--- /dev/null
+testmenu:
+ exec perl mklistpage.pl > menubody.html
+ cat menuhead.html menubody.html menufoot.html > menu.html
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+ <head>
+ <title>jsDriver.pl</title>
+ </head>
+
+ <body bgcolor="white">
+ <h1 align="right">jsDriver.pl</h1>
+
+ <dl>
+ <dt><b>NAME</b></dt>
+ <dd>
+ <b>jsDriver.pl</b> - execute JavaScript programs in various shells in
+ batch or single mode, reporting on failures encountered.
+ <br>
+ <br>
+
+ <dt><b>SYNOPSIS</b></dt>
+ <dd>
+ <table>
+ <tr>
+ <td align="right" valign="top">
+ <code>
+ <b>jsDriver.pl</b>
+ </code>
+ </td>
+ <td>
+ <code>
+ [-hkt] [-b BUGURL] [-c CLASSPATH] [-f OUTFILE]
+ [-j JAVAPATH] [-l TESTLIST ...] [-L NEGLIST ...] [-p TESTPATH]
+ [-s SHELLPATH] [-u LXRURL] [--help] [--confail] [--trace]
+ [--classpath=CLASSPATH] [--file=OUTFILE] [--javapath=JAVAPATH]
+ [--list=TESTLIST] [--neglist=TESTLIST] [--testpath=TESTPATH]
+ [--shellpath=SHELLPATH] [--lxrurl=LXRURL] {-e ENGINETYPE |
+ --engine=ENGINETYPE}
+ </code>
+ </td>
+ </tr>
+ </table>
+ <br>
+ <br>
+
+ <dt><b>DESCRIPTION</b></dt>
+ <dd>
+ <b>jsDriver.pl</b> is normally used to run a series of tests against
+ one of the JavaScript shells. These tests are expected to be laid out
+ in a directory structure exactly three levels deep. The first level
+ is considered the <b>root</b> of the tests, subdirectories under the
+ <b>root</b> represent <b>Test Suites</b> and generally mark broad
+ categories such as <i>ECMA Level 1</i> or <i>Live Connect 3</i>. Under the
+ <b>Test Suites</b> are the <b>Test Categories</b>, which divide the
+ <b>Test Suite</b> into smaller categories, such as <i>Execution Contexts</i>
+ or <i>Lexical Rules</i>. Testcases are located under the
+ <B>Test Categories</b> as normal JavaScript (*.js) files.
+ <p>
+ If a file named <b>shell.js</b> exists in either the
+ <b>Test Suite</b> or the <b>Test Category</b> directory, it is
+ loaded into the shell before the testcase. If <b>shell.js</b>
+ exists in both directories, the version in the <b>Test Suite</b>
+ directory is loaded <i>first</i>, giving the version associated with
+ the <b>Test Category</b> the ability to override functions previously
+ declared. You can use this to
+ create functions and variables common to an entire suite or category.
+ <p>
+ Testcases can report failures back to <b>jsDriver.pl</b> in one of
+ two ways. The most common is to write a line of text containing
+ the word <code>FAILED!</code> to <b>STDOUT</b> or <b>STDERR</b>.
+ When the engine encounters a matching line, the test is marked as
+ failed, and any line containing <code>FAILED!</code> is displayed in
+ the failure report. The second way a test case can report failure is
+ to return an unexpected exit code. By default, <b>jsDriver.pl</b>
+ expects all test cases to return exit code 0, although a test
+ can output a line containing <code>EXPECT EXIT <i>n</i></code> where
+ <i>n</i> is the exit code the driver should expect to see. Testcases
+ can return a nonzero exit code by calling the shell function
+ <code>quit(<i>n</i>)</code> where <code><i>n</i></code> is the
+ code to exit with. The various JavaScript shells report
+ non-zero exit codes under the following conditions:
+
+ <center>
+ <table border="1">
+ <tr>
+ <th>Reason</th>
+ <th>Exit Code</th>
+ </tr>
+ <tr>
+ <td>
+ Engine initialization failure.
+ </td>
+ <td>
+ 1
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Invalid argument on command line.
+ </td>
+ <td>
+ 2
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Runtime error (uncaught exception) encountered.
+ </td>
+ <td>
+ 3
+ </td>
+ </tr>
+ <tr>
+ <td>
+ File argument specified on command line not found.
+ </td>
+ <td>
+ 4
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Reserved for future use.
+ </td>
+ <td>
+ 5-9
+ </td>
+ </tr>
+ </table>
+ </center>
+ <br>
+ <br>
+
+ <dt><b>OPTIONS</b></dt>
+ <dd>
+ <dl>
+ <dt><b>-b URL, --bugurl=URL</b></dt>
+ <dd>
+ Bugzilla URL. When a testcase writes a line in the format
+ <code>BUGNUMBER <i>n</i></code> to <b>STDOUT</b> or <b>STDERR</b>,
+ <b>jsDriver.pl</b> interprets <code><i>n</i></code> as a bugnumber
+ in the <a href="http://bugzilla.mozilla.org">BugZilla</a> bug
+ tracking system. In the event that a testcase which has specified
+ a bugnumber fails, a hyperlink to the BugZilla database
+ will be included in the output by prefixing the bugnumber with the
+ URL specified here. By default, URL is assumed to be
+ "http://bugzilla.mozilla.org/show_bug.cgi?id=".
+ <br>
+ <br>
+ <a name="classpath"></a>
+ <dt><b>-c PATH, --classpath=PATH</b></dt>
+ <dd>
+ Classpath to pass the the Java Virtual Machine. When running tests
+ against the <b>Rhino</b> engine, PATH will be passed in as the value
+ to an argument named "-classpath". If your particular JVM
+ does not support this option, it is recommended you specify your
+ class path via an environment setting. Refer to your JVM
+ documentation for more details about CLASSPATH.
+ <br>
+ <br>
+ <dt><b>-e TYPE ..., --engine=TYPE ...</b></dt>
+ <dd>
+ Required. Type of engine(s) to run the tests against. TYPE can be
+ one or more of the following values:
+ <center>
+ <table border="1">
+ <tr>
+ <th>TYPE</th>
+ <th>Engine</th>
+ </tr>
+ <tr>
+ <td>lcopt</td>
+ <td>LiveConnect, optimized</td>
+ </tr>
+ <tr>
+ <td>lcdebug</td>
+ <td>LiveConnect, debug</td>
+ </tr>
+ <tr>
+ <td>rhino</td>
+ <td>Rhino compiled mode</td>
+ </tr>
+ <tr>
+ <td>rhinoi</td>
+ <td>Rhino interpreted mode</td>
+ </tr>
+ <tr>
+ <td>rhinoms</td>
+ <td>Rhino compiled mode for the Microsoft VM (jview)</td>
+ </tr>
+ <tr>
+ <td>rhinomsi</td>
+ <td>Rhino interpreted mode for the Microsoft VM (jview)</td>
+ </tr>
+ <tr>
+ <td>smopt</td>
+ <td>Spider-Monkey, optimized</td>
+ </tr>
+ <tr>
+ <td>smdebug</td>
+ <td>Spider-Monkey, debug</td>
+ </tr>
+ <tr>
+ <td>xpcshell</td>
+ <td>XPConnect shell</td>
+ </tr>
+ </table>
+ </center>
+ <br>
+ <br>
+ <dt><b>-f FILE, --file=FILE</b></dt>
+ <dd>
+ Generate html output to the HTML file named by FILE. By default,
+ a filename will be generated using a combination of the engine type
+ and a date/time stamp, in the format:
+ <code>results-<i><engine-type></i>-<i><date-stamp></i>.html</code>
+ <br>
+ <br>
+ <dt><b>-h, --help</b></dt>
+ <dd>
+ Prints usage information.
+ <br>
+ <br>
+ <dt><b>-j PATH, --javapath=PATH</b></dt>
+ <dd>
+ Set the location of the Java Virtual Machine to use when running
+ tests against the <b>Rhino</b> engine. This can be used to test
+ against multiple JVMs on the same system.
+ <br>
+ <br>
+ <dt><b>-k, --confail</b></dt>
+ <dd>
+ Log failures to the console. This will show any failures, as they
+ occur, on <b>STDERR</b> in addition to creating the HTML results
+ file. This can be useful for times when it may be
+ counter-productive to load an HTML version of the results each time
+ a test is re-run.
+ <br>
+ <br>
+ <dt><b>-l FILE ..., --list=FILE ...</b></dt>
+ <dd>
+ Specify a list of tests to execute. FILE can be a plain text file
+ containing a list of testcases to execute, a subdirectory
+ in which to
+ <a href="http://www.instantweb.com/~foldoc/foldoc.cgi?query=grovel">grovel</a>
+ for tests, or a single testcase to execute. Any number of FILE
+ specifiers may follow this option. The driver uses the fact that a
+ valid testcase should be a file ending in .js to make the distinction
+ between a file containing a list of tests and an actual testcase.
+ <br>
+ <br>
+ <dt><b>-L FILE ..., --neglist=FILE ...</b></dt>
+ <dd>
+ Specify a list of tests to skip. FILE has the same meaning as in
+ the <b>-l</b> option. This option is evaluated after
+ <b>all</b> <b>-l</b> and <b>--list</b> options, allowing a user
+ to subtract a single testcase, a directory of testcases, or a
+ collection of unrelated testcases from the execution list.
+ <br>
+ <br>
+ <dt><b>-p PATH, --testpath=PATH</b></dt>
+ <dd>
+ Directory holding the "Test Suite" subdirectories. By
+ default this is ./
+ <br>
+ <br>
+ <dt><b>-s PATH, --shellpath=PATH</b></dt>
+ <dd>
+ Directory holding the JavaScript shell. This can be used to override
+ the automatic shell location <b>jsDriver.pl</b> performs based on
+ you OS and engine type. For Non <b>Rhino</b> engines, this
+ includes the name of the executable as well as the path. In
+ <b>Rhino</b>, this path will be appended to your
+ <a href="#classpath">CLASSPATH</a>. For the
+ <b>SpiderMonkey</b> shells, this value defaults to
+ ../src/<Platform-and-buildtype-specific-directory>/[js|jsshell],
+ for the
+ <b>LiveConnect</b> shells,
+ ../src/liveconnect/src/<Platform-and-buildtype-specific-directory>/lschell
+ and for the <b>xpcshell</b> the default is the value of your
+ <code>MOZILLA_FIVE_HOME</code> environment variable. There is no
+ default (as it is usually not needed) for the <b>Rhino</b> shell.
+ <br>
+ <br>
+ <dt><b>-t, --trace</b></dt>
+ <dd>
+ Trace execution of <b>jsDriver.pl</b>. This option is primarily
+ used for debugging of the script itself, but if you are interested in
+ seeing the actual command being run, or generally like gobs of
+ useless information, you may find it entertaining.
+ <br>
+ <br>
+ <dt><b>-u URL, --lxrurl=URL</b></dt>
+ <dd>
+ Failures listed in the HTML results will be hyperlinked to the
+ lxr source available online by prefixing the test path and
+ name with this URL. By default, URL is
+ http://lxr.mozilla.org/mozilla/source/js/tests/
+ <br>
+ <br>
+
+ </dl>
+ <dt><b>SEE ALSO</b></dt>
+ <dd>
+ <a href="http://lxr.mozilla.org/mozilla/source/js/tests/jsDriver.pl">jsDriver.pl</a>,
+ <a href="http://lxr.mozilla.org/mozilla/source/js/tests/mklistpage.pl">mklistpage.pl</a>,
+ <a href="http://www.mozilla.org/js/">http://www.mozilla.org/js/</a>,
+ <a href="http://www.mozilla.org/js/tests/library.html">http://www.mozilla.org/js/tests/library.html</a>
+ <br>
+ <br>
+
+ <dt><b>REQUIREMENTS</b></dt>
+ <dd>
+ <b>jsDriver.pl</b> requires the
+ <a href="http://search.cpan.org/search?module=Getopt::Mixed">Getopt::Mixed</a>
+ perl package, available from <a href="http://www.cpan.org">cpan.org</a>.
+ <br>
+ <br>
+ <dt><b>EXAMPLES</b></dt>
+ <dd>
+ <code>perl jsDriver.pl -e smdebug -L lc*</code><br>
+ Executes all tests EXCEPT the liveconnect tests against the
+ SpiderMonkey debug shell, writing the results
+ to the default result file. (NOTE: Unix shells take care of wildcard
+ expansion, turning <code>lc*</code> into <code>lc2 lc3</code>. Under
+ a DOS shell, you must explicitly list the directories.)
+ <p>
+ <code>perl jsDriver.pl -e rhino -L rhino-n.tests</code><br>
+ Executes all tests EXCEPT those listed in the
+ <code>rhino-n.tests</code> file.
+ <p>
+ <code>perl -I/home/rginda/perl/lib/ jsDriver.pl -e lcopt -l lc2
+ lc3 -f lcresults.html -k</code><br>
+ Executes ONLY the tests under the <code>lc2</code> and <code>lc3</code>
+ directories against the LiveConnect shell. Results will be written to
+ the file <code>lcresults.html</code> <b>AND</b> the console. The
+ <code>-I</code> option tells perl to look for modules in the
+ <code>/home/rginda/perl/lib</code> directory (in addition to the
+ usual places), useful if you do not have root access to install new
+ modules on the system.
+ </dl>
+ <hr>
+ Author: Robert Ginda<br>
+ Currently maintained by <i><a href="mailto:pschwartau@netscape.com">Phil Schwartau</a> </i><br>
+<!-- Created: Thu Dec 2 19:08:05 PST 1999 -->
+ </body>
+</html>
--- /dev/null
+/* The contents of this file are subject to the Netscape 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/NPL/
+ *
+ * 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 Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ */
+/**
+ File Name: 15.4-1.js
+ ECMA Section: 15.4 Array Objects
+
+ Description: Every Array object has a length property whose value
+ is always an integer with positive sign and less than
+ Math.pow(2,32).
+
+ Author: christine@netscape.com
+ Date: 28 october 1997
+
+*/
+ var SECTION = "15.4-1";
+ var VERSION = "ECMA_1";
+ startTest();
+ var TITLE = "Array Objects";
+
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = getTestCases();
+ test();
+
+function getTestCases() {
+ var array = new Array();
+ var item = 0;
+
+ array[item++] = new TestCase( SECTION,
+ "var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr[Math.pow(2,32)-2]",
+ "hi",
+ eval("var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr[Math.pow(2,32)-2]")
+ );
+ array[item++] = new TestCase( SECTION,
+ "var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr.length",
+ (Math.pow(2,32)-1),
+ eval("var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr.length")
+ );
+ array[item++] = new TestCase( SECTION,
+ "var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr[Math.pow(2,32)-3]",
+ "hi",
+ eval("var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr[Math.pow(2,32)-3]")
+ );
+ array[item++] = new TestCase( SECTION,
+ "var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr.length",
+ (Math.pow(2,32)-2),
+ eval("var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr.length")
+ );
+
+ array[item++] = new TestCase( SECTION,
+ "var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr[Math.pow(2,31)-2]",
+ "hi",
+ eval("var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr[Math.pow(2,31)-2]")
+ );
+ array[item++] = new TestCase( SECTION,
+ "var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr.length",
+ (Math.pow(2,31)-1),
+ eval("var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr.length")
+ );
+
+ array[item++] = new TestCase( SECTION,
+ "var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr[Math.pow(2,31)-1]",
+ "hi",
+ eval("var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr[Math.pow(2,31)-1]")
+ );
+ array[item++] = new TestCase( SECTION,
+ "var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr.length",
+ (Math.pow(2,31)),
+ eval("var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr.length")
+ );
+
+
+ array[item++] = new TestCase( SECTION,
+ "var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr[Math.pow(2,31)]",
+ "hi",
+ eval("var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr[Math.pow(2,31)]")
+ );
+ array[item++] = new TestCase( SECTION,
+ "var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr.length",
+ (Math.pow(2,31)+1),
+ eval("var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr.length")
+ );
+
+ array[item++] = new TestCase( SECTION,
+ "var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr[Math.pow(2,30)-2]",
+ "hi",
+ eval("var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr[Math.pow(2,30)-2]")
+ );
+ array[item++] = new TestCase( SECTION,
+ "var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr.length",
+ (Math.pow(2,30)-1),
+ eval("var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr.length")
+ );
+ return ( array );
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
--- /dev/null
+/* The contents of this file are subject to the Netscape 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/NPL/
+ *
+ * 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 Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ */
+/**
+ File Name: 15.4-2.js
+ ECMA Section: 15.4 Array Objects
+
+ Description: Whenever a property is added whose name is an array
+ index, the length property is changed, if necessary,
+ to be one more than the numeric value of that array
+ index; and whenever the length property is changed,
+ every property whose name is an array index whose value
+ is not smaller than the new length is automatically
+ deleted. This constraint applies only to the Array
+ object itself, and is unaffected by length or array
+ index properties that may be inherited from its
+ prototype.
+
+ Author: christine@netscape.com
+ Date: 28 october 1997
+
+*/
+ var SECTION = "15.4-2";
+ var VERSION = "ECMA_1";
+ startTest();
+ var TITLE = "Array Objects";
+
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = getTestCases();
+ test();
+
+function getTestCases() {
+ var array = new Array();
+ var item = 0;
+
+ array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,16)] = 'hi'; arr.length", Math.pow(2,16)+1, eval("var arr=new Array(); arr[Math.pow(2,16)] = 'hi'; arr.length") );
+
+ array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,30)-2] = 'hi'; arr.length", Math.pow(2,30)-1, eval("var arr=new Array(); arr[Math.pow(2,30)-2] = 'hi'; arr.length") );
+ array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,30)-1] = 'hi'; arr.length", Math.pow(2,30), eval("var arr=new Array(); arr[Math.pow(2,30)-1] = 'hi'; arr.length") );
+ array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,30)] = 'hi'; arr.length", Math.pow(2,30)+1, eval("var arr=new Array(); arr[Math.pow(2,30)] = 'hi'; arr.length") );
+
+ array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,31)-2] = 'hi'; arr.length", Math.pow(2,31)-1, eval("var arr=new Array(); arr[Math.pow(2,31)-2] = 'hi'; arr.length") );
+ array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,31)-1] = 'hi'; arr.length", Math.pow(2,31), eval("var arr=new Array(); arr[Math.pow(2,31)-1] = 'hi'; arr.length") );
+ array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,31)] = 'hi'; arr.length", Math.pow(2,31)+1, eval("var arr=new Array(); arr[Math.pow(2,31)] = 'hi'; arr.length") );
+
+ array[item++] = new TestCase( SECTION, "var arr = new Array(0,1,2,3,4,5); arr.length = 2; String(arr)", "0,1", eval("var arr = new Array(0,1,2,3,4,5); arr.length = 2; String(arr)") );
+ array[item++] = new TestCase( SECTION, "var arr = new Array(0,1); arr.length = 3; String(arr)", "0,1,", eval("var arr = new Array(0,1); arr.length = 3; String(arr)") );
+// array[item++] = new TestCase( SECTION, "var arr = new Array(0,1,2,3,4,5); delete arr[0]; arr.length", 5, eval("var arr = new Array(0,1,2,3,4,5); delete arr[0]; arr.length") );
+// array[item++] = new TestCase( SECTION, "var arr = new Array(0,1,2,3,4,5); delete arr[6]; arr.length", 5, eval("var arr = new Array(0,1,2,3,4,5); delete arr[6]; arr.length") );
+
+ return ( array );
+}
+function test( array ) {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
--- /dev/null
+/* The contents of this file are subject to the Netscape 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/NPL/
+ *
+ * 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 Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ */
+/**
+ File Name: 15.4.1.1.js
+ ECMA Section: 15.4.1 Array( item0, item1,... )
+
+ Description: When Array is called as a function rather than as a
+ constructor, it creates and initializes a new array
+ object. Thus, the function call Array(...) is
+ equivalent to the object creation new Array(...) with
+ the same arguments.
+
+ An array is created and returned as if by the expression
+ new Array( item0, item1, ... ).
+
+ Author: christine@netscape.com
+ Date: 7 october 1997
+*/
+ var SECTION = "15.4.1.1";
+ var VERSION = "ECMA_1";
+ startTest();
+ var TITLE = "Array Constructor Called as a Function";
+
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = getTestCases();
+ test();
+
+function ToUint32( n ) {
+ n = Number( n );
+ if( isNaN(n) || n == 0 || n == Number.POSITIVE_INFINITY ||
+ n == Number.NEGATIVE_INFINITY ) {
+ return 0;
+ }
+ var sign = n < 0 ? -1 : 1;
+
+ return ( sign * ( n * Math.floor( Math.abs(n) ) ) ) % Math.pow(2, 32);
+}
+
+function getTestCases() {
+ var array = new Array();
+ var item = 0;
+
+ array[item++] = new TestCase( SECTION, "typeof Array(1,2)", "object", typeof Array(1,2) );
+ array[item++] = new TestCase( SECTION, "(Array(1,2)).toString", Array.prototype.toString, (Array(1,2)).toString );
+ array[item++] = new TestCase( SECTION,
+ "var arr = Array(1,2,3); arr.toString = Object.prototype.toString; arr.toString()",
+ "[object Array]",
+ eval("var arr = Array(1,2,3); arr.toString = Object.prototype.toString; arr.toString()") );
+
+
+ array[item++] = new TestCase( SECTION, "(Array(1,2)).length", 2, (Array(1,2)).length );
+ array[item++] = new TestCase( SECTION, "var arr = (Array(1,2)); arr[0]", 1, eval("var arr = (Array(1,2)); arr[0]") );
+ array[item++] = new TestCase( SECTION, "var arr = (Array(1,2)); arr[1]", 2, eval("var arr = (Array(1,2)); arr[1]") );
+ array[item++] = new TestCase( SECTION, "var arr = (Array(1,2)); String(arr)", "1,2", eval("var arr = (Array(1,2)); String(arr)") );
+
+ return ( array );
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
--- /dev/null
+/* The contents of this file are subject to the Netscape 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/NPL/
+ *
+ * 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 Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ */
+/**
+ File Name: 15.4.1.2.js
+ ECMA Section: 15.4.1.2 Array(len)
+
+ Description: When Array is called as a function rather than as a
+ constructor, it creates and initializes a new array
+ object. Thus, the function call Array(...) is
+ equivalent to the object creationi new Array(...) with
+ the same arguments.
+
+ An array is created and returned as if by the
+ expression new Array(len).
+
+ Author: christine@netscape.com
+ Date: 7 october 1997
+*/
+ var SECTION = "15.4.1.2";
+ var VERSION = "ECMA_1";
+ startTest();
+ var TITLE = "Array Constructor Called as a Function: Array(len)";
+
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = getTestCases();
+ test();
+
+function getTestCases() {
+ var array = new Array();
+ var item = 0;
+
+ array[item++] = new TestCase( SECTION, "(Array()).length", 0, (Array()).length );
+ array[item++] = new TestCase( SECTION, "(Array(0)).length", 0, (Array(0)).length );
+ array[item++] = new TestCase( SECTION, "(Array(1)).length", 1, (Array(1)).length );
+ array[item++] = new TestCase( SECTION, "(Array(10)).length", 10, (Array(10)).length );
+ array[item++] = new TestCase( SECTION, "(Array('1')).length", 1, (Array('1')).length );
+ array[item++] = new TestCase( SECTION, "(Array(1000)).length", 1000, (Array(1000)).length );
+ array[item++] = new TestCase( SECTION, "(Array('1000')).length", 1, (Array('1000')).length );
+ array[item++] = new TestCase( SECTION, "(Array(4294967295)).length", ToUint32(4294967295), (Array(4294967295)).length );
+ array[item++] = new TestCase( SECTION, "(Array(Math.pow(2,31)-1)).length", ToUint32(Math.pow(2,31)-1), (Array(Math.pow(2,31)-1)).length );
+ array[item++] = new TestCase( SECTION, "(Array(Math.pow(2,31))).length", ToUint32(Math.pow(2,31)), (Array(Math.pow(2,31))).length );
+ array[item++] = new TestCase( SECTION, "(Array(Math.pow(2,31)+1)).length", ToUint32(Math.pow(2,31)+1), (Array(Math.pow(2,31)+1)).length );
+ array[item++] = new TestCase( SECTION, "(Array('8589934592')).length", 1, (Array("8589934592")).length );
+ array[item++] = new TestCase( SECTION, "(Array('4294967296')).length", 1, (Array("4294967296")).length );
+ array[item++] = new TestCase( SECTION, "(Array(1073741823)).length", ToUint32(1073741823), (Array(1073741823)).length );
+ array[item++] = new TestCase( SECTION, "(Array(1073741824)).length", ToUint32(1073741824), (Array(1073741824)).length );
+ array[item++] = new TestCase( SECTION, "(Array('a string')).length", 1, (Array("a string")).length );
+
+ return ( array );
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
+function ToUint32( n ) {
+ n = Number( n );
+ var sign = ( n < 0 ) ? -1 : 1;
+
+ if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) {
+ return 0;
+ }
+ n = sign * Math.floor( Math.abs(n) )
+
+ n = n % Math.pow(2,32);
+
+ if ( n < 0 ){
+ n += Math.pow(2,32);
+ }
+
+ return ( n );
+}
\ No newline at end of file
--- /dev/null
+/* The contents of this file are subject to the Netscape 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/NPL/
+ *
+ * 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 Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ */
+/**
+ File Name: 15.4.1.3.js
+ ECMA Section: 15.4.1.3 Array()
+
+ Description: When Array is called as a function rather than as a
+ constructor, it creates and initializes a new array
+ object. Thus, the function call Array(...) is
+ equivalent to the object creationi new Array(...) with
+ the same arguments.
+
+ An array is created and returned as if by the
+ expression new Array(len).
+
+ Author: christine@netscape.com
+ Date: 7 october 1997
+*/
+ var SECTION = "15.4.1.3";
+ var VERSION = "ECMA_1";
+ startTest();
+ var TITLE = "Array Constructor Called as a Function: Array()";
+
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = getTestCases();
+ test();
+
+
+function getTestCases() {
+ var array = new Array();
+ var item = 0;
+
+ array[item++] = new TestCase( SECTION,
+ "typeof Array()",
+ "object",
+ typeof Array() );
+
+ array[item++] = new TestCase( SECTION,
+ "MYARR = new Array();MYARR.getClass = Object.prototype.toString;MYARR.getClass()",
+ "[object Array]",
+ eval("MYARR = Array();MYARR.getClass = Object.prototype.toString;MYARR.getClass()") );
+
+ array[item++] = new TestCase( SECTION,
+ "(Array()).length",
+ 0, (
+ Array()).length );
+
+ array[item++] = new TestCase( SECTION,
+ "Array().toString()",
+ "",
+ Array().toString() );
+
+
+ return ( array );
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
--- /dev/null
+/* The contents of this file are subject to the Netscape 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/NPL/
+ *
+ * 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 Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ */
+/**
+ File Name: 15.4.1.js
+ ECMA Section: 15.4.1 The Array Constructor Called as a Function
+
+ Description: When Array is called as a function rather than as a
+ constructor, it creates and initializes a new array
+ object. Thus, the function call Array(...) is
+ equivalent to the object creationi new Array(...) with
+ the same arguments.
+
+ Author: christine@netscape.com
+ Date: 7 october 1997
+*/
+
+ var SECTION = "15.4.1";
+ var VERSION = "ECMA_1";
+ startTest();
+ var TITLE = "The Array Constructor Called as a Function";
+
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = getTestCases();
+ test();
+
+function getTestCases() {
+ var array = new Array();
+ var item = 0;
+
+ array[item++] = new TestCase( SECTION,
+ "Array() +''",
+ "",
+ Array() +"" );
+
+ array[item++] = new TestCase( SECTION,
+ "typeof Array()",
+ "object",
+ typeof Array() );
+
+ array[item++] = new TestCase( SECTION,
+ "var arr = Array(); arr.getClass = Object.prototype.toString; arr.getClass()",
+ "[object Array]",
+ eval("var arr = Array(); arr.getClass = Object.prototype.toString; arr.getClass()") );
+
+ array[item++] = new TestCase( SECTION,
+ "var arr = Array(); arr.toString == Array.prototype.toString",
+ true,
+ eval("var arr = Array(); arr.toString == Array.prototype.toString") );
+
+ array[item++] = new TestCase( SECTION,
+ "Array().length",
+ 0,
+ Array().length );
+
+
+ array[item++] = new TestCase( SECTION,
+ "Array(1,2,3) +''",
+ "1,2,3",
+ Array(1,2,3) +"" );
+
+ array[item++] = new TestCase( SECTION,
+ "typeof Array(1,2,3)",
+ "object",
+ typeof Array(1,2,3) );
+
+ array[item++] = new TestCase( SECTION,
+ "var arr = Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()",
+ "[object Array]",
+ eval("var arr = Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()") );
+
+ array[item++] = new TestCase( SECTION,
+ "var arr = Array(1,2,3); arr.toString == Array.prototype.toString",
+ true,
+ eval("var arr = Array(1,2,3); arr.toString == Array.prototype.toString") );
+
+ array[item++] = new TestCase( SECTION,
+ "Array(1,2,3).length",
+ 3,
+ Array(1,2,3).length );
+
+ array[item++] = new TestCase( SECTION,
+ "typeof Array(12345)",
+ "object",
+ typeof Array(12345) );
+
+ array[item++] = new TestCase( SECTION,
+ "var arr = Array(12345); arr.getClass = Object.prototype.toString; arr.getClass()",
+ "[object Array]",
+ eval("var arr = Array(12345); arr.getClass = Object.prototype.toString; arr.getClass()") );
+
+ array[item++] = new TestCase( SECTION,
+ "var arr = Array(1,2,3,4,5); arr.toString == Array.prototype.toString",
+ true,
+ eval("var arr = Array(1,2,3,4,5); arr.toString == Array.prototype.toString") );
+
+ array[item++] = new TestCase( SECTION,
+ "Array(12345).length",
+ 12345,
+ Array(12345).length );
+
+ return ( array );
+}
+function test() {
+ for (tc=0 ; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
--- /dev/null
+/* The contents of this file are subject to the Netscape 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/NPL/
+ *
+ * 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 Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ */
+/**
+ File Name: 15.4.2.1-1.js
+ ECMA Section: 15.4.2.1 new Array( item0, item1, ... )
+ Description: This description only applies of the constructor is
+ given two or more arguments.
+
+ The [[Prototype]] property of the newly constructed
+ object is set to the original Array prototype object,
+ the one that is the initial value of Array.prototype
+ (15.4.3.1).
+
+ The [[Class]] property of the newly constructed object
+ is set to "Array".
+
+ The length property of the newly constructed object is
+ set to the number of arguments.
+
+ The 0 property of the newly constructed object is set
+ to item0... in general, for as many arguments as there
+ are, the k property of the newly constructed object is
+ set to argument k, where the first argument is
+ considered to be argument number 0.
+
+ This file tests the typeof the newly constructed object.
+
+ Author: christine@netscape.com
+ Date: 7 october 1997
+*/
+
+ var SECTION = "15.4.2.1-1";
+ var VERSION = "ECMA_1";
+ startTest();
+ var TITLE = "The Array Constructor: new Array( item0, item1, ...)";
+
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = getTestCases();
+ test();
+
+
+function getTestCases() {
+ var array = new Array();
+ var item = 0;
+
+ array[item++] = new TestCase( SECTION, "typeof new Array(1,2)", "object", typeof new Array(1,2) );
+ array[item++] = new TestCase( SECTION, "(new Array(1,2)).toString", Array.prototype.toString, (new Array(1,2)).toString );
+ array[item++] = new TestCase( SECTION,
+ "var arr = new Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()",
+ "[object Array]",
+ eval("var arr = new Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()") );
+
+ array[item++] = new TestCase( SECTION, "(new Array(1,2)).length", 2, (new Array(1,2)).length );
+ array[item++] = new TestCase( SECTION, "var arr = (new Array(1,2)); arr[0]", 1, eval("var arr = (new Array(1,2)); arr[0]") );
+ array[item++] = new TestCase( SECTION, "var arr = (new Array(1,2)); arr[1]", 2, eval("var arr = (new Array(1,2)); arr[1]") );
+ array[item++] = new TestCase( SECTION, "var arr = (new Array(1,2)); String(arr)", "1,2", eval("var arr = (new Array(1,2)); String(arr)") );
+
+ return ( array );
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
--- /dev/null
+/* The contents of this file are subject to the Netscape 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/NPL/
+ *
+ * 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 Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ */
+/**
+ File Name: 15.4.2.1-2.js
+ ECMA Section: 15.4.2.1 new Array( item0, item1, ... )
+ Description: This description only applies of the constructor is
+ given two or more arguments.
+
+ The [[Prototype]] property of the newly constructed
+ object is set to the original Array prototype object,
+ the one that is the initial value of Array.prototype
+ (15.4.3.1).
+
+ The [[Class]] property of the newly constructed object
+ is set to "Array".
+
+ The length property of the newly constructed object is
+ set to the number of arguments.
+
+ The 0 property of the newly constructed object is set
+ to item0... in general, for as many arguments as there
+ are, the k property of the newly constructed object is
+ set to argument k, where the first argument is
+ considered to be argument number 0.
+
+
+ Author: christine@netscape.com
+ Date: 7 october 1997
+*/
+ var SECTION = "15.4.2.1-2";
+ var VERSION = "ECMA_1";
+ startTest();
+ var TITLE = "The Array Constructor: new Array( item0, item1, ...)";
+
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ testcases = getTestCases();
+
+ test();
+
+function getTestCases() {
+ var array = new Array();
+
+ var TEST_STRING = "new Array(";
+ var ARGUMENTS = ""
+ var TEST_LENGTH = Math.pow(2,10); //Math.pow(2,32);
+
+ for ( var index = 0; index < TEST_LENGTH; index++ ) {
+ ARGUMENTS += index;
+ ARGUMENTS += (index == (TEST_LENGTH-1) ) ? "" : ",";
+ }
+
+ TEST_STRING += ARGUMENTS + ")";
+
+ TEST_ARRAY = eval( TEST_STRING );
+
+ for ( item = 0; item < TEST_LENGTH; item++ ) {
+ array[item] = new TestCase( SECTION, "["+item+"]", item, TEST_ARRAY[item] );
+ }
+
+ array[item++ ] = new TestCase( SECTION, "new Array( ["+TEST_LENGTH+" arguments] ) +''", ARGUMENTS, TEST_ARRAY +"" );
+
+ return ( array );
+}
--- /dev/null
+/* The contents of this file are subject to the Netscape 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/NPL/
+ *
+ * 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 Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ */
+/**
+ File Name: 15.4.2.1-3.js
+ ECMA Section: 15.4.2.1 new Array( item0, item1, ... )
+ Description: This description only applies of the constructor is
+ given two or more arguments.
+
+ The [[Prototype]] property of the newly constructed
+ object is set to the original Array prototype object,
+ the one that is the initial value of Array.prototype
+ (15.4.3.1).
+
+ The [[Class]] property of the newly constructed object
+ is set to "Array".
+
+ The length property of the newly constructed object is
+ set to the number of arguments.
+
+ The 0 property of the newly constructed object is set
+ to item0... in general, for as many arguments as there
+ are, the k property of the newly constructed object is
+ set to argument k, where the first argument is
+ considered to be argument number 0.
+
+ This test stresses the number of arguments presented to
+ the Array constructor. Should support up to Math.pow
+ (2,32) arguments, since that is the maximum length of an
+ ECMAScript array.
+
+ ***Change TEST_LENGTH to Math.pow(2,32) when larger array
+ lengths are supported.
+
+ Author: christine@netscape.com
+ Date: 7 october 1997
+*/
+ var SECTION = "15.4.2.1-3";
+ var VERSION = "ECMA_1";
+ startTest();
+ var TITLE = "The Array Constructor: new Array( item0, item1, ...)";
+
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = getTestCases();
+ test();
+
+function getTestCases() {
+ var array = new Array();
+
+ var TEST_STRING = "new Array(";
+ var ARGUMENTS = ""
+ var TEST_LENGTH = Math.pow(2,10); //Math.pow(2,32);
+
+ for ( var index = 0; index < TEST_LENGTH; index++ ) {
+ ARGUMENTS += index;
+ ARGUMENTS += (index == (TEST_LENGTH-1) ) ? "" : ",";
+ }
+
+ TEST_STRING += ARGUMENTS + ")";
+
+ TEST_ARRAY = eval( TEST_STRING );
+
+ for ( item = 0; item < TEST_LENGTH; item++ ) {
+ array[item] = new TestCase( SECTION, "TEST_ARRAY["+item+"]", item, TEST_ARRAY[item] );
+ }
+
+ array[item++] = new TestCase( SECTION, "new Array( ["+TEST_LENGTH+" arguments] ) +''", ARGUMENTS, TEST_ARRAY +"" );
+ array[item++] = new TestCase( SECTION, "TEST_ARRAY.toString", Array.prototype.toString, TEST_ARRAY.toString );
+ array[item++] = new TestCase( SECTION, "TEST_ARRAY.join", Array.prototype.join, TEST_ARRAY.join );
+ array[item++] = new TestCase( SECTION, "TEST_ARRAY.sort", Array.prototype.sort, TEST_ARRAY.sort );
+ array[item++] = new TestCase( SECTION, "TEST_ARRAY.reverse", Array.prototype.reverse, TEST_ARRAY.reverse );
+ array[item++] = new TestCase( SECTION, "TEST_ARRAY.length", TEST_LENGTH, TEST_ARRAY.length );
+ array[item++] = new TestCase( SECTION,
+ "TEST_ARRAY.toString = Object.prototype.toString; TEST_ARRAY.toString()",
+ "[object Array]",
+ eval("TEST_ARRAY.toString = Object.prototype.toString; TEST_ARRAY.toString()") );
+
+ return ( array );
+}
+
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
--- /dev/null
+/* The contents of this file are subject to the Netscape 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/NPL/
+ *
+ * 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 Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ */
+/**
+ File Name: 15.4.2.2-1.js
+ ECMA Section: 15.4.2.2 new Array(len)
+
+ Description: This description only applies of the constructor is
+ given two or more arguments.
+
+ The [[Prototype]] property of the newly constructed
+ object is set to the original Array prototype object,
+ the one that is the initial value of Array.prototype(0)
+ (15.4.3.1).
+
+ The [[Class]] property of the newly constructed object
+ is set to "Array".
+
+ If the argument len is a number, then the length
+ property of the newly constructed object is set to
+ ToUint32(len).
+
+ If the argument len is not a number, then the length
+ property of the newly constructed object is set to 1
+ and the 0 property of the newly constructed object is
+ set to len.
+
+ This file tests cases where len is a number.
+
+ The cases in this test need to be updated since the
+ ToUint32 description has changed.
+
+ Author: christine@netscape.com
+ Date: 7 october 1997
+*/
+ var SECTION = "15.4.2.2-1";
+ var VERSION = "ECMA_1";
+ startTest();
+ var TITLE = "The Array Constructor: new Array( len )";
+
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = getTestCases();
+ test();
+
+function getTestCases() {
+ var array = new Array();
+ var item = 0;
+
+ array[item++] = new TestCase( SECTION, "new Array(0)", "", (new Array(0)).toString() );
+ array[item++] = new TestCase( SECTION, "typeof new Array(0)", "object", (typeof new Array(0)) );
+ array[item++] = new TestCase( SECTION, "(new Array(0)).length", 0, (new Array(0)).length );
+ array[item++] = new TestCase( SECTION, "(new Array(0)).toString", Array.prototype.toString, (new Array(0)).toString );
+
+ array[item++] = new TestCase( SECTION, "new Array(1)", "", (new Array(1)).toString() );
+ array[item++] = new TestCase( SECTION, "new Array(1).length", 1, (new Array(1)).length );
+ array[item++] = new TestCase( SECTION, "(new Array(1)).toString", Array.prototype.toString, (new Array(1)).toString );
+
+ array[item++] = new TestCase( SECTION, "(new Array(-0)).length", 0, (new Array(-0)).length );
+ array[item++] = new TestCase( SECTION, "(new Array(0)).length", 0, (new Array(0)).length );
+
+ array[item++] = new TestCase( SECTION, "(new Array(10)).length", 10, (new Array(10)).length );
+ array[item++] = new TestCase( SECTION, "(new Array('1')).length", 1, (new Array('1')).length );
+ array[item++] = new TestCase( SECTION, "(new Array(1000)).length", 1000, (new Array(1000)).length );
+ array[item++] = new TestCase( SECTION, "(new Array('1000')).length", 1, (new Array('1000')).length );
+
+ array[item++] = new TestCase( SECTION, "(new Array(4294967295)).length", ToUint32(4294967295), (new Array(4294967295)).length );
+
+ array[item++] = new TestCase( SECTION, "(new Array('8589934592')).length", 1, (new Array("8589934592")).length );
+ array[item++] = new TestCase( SECTION, "(new Array('4294967296')).length", 1, (new Array("4294967296")).length );
+ array[item++] = new TestCase( SECTION, "(new Array(1073741824)).length", ToUint32(1073741824), (new Array(1073741824)).length );
+
+ return ( array );
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed )
+ ? ""
+ : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
+function ToUint32( n ) {
+ n = Number( n );
+ var sign = ( n < 0 ) ? -1 : 1;
+
+ if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) {
+ return 0;
+ }
+ n = sign * Math.floor( Math.abs(n) )
+
+ n = n % Math.pow(2,32);
+
+ if ( n < 0 ){
+ n += Math.pow(2,32);
+ }
+
+ return ( n );
+}
\ No newline at end of file
--- /dev/null
+/* The contents of this file are subject to the Netscape 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/NPL/
+ *
+ * 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 Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ */
+/**
+ File Name: 15.4.2.2-2.js
+ ECMA Section: 15.4.2.2 new Array(len)
+
+ Description: This description only applies of the constructor is
+ given two or more arguments.
+
+ The [[Prototype]] property of the newly constructed
+ object is set to the original Array prototype object,
+ the one that is the initial value of Array.prototype(0)
+ (15.4.3.1).
+
+ The [[Class]] property of the newly constructed object
+ is set to "Array".
+
+ If the argument len is a number, then the length
+ property of the newly constructed object is set to
+ ToUint32(len).
+
+ If the argument len is not a number, then the length
+ property of the newly constructed object is set to 1
+ and the 0 property of the newly constructed object is
+ set to len.
+
+ This file tests length of the newly constructed array
+ when len is not a number.
+
+ Author: christine@netscape.com
+ Date: 7 october 1997
+*/
+ var SECTION = "15.4.2.2-2";
+ var VERSION = "ECMA_1";
+ startTest();
+ var TITLE = "The Array Constructor: new Array( len )";
+
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = getTestCases();
+ test();
+
+function getTestCases() {
+ var array = new Array();
+ var item = 0;
+
+ array[item++] = new TestCase( SECTION, "(new Array(new Number(1073741823))).length", 1, (new Array(new Number(1073741823))).length );
+ array[item++] = new TestCase( SECTION, "(new Array(new Number(0))).length", 1, (new Array(new Number(0))).length );
+ array[item++] = new TestCase( SECTION, "(new Array(new Number(1000))).length", 1, (new Array(new Number(1000))).length );
+ array[item++] = new TestCase( SECTION, "(new Array('mozilla, larryzilla, curlyzilla')).length", 1, (new Array('mozilla, larryzilla, curlyzilla')).length );
+ array[item++] = new TestCase( SECTION, "(new Array(true)).length", 1, (new Array(true)).length );
+ array[item++] = new TestCase( SECTION, "(new Array(false)).length", 1, (new Array(false)).length);
+ array[item++] = new TestCase( SECTION, "(new Array(new Boolean(true)).length", 1, (new Array(new Boolean(true))).length );
+ array[item++] = new TestCase( SECTION, "(new Array(new Boolean(false)).length", 1, (new Array(new Boolean(false))).length );
+ return ( array );
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+
+ testcases[tc].actual );
+ testcases[tc].reason += ( testcases[tc].passed )
+ ? ""
+ : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
--- /dev/null
+/* The contents of this file are subject to the Netscape 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/NPL/
+ *
+ * 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 Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ */
+/**
+ File Name: 15.4.2.3.js
+ ECMA Section: 15.4.2.3 new Array()
+ Description: The [[Prototype]] property of the newly constructed
+ object is set to the origianl Array prototype object,
+ the one that is the initial value of Array.prototype.
+ The [[Class]] property of the new object is set to
+ "Array". The length of the object is set to 0.
+
+ Author: christine@netscape.com
+ Date: 7 october 1997
+*/
+
+ var SECTION = "15.4.2.3";
+ var VERSION = "ECMA_1";
+ startTest();
+ var TITLE = "The Array Constructor: new Array()";
+
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = getTestCases();
+ test();
+
+function getTestCases() {
+ var array = new Array();
+ var item = 0;
+ array[item++] = new TestCase( SECTION, "new Array() +''", "", (new Array()) +"" );
+ array[item++] = new TestCase( SECTION, "typeof new Array()", "object", (typeof new Array()) );
+ array[item++] = new TestCase( SECTION,
+ "var arr = new Array(); arr.getClass = Object.prototype.toString; arr.getClass()",
+ "[object Array]",
+ eval("var arr = new Array(); arr.getClass = Object.prototype.toString; arr.getClass()") );
+
+ array[item++] = new TestCase( SECTION, "(new Array()).length", 0, (new Array()).length );
+ array[item++] = new TestCase( SECTION, "(new Array()).toString == Array.prototype.toString", true, (new Array()).toString == Array.prototype.toString );
+ array[item++] = new TestCase( SECTION, "(new Array()).join == Array.prototype.join", true, (new Array()).join == Array.prototype.join );
+ array[item++] = new TestCase( SECTION, "(new Array()).reverse == Array.prototype.reverse", true, (new Array()).reverse == Array.prototype.reverse );
+ array[item++] = new TestCase( SECTION, "(new Array()).sort == Array.prototype.sort", true, (new Array()).sort == Array.prototype.sort );
+
+ return ( array );
+}
+function test() {
+ for ( tc=0; tc < testcases.length; tc++ ) {
+ testcases[tc].passed = writeTestCaseResult(
+ testcases[tc].expect,
+ testcases[tc].actual,
+ testcases[tc].description +" = "+ testcases[tc].actual );
+
+ testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
+ }
+ stopTest();
+ return ( testcases );
+}
--- /dev/null
+/* The contents of this file are subject to the Netscape 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/NPL/
+ *
+ * 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 Mozilla Communicator client code, released March
+ * 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape Communications
+ * Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ */
+/**
+ File Name: 15.4.3.1-1.js
+ ECMA Section: 15.4.3.1 Array.prototype
+ Description: The initial value of Array.prototype is the built-in
+ Array prototype object (15.4.4).
+
+ Author: christine@netscape.com
+ Date: 7 october 1997
+*/
+
+ var SECTION = "15.4.3.1-1";
+ var VERSION = "ECMA_1";
+ startTest();
+ var TITLE = "Array.prototype";
+
+ writeHeaderToLog( SECTION + " "+ TITLE);
+
+ var testcases = getTestCases();
+ test();
+