From 98e2821b38a775737e42a2479a6bc65107210859 Mon Sep 17 00:00:00 2001 From: Elliot Kroo Date: Thu, 11 Mar 2010 15:21:30 -0800 Subject: reorganizing the first level of folders (trunk/branch folders are not the git way :) --- .../org/mozilla/javascript/drivers/JsDriver.java | 838 --------------------- .../org/mozilla/javascript/drivers/ShellTest.java | 346 --------- .../mozilla/javascript/drivers/StandardTests.java | 212 ------ .../org/mozilla/javascript/drivers/results.html | 105 --- .../mozilla/javascript/tests/Bug409702Test.java | 49 -- .../javascript/tests/JavaAcessibilityTest.java | 99 --- .../javascript/tests/PrivateAccessClass.java | 89 --- 7 files changed, 1738 deletions(-) delete mode 100644 trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/drivers/JsDriver.java delete mode 100644 trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/drivers/ShellTest.java delete mode 100644 trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/drivers/StandardTests.java delete mode 100644 trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/drivers/results.html delete mode 100644 trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/tests/Bug409702Test.java delete mode 100644 trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/tests/JavaAcessibilityTest.java delete mode 100644 trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/tests/PrivateAccessClass.java (limited to 'trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript') diff --git a/trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/drivers/JsDriver.java b/trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/drivers/JsDriver.java deleted file mode 100644 index 8bae79f..0000000 --- a/trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/drivers/JsDriver.java +++ /dev/null @@ -1,838 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the Java port of jsDriver.pl. - * - * The Initial Developer of the Original Code is - * David P. Caldwell. - * Portions created by David P. Caldwell are Copyright (C) - * 2007 David P. Caldwell. All Rights Reserved. - * - * - * Contributor(s): - * David P. Caldwell - * Norris Boyd - * - * Alternatively, the contents of this file may be used under the terms of - * the GNU General Public License Version 2 or later (the "GPL"), in which - * case the provisions of the GPL are applicable instead of those above. If - * you wish to allow use of your version of this file only under the terms of - * the GPL and not to allow others to use your version of this file under the - * MPL, indicate your decision by deleting the provisions above and replacing - * them with the notice and other provisions required by the GPL. If you do - * not delete the provisions above, a recipient may use your version of this - * file under either the MPL or the GPL. - * - * ***** END LICENSE BLOCK ***** */ - -package org.mozilla.javascript.drivers; - -import java.io.*; -import java.util.*; - -import org.w3c.dom.*; - -import org.mozilla.javascript.tools.shell.*; - -/** - * @version $Id: JsDriver.java,v 1.5 2007/10/11 19:44:10 szegedia%freemail.hu Exp $ - */ -public class JsDriver { - private JsDriver() { - } - - private static String join(String[] list) { - String rv = ""; - for (int i=0; i 0) { - rv += "\n"; - } - rv += line; - } - } - return rv; - } catch (IOException e) { - throw new RuntimeException("Can't happen."); - } - } - - boolean failed() { - return failed; - } - - void finish() { - if (failed) { - getElementById(failureHtml, "failureDetails.status").setTextContent(getLinesStartingWith("STATUS:")); - - String bn = getLinesStartingWith("BUGNUMBER:"); - Element bnlink = getElementById(failureHtml, "failureDetails.bug.href"); - if (bn.length() > 0) { - String number = bn.substring("BUGNUMBER: ".length()); - if (!number.equals("none")) { - bnlink.setAttribute("href", bugUrl + number); - getElementById(bnlink, "failureDetails.bug.number").setTextContent(number); - } else { - bnlink.getParentNode().removeChild(bnlink); - } - } else { - bnlink.getParentNode().removeChild(bnlink); - } - - getElementById(failureHtml, "failureDetails.lxr").setAttribute("href", lxrUrl + testPath); - getElementById(failureHtml, "failureDetails.lxr.text").setTextContent(testPath); - - getElementById(html.getDocumentElement(), "retestList.text").setTextContent( - getElementById(html.getDocumentElement(), "retestList.text").getTextContent() - + testPath - + "\n" - ); - - getElementById(html.getDocumentElement(), "failureDetails").appendChild(failureHtml); - } - } - } - - private static class XmlStatus extends ShellTest.Status { - private Element target; - private Date start; - - XmlStatus(String path, Element root) { - this.target = root.getOwnerDocument().createElement("test"); - this.target.setAttribute("path", path); - root.appendChild(target); - } - - void running(File file) { - this.start = new Date(); - } - - private Element createElement(Element parent, String name) { - Element rv = parent.getOwnerDocument().createElement(name); - parent.appendChild(rv); - return rv; - } - - private void finish() { - Date end = new Date(); - long elapsed = end.getTime() - start.getTime(); - this.target.setAttribute("elapsed", String.valueOf(elapsed)); - } - - private void setTextContent(Element e, String content) { - e.setTextContent( newlineLineEndings(content) ); - } - - void exitCodesWere(int expected, int actual) { - finish(); - Element exit = createElement(target, "exit"); - exit.setAttribute("expected", String.valueOf(expected)); - exit.setAttribute("actual", String.valueOf(actual)); - } - - void timedOut() { - finish(); - createElement(target, "timedOut"); - } - - void failed(String s) { - finish(); - Element failed = createElement(target, "failed"); - setTextContent(failed, s); - } - - void outputWas(String message) { - finish(); - Element output = createElement(target, "output"); - setTextContent(output, message); - } - - void threw(Throwable t) { - finish(); - Element threw = createElement(target, "threw"); - setTextContent(threw, ShellTest.getStackTrace(t)); - } - } - - private static class Results { - private ShellContextFactory factory; - private Arguments arguments; - private File output; - private boolean trace; - - private Document html; - private Element failureHtml; - - private Document xml; - - private Date start; - private int tests; - private int failures; - - Results(ShellContextFactory factory, Arguments arguments, boolean trace) { - this.factory = factory; - this.arguments = arguments; - - File output = arguments.getOutputFile(); - if (output == null) { - output = new File("rhino-test-results." + new java.text.SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").format(new Date()) + ".html"); - } - this.output = output; - - this.trace = trace; - } - - private Document parse(InputStream in) { - try { - javax.xml.parsers.DocumentBuilderFactory factory = javax.xml.parsers.DocumentBuilderFactory.newInstance(); - factory.setValidating(false); - javax.xml.parsers.DocumentBuilder dom = factory.newDocumentBuilder(); - return dom.parse(in); - } catch (Throwable t) { - throw new RuntimeException("Parser failure", t); - } - } - - private Document getTemplate() { - return parse(getClass().getResourceAsStream("results.html")); - } - - private void write(Document template, boolean xml) { - try { - File output = this.output; - javax.xml.transform.TransformerFactory factory = javax.xml.transform.TransformerFactory.newInstance(); - javax.xml.transform.Transformer xform = factory.newTransformer(); - if (xml) { - xform.setOutputProperty(javax.xml.transform.OutputKeys.METHOD, "xml"); - xform.setOutputProperty(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes"); - output = new File(output.getCanonicalPath() + ".xml"); - } - xform.transform( - new javax.xml.transform.dom.DOMSource(template), - new javax.xml.transform.stream.StreamResult( new FileOutputStream(output) ) - ); - } catch (IOException e) { - arguments.getConsole().println("Could not write results file to " + output + ": "); - e.printStackTrace(System.err); - } catch (javax.xml.transform.TransformerConfigurationException e) { - throw new RuntimeException("Parser failure", e); - } catch (javax.xml.transform.TransformerException e) { - throw new RuntimeException("Parser failure", e); - } - } - - void start() { - this.html = getTemplate(); - this.failureHtml = getElementById(html.getDocumentElement(), "failureDetails.prototype"); - if (this.failureHtml == null) { - try { - javax.xml.transform.TransformerFactory.newInstance().newTransformer().transform( - new javax.xml.transform.dom.DOMSource(html), - new javax.xml.transform.stream.StreamResult(System.err) - ); - } catch (Throwable t) { - throw new RuntimeException(t); - } - throw new RuntimeException("No"); - } - this.failureHtml.getParentNode().removeChild(this.failureHtml); - - try { - this.xml = javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder() - .getDOMImplementation().createDocument(null, "results", null) - ; - xml.getDocumentElement().setAttribute("timestamp", String.valueOf(new Date().getTime())); - xml.getDocumentElement().setAttribute("optimization", String.valueOf(arguments.getOptimizationLevel())); - xml.getDocumentElement().setAttribute("strict", String.valueOf(arguments.isStrict())); - xml.getDocumentElement().setAttribute("timeout", String.valueOf(arguments.getTimeout())); - } catch (javax.xml.parsers.ParserConfigurationException e) { - throw new RuntimeException(e); - } - - this.start = new Date(); - } - - void run(Tests.Script script, ShellTest.Parameters parameters) { - String path = script.getPath(); - File test = script.getFile(); - ConsoleStatus cStatus = new ConsoleStatus(arguments.getConsole(), trace); - HtmlStatus hStatus = new HtmlStatus(arguments.getLxrUrl(), arguments.getBugUrl(), path, html, (Element)failureHtml.cloneNode(true)); - XmlStatus xStatus = new XmlStatus(path, this.xml.getDocumentElement()); - ShellTest.Status status = ShellTest.Status.compose(new ShellTest.Status[] { cStatus, hStatus, xStatus }); - try { - ShellTest.run(factory, test, parameters, status); - } catch (Exception e) { - throw new RuntimeException(e); - } - tests++; - if (hStatus.failed()) { - failures++; - } - hStatus.finish(); - } - - private void set(Document document, String id, String value) { - getElementById(document.getDocumentElement(), id).setTextContent(value); - } - - void finish() { - Date end = new Date(); - long elapsedMs = end.getTime() - start.getTime(); - set(html, "results.testlist", join(arguments.getTestList())); - set(html, "results.skiplist", join(arguments.getSkipList())); - String pct = new java.text.DecimalFormat("##0.00").format( (double)failures / (double)tests * 100.0 ); - set(html, "results.results", "Tests attempted: " + tests + " Failures: " + failures + " (" + pct + "%)"); - set(html, "results.platform", "java.home=" + System.getProperty("java.home") - + "\n" + "java.version=" + System.getProperty("java.version") - + "\n" + "os.name=" + System.getProperty("os.name") - ); - set(html, "results.classpath", System.getProperty("java.class.path").replace(File.pathSeparatorChar, ' ')); - int elapsedSeconds = (int)(elapsedMs / 1000); - int elapsedMinutes = elapsedSeconds / 60; - elapsedSeconds = elapsedSeconds % 60; - String elapsed = "" + elapsedMinutes + " minutes, " + elapsedSeconds + " seconds"; - set(html, "results.elapsed", elapsed); - set(html, "results.time", new java.text.SimpleDateFormat("MMMM d yyyy h:mm:ss aa").format(new java.util.Date())); - write(html, false); - write(xml, true); - } - } - - private static class ShellTestParameters extends ShellTest.Parameters { - private int timeout; - - ShellTestParameters(int timeout) { - this.timeout = timeout; - } - - int getTimeoutMilliseconds() { - return timeout; - } - } - - void run(Arguments arguments) throws Throwable { - if (arguments.help()) { - System.out.println("See mozilla/js/tests/README-jsDriver.html; note that some options are not supported."); - System.out.println("Consult the Java source code at testsrc/org/mozilla/javascript/JsDriver.java for details."); - System.exit(0); - } - - ShellContextFactory factory = new ShellContextFactory(); - factory.setOptimizationLevel(arguments.getOptimizationLevel()); - factory.setStrictMode(arguments.isStrict()); - - File path = arguments.getTestsPath(); - if (path == null) { - path = new File("../tests"); - } - if (!path.exists()) { - throw new RuntimeException("JavaScript tests not found at " + path.getCanonicalPath()); - } - Tests tests = new Tests(path, arguments.getTestList(), arguments.getSkipList()); - Tests.Script[] all = tests.getFiles(); - arguments.getConsole().println("Running " + all.length + " tests."); - - Results results = new Results(factory, arguments, arguments.trace()); - - results.start(); - for (int i=0; i 0; - } - - File getFile() { - if (getValue() == null) return null; - return new File(getValue()); - } - - String[] getValues() { - return (String[])values.toArray(new String[0]); - } - - void process(List arguments) { - String option = (String)arguments.get(0); - String dashLetter = (letterOption == null) ? (String)null : "-" + letterOption; - if (option.equals(dashLetter) || option.equals("--" + wordOption)) { - arguments.remove(0); - if (flag) { - values.add(0, (String)null ); - } else if (array) { - while( arguments.size() > 0 && !( (String)arguments.get(0) ).startsWith("-") ) { - values.add(arguments.remove(0)); - } - } else { - values.set(0, arguments.remove(0)); - } - if (ignored) { - System.err.println("WARNING: " + option + " is ignored in the Java version of the test driver."); - } - } - } - } - - // -b URL, --bugurl=URL - public String getBugUrl() { - return bugUrl.getValue(); - } - - // -c PATH, --classpath=PATH - // Does not apply; we will use the VM's classpath - - // -e TYPE ..., --engine=TYPE ... - // Does not apply; was used to select between SpiderMonkey and Rhino - - // Not in jsDriver.pl - public int getOptimizationLevel() { - return optimizationLevel.getInt(); - } - - // --strict - public boolean isStrict() { - return strict.getSwitch(); - } - - // -f FILE, --file=FILE - public File getOutputFile() { - return outputFile.getFile(); - } - - // -h, --help - public boolean help() { - return help.getSwitch(); - } - - // -j PATH, --javapath=PATH - // Does not apply; we will use this JVM - - // -k, --confail - // TODO Currently this is ignored; not clear precisely what it means (perhaps we should not be logging ordinary - // pass/fail to the console currently?) - public boolean logFailuresToConsole() { - return logFailuresToConsole.getSwitch(); - } - - // -l FILE,... or --list=FILE,... - public String[] getTestList() { - return testList.getValues(); - } - - // -L FILE,... or --neglist=FILE,... - public String[] getSkipList() { - return skipList.getValues(); - } - - // -p PATH, --testpath=PATH - public File getTestsPath() { - return testsPath.getFile(); - } - - // -s PATH, --shellpath=PATH - // Does not apply; we will use the Rhino shell with any classes given on the classpath - - // -t, --trace - public boolean trace() { - return trace.getSwitch(); - } - - // -u URL, --lxrurl=URL - public String getLxrUrl() { - return lxrUrl.getValue(); - } - - // - // New arguments - // - - // --timeout - // Milliseconds to wait for each test - public int getTimeout() { - return timeout.getInt(); - } - - public Console getConsole() { - return console; - } - - void process(List arguments) { - while(arguments.size() > 0) { - String option = (String)arguments.get(0); - if (option.startsWith("--")) { - // preprocess --name=value options into --name value - if (option.indexOf("=") != -1) { - arguments.set(0, option.substring(option.indexOf("="))); - arguments.add(1, option.substring(option.indexOf("=") + 1)); - } - } else if (option.startsWith("-")) { - // could be multiple single-letter options, e.g. -kht, so preprocess them into -k -h -t - if (option.length() > 2) { - for (int i=2; i 0) { - ((Option)options.get(i)).process(arguments); - } - } - - if (arguments.size() == lengthBefore) { - System.err.println("WARNING: ignoring unrecognized option " + arguments.remove(0)); - } - } - } - } - - public static void main(String[] args) throws Throwable { - ArrayList arguments = new ArrayList(); - arguments.addAll(Arrays.asList(args)); - Arguments clArguments = new Arguments(); - clArguments.process(arguments); - main(clArguments); - } -} diff --git a/trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/drivers/ShellTest.java b/trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/drivers/ShellTest.java deleted file mode 100644 index 9acf64e..0000000 --- a/trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/drivers/ShellTest.java +++ /dev/null @@ -1,346 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the Java port of jsDriver.pl. - * - * The Initial Developer of the Original Code is - * David P. Caldwell. - * Portions created by David P. Caldwell are Copyright (C) - * 2007 David P. Caldwell. All Rights Reserved. - * - * - * Contributor(s): - * David P. Caldwell - * - * Alternatively, the contents of this file may be used under the terms of - * the GNU General Public License Version 2 or later (the "GPL"), in which - * case the provisions of the GPL are applicable instead of those above. If - * you wish to allow use of your version of this file only under the terms of - * the GPL and not to allow others to use your version of this file under the - * MPL, indicate your decision by deleting the provisions above and replacing - * them with the notice and other provisions required by the GPL. If you do - * not delete the provisions above, a recipient may use your version of this - * file under either the MPL or the GPL. - * - * ***** END LICENSE BLOCK ***** */ - -package org.mozilla.javascript.drivers; - -import org.mozilla.javascript.*; -import java.io.*; -import java.util.*; - -import org.mozilla.javascript.tools.shell.*; - -/** - * @version $Id: ShellTest.java,v 1.5 2007/10/11 19:44:10 szegedia%freemail.hu Exp $ - */ -class ShellTest { - static final FileFilter DIRECTORY_FILTER = new FileFilter() { - public boolean accept(File pathname) - { - return pathname.isDirectory() && !pathname.getName().equals("CVS"); - } - }; - - static final FileFilter TEST_FILTER = new FileFilter() { - public boolean accept(File pathname) - { - return pathname.getName().endsWith(".js") && !pathname.getName().equals("shell.js") && !pathname.getName().equals("browser.js") && !pathname.getName().equals("template.js"); - } - }; - - static String getStackTrace(Throwable t) { - ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - t.printStackTrace(new PrintStream(bytes)); - return new String(bytes.toByteArray()); - } - - private static void runFileIfExists(Context cx, Scriptable global, File f) - { - if(f.isFile()) - { - Main.processFile(cx, global, f.getPath()); - } - } - - private static class TestState - { - boolean finished; - ErrorReporterWrapper errors; - int exitCode = 0; - } - - static abstract class Status { - private boolean negative; - - final void setNegative() { - this.negative = true; - } - - final boolean isNegative() { - return this.negative; - } - - final void hadErrors(JsError[] errors) { - if (!negative && errors.length > 0) { - failed("JavaScript errors:\n" + JsError.toString(errors)); - } else if (negative && errors.length == 0) { - failed("Should have produced runtime error."); - } - } - - abstract void running(File jsFile); - - abstract void failed(String s); - abstract void threw(Throwable t); - abstract void timedOut(); - abstract void exitCodesWere(int expected, int actual); - abstract void outputWas(String s); - - static Status compose(final Status[] array) { - return new Status() { - void running(File file) { - for (int i=0; i - * - * Alternatively, the contents of this file may be used under the terms of - * the GNU General Public License Version 2 or later (the "GPL"), in which - * case the provisions of the GPL are applicable instead of those above. If - * you wish to allow use of your version of this file only under the terms of - * the GPL and not to allow others to use your version of this file under the - * MPL, indicate your decision by deleting the provisions above and replacing - * them with the notice and other provisions required by the GPL. If you do - * not delete the provisions above, a recipient may use your version of this - * file under either the MPL or the GPL. - * - * ***** END LICENSE BLOCK ***** */ - -package org.mozilla.javascript.drivers; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.Arrays; -import java.util.Properties; - -import junit.framework.Assert; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -import org.mozilla.javascript.tools.shell.ShellContextFactory; - -/** - * Executes the tests in the js/tests directory, much like jsDriver.pl does. - * Excludes tests found in the js/tests/rhino-n.tests file. - * @author Attila Szegedi - * @version $Id: StandardTests.java,v 1.6.2.2 2008/02/11 16:57:16 nboyd%atg.com Exp $ - */ -public class StandardTests extends TestSuite -{ - public static TestSuite suite() throws Exception - { - TestSuite suite = new TestSuite("Standard JavaScript tests"); - - File testDir = null; - if (System.getProperty("mozilla.js.tests") != null) { - testDir = new File(System.getProperty("mozilla.js.tests")); - } else { - URL url = StandardTests.class.getResource("."); - String path = url.getFile(); - int jsIndex = path.lastIndexOf("/js"); - if(jsIndex == -1) - { - throw new IllegalStateException("You aren't running the tests from within the standard mozilla/js directory structure"); - } - path = path.substring(0, jsIndex + 3).replace('/', File.separatorChar); - testDir = new File(path, "tests"); - } - if(!testDir.isDirectory()) - { - throw new FileNotFoundException(testDir + " is not a directory"); - } - Properties excludes = new Properties(); - loadExcludes(excludes, "/base.skip"); - Properties opt1Excludes = new Properties(); - loadExcludes(opt1Excludes, "/opt1.skip"); - opt1Excludes.putAll(excludes); - for(int i = -1; i < 2; ++i) - { - TestSuite optimizationLevelSuite = new TestSuite("Optimization level " + i); - addSuites(optimizationLevelSuite, testDir, i == -1 ? excludes : opt1Excludes, i); - suite.addTest(optimizationLevelSuite); - } - return suite; - } - - private static void loadExcludes(Properties excludes, String excludeFileName) throws IOException - { - InputStream in = StandardTests.class.getResourceAsStream(excludeFileName); - try - { - excludes.load(in); - } - finally - { - in.close(); - } - } - - private static void addSuites(TestSuite topLevel, File testDir, Properties excludes, int optimizationLevel) - { - File[] subdirs = testDir.listFiles(ShellTest.DIRECTORY_FILTER); - Arrays.sort(subdirs); - for (int i = 0; i < subdirs.length; i++) - { - File subdir = subdirs[i]; - String name = subdir.getName(); - TestSuite testSuite = new TestSuite(name); - addCategories(testSuite, subdir, name + "/", excludes, optimizationLevel); - topLevel.addTest(testSuite); - } - } - - private static void addCategories(TestSuite suite, File suiteDir, String prefix, Properties excludes, int optimizationLevel) - { - File[] subdirs = suiteDir.listFiles(ShellTest.DIRECTORY_FILTER); - Arrays.sort(subdirs); - for (int i = 0; i < subdirs.length; i++) - { - File subdir = subdirs[i]; - String name = subdir.getName(); - TestSuite testCategory = new TestSuite(name); - addTests(testCategory, subdir, prefix + name + "/", excludes, optimizationLevel); - suite.addTest(testCategory); - } - } - - private static void addTests(TestSuite suite, File suiteDir, String prefix, Properties excludes, int optimizationLevel) - { - File[] jsFiles = suiteDir.listFiles(ShellTest.TEST_FILTER); - Arrays.sort(jsFiles); - for (int i = 0; i < jsFiles.length; i++) - { - File jsFile = jsFiles[i]; - String name = jsFile.getName(); - if(!excludes.containsKey(prefix + name)) - { - suite.addTest(new JsTestCase(jsFile, optimizationLevel)); - } - } - } - - private static class JunitStatus extends ShellTest.Status { - final void running(File jsFile) { - // do nothing - } - - final void failed(String s) { - Assert.fail(s); - } - - final void exitCodesWere(int expected, int actual) { - Assert.assertEquals("Unexpected exit code", expected, actual); - } - - final void outputWas(String s) { - System.out.print(s); - } - - final void threw(Throwable t) { - Assert.fail(ShellTest.getStackTrace(t)); - } - - final void timedOut() { - failed("Timed out."); - } - } - - private static final class JsTestCase extends TestCase - { - private final File jsFile; - private final int optimizationLevel; - - JsTestCase(File jsFile, int optimizationLevel) - { - super(jsFile.getName() + (optimizationLevel == 1 ? "-compiled" : "-interpreted")); - this.jsFile = jsFile; - this.optimizationLevel = optimizationLevel; - } - - public int countTestCases() - { - return 1; - } - - private static class ShellTestParameters extends ShellTest.Parameters { - int getTimeoutMilliseconds() { - if (System.getProperty("mozilla.js.tests.timeout") != null) { - return Integer.parseInt(System.getProperty("mozilla.js.tests.timeout")); - } - return 60000; - } - } - - public void runBare() throws Exception - { - final ShellContextFactory shellContextFactory = new ShellContextFactory(); - shellContextFactory.setOptimizationLevel(optimizationLevel); - ShellTest.run(shellContextFactory, jsFile, new ShellTestParameters(), new JunitStatus()); - } - } -} diff --git a/trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/drivers/results.html b/trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/drivers/results.html deleted file mode 100644 index 36bd729..0000000 --- a/trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/drivers/results.html +++ /dev/null @@ -1,105 +0,0 @@ - - -Rhino: Test Results - - - -

Results of JavaScript Test Library for Rhino

-
-

Summary

-

- - - - - - - - - - - - - - - - - - - - - - - - - -
- Test List - - - -
- Skip List - - - -
- Results - - - -
- Platform, JRE - - - -
- Classpath - - -
- Time - - Execution took , ending at -
-

-

- Failure Details - Retest List -

-
-
- -

Failure Details

-
-

- Testcase path failed - Bug Number XXX -

-
-
-				
-
-				
-
-				
-
- -
-
- -
- -

Retest List

-

-		Top of Page
-		Top of Retest List
-	
- - diff --git a/trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/tests/Bug409702Test.java b/trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/tests/Bug409702Test.java deleted file mode 100644 index e9793cb..0000000 --- a/trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/tests/Bug409702Test.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * - */ -package org.mozilla.javascript.tests; - -import junit.framework.TestCase; - -import org.mozilla.javascript.*; - -/** - * See https://bugzilla.mozilla.org/show_bug.cgi?id=409702 - * @author Norris Boyd - */ -public class Bug409702Test extends TestCase { - - public static abstract class Test { - public Test() { - } - - public abstract void a(); - - public abstract int b(); - - public static abstract class Subclass extends Test { - - @Override - public final void a() { - } - } - } - - public void testAdapter() { - final int value = 12; - String source = - "var instance = " + - " new JavaAdapter(" + getClass().getName() + ".Test.Subclass," + - "{ b: function () { return " + value + "; } });" + - "instance.b();"; - - Context cx = ContextFactory.getGlobal().enterContext(); - try { - Scriptable scope = cx.initStandardObjects(); - Object result = cx.evaluateString(scope, source, "source", 1, null); - assertEquals(new Integer(value), result); - } finally { - Context.exit(); - } - } -} diff --git a/trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/tests/JavaAcessibilityTest.java b/trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/tests/JavaAcessibilityTest.java deleted file mode 100644 index b6cf3ca..0000000 --- a/trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/tests/JavaAcessibilityTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * - */ -package org.mozilla.javascript.tests; - -import junit.framework.TestCase; - -import org.mozilla.javascript.Context; -import org.mozilla.javascript.ContextAction; -import org.mozilla.javascript.ContextFactory; -import org.mozilla.javascript.NativeJavaObject; -import org.mozilla.javascript.Script; -import org.mozilla.javascript.tools.shell.Global; -import org.mozilla.javascript.tools.shell.ShellContextFactory; - -/** - * @author donnamalayeri - */ -public class JavaAcessibilityTest extends TestCase { - - protected final Global global = new Global(); - String importClass = "importClass(Packages.org.mozilla.javascript.tests.PrivateAccessClass)\n"; - - public JavaAcessibilityTest() { - global.init(contextFactory); - } - - private ContextFactory contextFactory = new ShellContextFactory() { - protected boolean hasFeature(Context cx, int featureIndex) { - if (featureIndex == Context.FEATURE_ENHANCED_JAVA_ACCESS) - return true; - return super.hasFeature(cx, featureIndex); - } - }; - - public void testAccessingFields() { - Object result = runScript(importClass + "PrivateAccessClass.staticPackagePrivateInt"); - assertEquals(new Integer(0), result); - - result = runScript(importClass + "PrivateAccessClass.staticPrivateInt"); - assertEquals(new Integer(1), result); - - result = runScript(importClass + "PrivateAccessClass.staticProtectedInt"); - assertEquals(new Integer(2), result); - - result = runScript(importClass + "new PrivateAccessClass().packagePrivateString"); - assertEquals("package private", ((NativeJavaObject) result).unwrap()); - - result = runScript(importClass + "new PrivateAccessClass().privateString"); - assertEquals("private", ((NativeJavaObject) result).unwrap()); - - result = runScript(importClass + "new PrivateAccessClass().protectedString"); - assertEquals("protected", ((NativeJavaObject) result).unwrap()); - - result = runScript(importClass + "new PrivateAccessClass.PrivateNestedClass().packagePrivateInt"); - assertEquals(new Integer(0), result); - - result = runScript(importClass + "new PrivateAccessClass.PrivateNestedClass().privateInt"); - assertEquals(new Integer(1), result); - - result = runScript(importClass + "new PrivateAccessClass.PrivateNestedClass().protectedInt"); - assertEquals(new Integer(2), result); - } - - public void testAccessingMethods() { - Object result = runScript(importClass + "PrivateAccessClass.staticPackagePrivateMethod()"); - assertEquals(new Integer(0), result); - - result = runScript(importClass + "PrivateAccessClass.staticPrivateMethod()"); - assertEquals(new Integer(1), result); - - result = runScript(importClass + "PrivateAccessClass.staticProtectedMethod()"); - assertEquals(new Integer(2), result); - - result = runScript(importClass + "new PrivateAccessClass().packagePrivateMethod()"); - assertEquals(new Integer(3), result); - - result = runScript(importClass + "new PrivateAccessClass().privateMethod()"); - assertEquals(new Integer(4), result); - - result = runScript(importClass + "new PrivateAccessClass().protectedMethod()"); - assertEquals(new Integer(5), result); - } - - public void testAccessingConstructors() { - runScript(importClass + "new PrivateAccessClass(\"foo\")"); - runScript(importClass + "new PrivateAccessClass(5)"); - runScript(importClass + "new PrivateAccessClass(5, \"foo\")"); - } - - private Object runScript(final String scriptSourceText) { - return this.contextFactory.call(new ContextAction() { - public Object run(Context context) { - Script script = context.compileString(scriptSourceText, "", 1, null); - return script.exec(context, global); - } - }); - } -} diff --git a/trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/tests/PrivateAccessClass.java b/trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/tests/PrivateAccessClass.java deleted file mode 100644 index 08f95a3..0000000 --- a/trunk/infrastructure/rhino1_7R1/testsrc/org/mozilla/javascript/tests/PrivateAccessClass.java +++ /dev/null @@ -1,89 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Rhino code, released May 6, 1999. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1997-1999 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Attila Szegedi - * David P. Caldwell - * - * Alternatively, the contents of this file may be used under the terms of - * the GNU General Public License Version 2 or later (the "GPL"), in which - * case the provisions of the GPL are applicable instead of those above. If - * you wish to allow use of your version of this file only under the terms of - * the GPL and not to allow others to use your version of this file under the - * MPL, indicate your decision by deleting the provisions above and replacing - * them with the notice and other provisions required by the GPL. If you do - * not delete the provisions above, a recipient may use your version of this - * file under either the MPL or the GPL. - * - * ***** END LICENSE BLOCK ***** */ - -package org.mozilla.javascript.tests; - -/** - * A class with private/protected/package private members, to test the Rhino - * feature Context.FEATURE_ENHANCED_JAVA_ACCESS, that allows bypassing Java - * member access restrictions. - * @author Donna Malayeri - */ - -public class PrivateAccessClass -{ - private PrivateAccessClass() { } - PrivateAccessClass(String s) { } - private PrivateAccessClass(int x) { } - protected PrivateAccessClass(int x, String s) { } - - private static class PrivateNestedClass - { - private PrivateNestedClass() { } - - int packagePrivateInt = 0; - private int privateInt = 1; - protected int protectedInt = 2; - } - - static int staticPackagePrivateInt = 0; - private static int staticPrivateInt = 1; - protected static int staticProtectedInt = 2; - - String packagePrivateString = "package private"; - private String privateString = "private"; - protected String protectedString = "protected"; - - static int staticPackagePrivateMethod() { return 0; } - static private int staticPrivateMethod() { return 1; } - static protected int staticProtectedMethod() { return 2; } - - int packagePrivateMethod() { return 3; } - private int privateMethod() { return 4; } - protected int protectedMethod() { return 5; } - - /* - * Suppress warnings about unused private members. - */ - public int referenceToPrivateMembers() { - PrivateAccessClass pac = new PrivateAccessClass(); - PrivateAccessClass pac2 = new PrivateAccessClass(2); - PrivateNestedClass pnc = new PrivateNestedClass(); - System.out.println(privateString); - return pnc.privateInt + staticPrivateInt + staticPrivateMethod() + - pac.privateMethod(); - } -} -- cgit v1.2.3