diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /js/src/tests/ecma/Statements | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/tests/ecma/Statements')
33 files changed, 1746 insertions, 0 deletions
diff --git a/js/src/tests/ecma/Statements/12.10-1.js b/js/src/tests/ecma/Statements/12.10-1.js new file mode 100644 index 000000000..8e4f67c87 --- /dev/null +++ b/js/src/tests/ecma/Statements/12.10-1.js @@ -0,0 +1,117 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.10-1.js + ECMA Section: 12.10 The with statement + Description: + WithStatement : + with ( Expression ) Statement + + The with statement adds a computed object to the front of the scope chain + of the current execution context, then executes a statement with this + augmented scope chain, then restores the scope chain. + + Semantics + + The production WithStatement : with ( Expression ) Statement is evaluated + as follows: + 1. Evaluate Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Add Result(3) to the front of the scope chain. + 5. Evaluate Statement using the augmented scope chain from step 4. + 6. Remove Result(3) from the front of the scope chain. + 7. Return Result(5). + + Discussion + Note that no matter how control leaves the embedded Statement, whether + normally or by some form of abrupt completion, the scope chain is always + restored to its former state. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "12.10-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The with statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +// although the scope chain changes, the this value is immutable for a given +// execution context. + +new TestCase( SECTION, + "with( new Number() ) { this +'' }", + GLOBAL, + eval("with( new Number() ) { this +'' }") ); + +// the object's functions and properties should override those of the +// global object. + +new TestCase( + SECTION, + "var MYOB = new WithObject(true); with (MYOB) { parseInt() }", + true, + eval("var MYOB = new WithObject(true); with (MYOB) { parseInt() }") ); + +new TestCase( + SECTION, + "var MYOB = new WithObject(false); with (MYOB) { NaN }", + false, + eval("var MYOB = new WithObject(false); with (MYOB) { NaN }") ); + +new TestCase( + SECTION, + "var MYOB = new WithObject(NaN); with (MYOB) { Infinity }", + Number.NaN, + eval("var MYOB = new WithObject(NaN); with (MYOB) { Infinity }") ); + +new TestCase( + SECTION, + "var MYOB = new WithObject(false); with (MYOB) { }; Infinity", + Number.POSITIVE_INFINITY, + eval("var MYOB = new WithObject(false); with (MYOB) { }; Infinity") ); + + +new TestCase( + SECTION, + "var MYOB = new WithObject(0); with (MYOB) { delete Infinity; Infinity }", + Number.POSITIVE_INFINITY, + eval("var MYOB = new WithObject(0); with (MYOB) { delete Infinity; Infinity }") ); + +// let us leave the with block via a break. + +new TestCase( + SECTION, + "var MYOB = new WithObject(0); while (true) { with (MYOB) { Infinity; break; } } Infinity", + Number.POSITIVE_INFINITY, + eval("var MYOB = new WithObject(0); while (true) { with (MYOB) { Infinity; break; } } Infinity") ); + + +test(); + +function WithObject( value ) { + this.prop1 = 1; + this.prop2 = new Boolean(true); + this.prop3 = "a string"; + this.value = value; + + // now we will override global functions + + this.parseInt = new Function( "return this.value" ); + this.NaN = value; + this.Infinity = value; + this.unescape = new Function( "return this.value" ); + this.escape = new Function( "return this.value" ); + this.eval = new Function( "return this.value" ); + this.parseFloat = new Function( "return this.value" ); + this.isNaN = new Function( "return this.value" ); + this.isFinite = new Function( "return this.value" ); +} diff --git a/js/src/tests/ecma/Statements/12.10.js b/js/src/tests/ecma/Statements/12.10.js new file mode 100644 index 000000000..906430924 --- /dev/null +++ b/js/src/tests/ecma/Statements/12.10.js @@ -0,0 +1,27 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.10-1.js + ECMA Section: 12.10 The with statement + Description: + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "12.10-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The with statement"; + +writeHeaderToLog( SECTION +" "+ TITLE); + +new TestCase( SECTION, + "var x; with (7) x = valueOf(); typeof x;", + "number", + eval("var x; with(7) x = valueOf(); typeof x;") ); + +test(); diff --git a/js/src/tests/ecma/Statements/12.2-1.js b/js/src/tests/ecma/Statements/12.2-1.js new file mode 100644 index 000000000..a0ece24fa --- /dev/null +++ b/js/src/tests/ecma/Statements/12.2-1.js @@ -0,0 +1,40 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.2-1.js + ECMA Section: The variable statement + Description: + + If the variable statement occurs inside a FunctionDeclaration, the + variables are defined with function-local scope in that function, as + described in section 10.1.3. Otherwise, they are defined with global + scope, that is, they are created as members of the global object, as + described in section 0. Variables are created when the execution scope + is entered. A Block does not define a new execution scope. Only Program and + FunctionDeclaration produce a new scope. Variables are initialized to the + undefined value when created. A variable with an Initializer is assigned + the value of its AssignmentExpression when the VariableStatement is executed, + not when the variable is created. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "12.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The variable statement"; + +writeHeaderToLog( SECTION +" "+ TITLE); + +new TestCase( "SECTION", + "var x = 3; function f() { var a = x; var x = 23; return a; }; f()", + void 0, + eval("var x = 3; function f() { var a = x; var x = 23; return a; }; f()") ); + +test(); + diff --git a/js/src/tests/ecma/Statements/12.5-1.js b/js/src/tests/ecma/Statements/12.5-1.js new file mode 100644 index 000000000..c5bd6b593 --- /dev/null +++ b/js/src/tests/ecma/Statements/12.5-1.js @@ -0,0 +1,68 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.5-1.js + ECMA Section: The if statement + Description: + + The production IfStatement : if ( Expression ) Statement else Statement + is evaluated as follows: + + 1.Evaluate Expression. + 2.Call GetValue(Result(1)). + 3.Call ToBoolean(Result(2)). + 4.If Result(3) is false, go to step 7. + 5.Evaluate the first Statement. + 6.Return Result(5). + 7.Evaluate the second Statement. + 8.Return Result(7). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + +var SECTION = "12.5-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The if statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +new TestCase( SECTION, + "var MYVAR; if ( true ) MYVAR='PASSED'; else MYVAR= 'FAILED';", + "PASSED", + eval("var MYVAR; if ( true ) MYVAR='PASSED'; else MYVAR= 'FAILED';") ); + +new TestCase( SECTION, + "var MYVAR; if ( false ) MYVAR='FAILED'; else MYVAR= 'PASSED';", + "PASSED", + eval("var MYVAR; if ( false ) MYVAR='FAILED'; else MYVAR= 'PASSED';") ); + +new TestCase( SECTION, + "var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; else MYVAR= 'FAILED';", + "PASSED", + eval("var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; else MYVAR= 'FAILED';") ); + +new TestCase( SECTION, + "var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; else MYVAR= 'FAILED';", + "PASSED", + eval("var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; else MYVAR= 'FAILED';") ); + +new TestCase( SECTION, + "var MYVAR; if ( 1 ) MYVAR='PASSED'; else MYVAR= 'FAILED';", + "PASSED", + eval("var MYVAR; if ( 1 ) MYVAR='PASSED'; else MYVAR= 'FAILED';") ); + +new TestCase( SECTION, + "var MYVAR; if ( 0 ) MYVAR='FAILED'; else MYVAR= 'PASSED';", + "PASSED", + eval("var MYVAR; if ( 0 ) MYVAR='FAILED'; else MYVAR= 'PASSED';") ); + +test(); + diff --git a/js/src/tests/ecma/Statements/12.5-2.js b/js/src/tests/ecma/Statements/12.5-2.js new file mode 100644 index 000000000..f7c58b02d --- /dev/null +++ b/js/src/tests/ecma/Statements/12.5-2.js @@ -0,0 +1,65 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.5-2.js + ECMA Section: The if statement + Description: + + The production IfStatement : if ( Expression ) Statement else Statement + is evaluated as follows: + + 1.Evaluate Expression. + 2.Call GetValue(Result(1)). + 3.Call ToBoolean(Result(2)). + 4.If Result(3) is false, go to step 7. + 5.Evaluate the first Statement. + 6.Return Result(5). + 7.Evaluate the second Statement. + 8.Return Result(7). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "12.5-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The if statement" ; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "var MYVAR; if ( true ) MYVAR='PASSED'; MYVAR", + "PASSED", + eval("var MYVAR; if ( true ) MYVAR='PASSED'; MYVAR") ); + +new TestCase( SECTION, + "var MYVAR; if ( false ) MYVAR='FAILED'; MYVAR;", + "PASSED", + eval("var MYVAR=\"PASSED\"; if ( false ) MYVAR='FAILED'; MYVAR;") ); + +new TestCase( SECTION, + "var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; MYVAR", + "PASSED", + eval("var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; MYVAR") ); + +new TestCase( SECTION, + "var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; MYVAR", + "PASSED", + eval("var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; MYVAR") ); + +new TestCase( SECTION, + "var MYVAR; if ( 1 ) MYVAR='PASSED'; MYVAR", + "PASSED", + eval("var MYVAR; if ( 1 ) MYVAR='PASSED'; MYVAR") ); + +new TestCase( SECTION, + "var MYVAR; if ( 0 ) MYVAR='FAILED'; MYVAR;", + "PASSED", + eval("var MYVAR=\"PASSED\"; if ( 0 ) MYVAR='FAILED'; MYVAR;") ); + +test(); diff --git a/js/src/tests/ecma/Statements/12.6.1-1.js b/js/src/tests/ecma/Statements/12.6.1-1.js new file mode 100644 index 000000000..5a575f050 --- /dev/null +++ b/js/src/tests/ecma/Statements/12.6.1-1.js @@ -0,0 +1,40 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.6.1-1.js + ECMA Section: The while statement + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "12.6.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The While statement"; +writeHeaderToLog( SECTION + " "+ TITLE); + + +new TestCase( SECTION, + "var MYVAR = 0; while( MYVAR++ < 100) { if ( MYVAR < 100 ) break; } MYVAR ", + 1, + eval("var MYVAR = 0; while( MYVAR++ < 100) { if ( MYVAR < 100 ) break; } MYVAR ")); + +new TestCase( SECTION, + "var MYVAR = 0; while( MYVAR++ < 100) { if ( MYVAR < 100 ) continue; else break; } MYVAR ", + 100, + eval("var MYVAR = 0; while( MYVAR++ < 100) { if ( MYVAR < 100 ) continue; else break; } MYVAR ")); + +new TestCase( SECTION, + "function MYFUN( arg1 ) { while ( arg1++ < 100 ) { if ( arg1 < 100 ) return arg1; } }; MYFUN(1)", + 2, + eval("function MYFUN( arg1 ) { while ( arg1++ < 100 ) { if ( arg1 < 100 ) return arg1; } }; MYFUN(1)")); + +test(); + diff --git a/js/src/tests/ecma/Statements/12.6.2-1.js b/js/src/tests/ecma/Statements/12.6.2-1.js new file mode 100644 index 000000000..53f623412 --- /dev/null +++ b/js/src/tests/ecma/Statements/12.6.2-1.js @@ -0,0 +1,41 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.6.2-1.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is not present. + 2. second expression is not present + 3. third expression is not present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ + +var SECTION = "12.6.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( "12.6.2-1", "for statement", 99, testprogram() ); + +test(); + + +function testprogram() { + myVar = 0; + + for ( ; ; ) { + if ( ++myVar == 99 ) + break; + } + + return myVar; +} diff --git a/js/src/tests/ecma/Statements/12.6.2-2.js b/js/src/tests/ecma/Statements/12.6.2-2.js new file mode 100644 index 000000000..04a958c93 --- /dev/null +++ b/js/src/tests/ecma/Statements/12.6.2-2.js @@ -0,0 +1,42 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.6.2-2.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is not present. + 2. second expression is not present + 3. third expression is present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ +var SECTION = "12.6.2-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "for statement", 99, testprogram() ); + +test(); + +function testprogram() { + myVar = 0; + + for ( ; ; myVar++ ) { + if ( myVar < 99 ) { + continue; + } else { + break; + } + } + + return myVar; +} diff --git a/js/src/tests/ecma/Statements/12.6.2-3.js b/js/src/tests/ecma/Statements/12.6.2-3.js new file mode 100644 index 000000000..049ba2500 --- /dev/null +++ b/js/src/tests/ecma/Statements/12.6.2-3.js @@ -0,0 +1,38 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.6.2-3.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is not present. + 2. second expression is present + 3. third expression is present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ +var SECTION = "12.6.2-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "for statement", 100, testprogram() ); + +test(); + +function testprogram() { + myVar = 0; + + for ( ; myVar < 100 ; myVar++ ) { + continue; + } + + return myVar; +} diff --git a/js/src/tests/ecma/Statements/12.6.2-4.js b/js/src/tests/ecma/Statements/12.6.2-4.js new file mode 100644 index 000000000..e9a0e7cf3 --- /dev/null +++ b/js/src/tests/ecma/Statements/12.6.2-4.js @@ -0,0 +1,38 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.6.2-4.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is not present. + 2. second expression is present + 3. third expression is present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ + +var SECTION = "12.6.2-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "for statement", 100, testprogram() ); + +test(); + +function testprogram() { + myVar = 0; + + for ( ; myVar < 100 ; myVar++ ) { + } + + return myVar; +} diff --git a/js/src/tests/ecma/Statements/12.6.2-5.js b/js/src/tests/ecma/Statements/12.6.2-5.js new file mode 100644 index 000000000..1386f04bd --- /dev/null +++ b/js/src/tests/ecma/Statements/12.6.2-5.js @@ -0,0 +1,39 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.6.2-5.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is not present. + 2. second expression is present + 3. third expression is present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ +var SECTION = "12.6.2-5"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "for statement", 99, testprogram() ); + +test(); + +function testprogram() { + myVar = 0; + + for ( ; myVar < 100 ; myVar++ ) { + if (myVar == 99) + break; + } + + return myVar; +} diff --git a/js/src/tests/ecma/Statements/12.6.2-6.js b/js/src/tests/ecma/Statements/12.6.2-6.js new file mode 100644 index 000000000..624ccbfba --- /dev/null +++ b/js/src/tests/ecma/Statements/12.6.2-6.js @@ -0,0 +1,41 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.6.2-6.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is present. + 2. second expression is not present + 3. third expression is present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ +var SECTION = "12.6.2-6"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( "12.6.2-6", "for statement", 256, testprogram() ); + +test(); + +function testprogram() { + var myVar; + + for ( myVar=2; ; myVar *= myVar ) { + + if (myVar > 100) + break; + continue; + } + + return myVar; +} diff --git a/js/src/tests/ecma/Statements/12.6.2-7.js b/js/src/tests/ecma/Statements/12.6.2-7.js new file mode 100644 index 000000000..1038723b5 --- /dev/null +++ b/js/src/tests/ecma/Statements/12.6.2-7.js @@ -0,0 +1,39 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.6.2-7.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is present. + 2. second expression is not present + 3. third expression is present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ +var SECTION = "12.6.2-7"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "for statement", 256, testprogram() ); + +test(); + +function testprogram() { + var myVar; + + for ( myVar=2; myVar < 100 ; myVar *= myVar ) { + + continue; + } + + return myVar; +} diff --git a/js/src/tests/ecma/Statements/12.6.2-8.js b/js/src/tests/ecma/Statements/12.6.2-8.js new file mode 100644 index 000000000..d76fb35ab --- /dev/null +++ b/js/src/tests/ecma/Statements/12.6.2-8.js @@ -0,0 +1,37 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.6.2-8.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is present. + 2. second expression is present + 3. third expression is present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ +var SECTION = "12.6.2-8"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "for statement", 256, testprogram() ); + +test(); + +function testprogram() { + var myVar; + + for ( myVar=2; myVar < 256; myVar *= myVar ) { + } + + return myVar; +} diff --git a/js/src/tests/ecma/Statements/12.6.2-9-n.js b/js/src/tests/ecma/Statements/12.6.2-9-n.js new file mode 100644 index 000000000..2b5941111 --- /dev/null +++ b/js/src/tests/ecma/Statements/12.6.2-9-n.js @@ -0,0 +1,42 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.6.2-9-n.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is not present. + 2. second expression is not present + 3. third expression is not present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ + + +var SECTION = "12.6.2-9-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "for (i)"; +EXPECTED = "error"; + +new TestCase( SECTION, + "for (i)", + "error", + eval("for (i) { }") ); + +/* + for (i) { + } + +*/ +test(); + diff --git a/js/src/tests/ecma/Statements/12.6.3-1.js b/js/src/tests/ecma/Statements/12.6.3-1.js new file mode 100644 index 000000000..06294d6d6 --- /dev/null +++ b/js/src/tests/ecma/Statements/12.6.3-1.js @@ -0,0 +1,29 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + +var SECTION = "12.6.3-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "var x; Number.prototype.foo = 34; for ( j in 7 ) x = j; x", + "foo", + eval("var x; Number.prototype.foo = 34; for ( j in 7 ){x = j;} x") ); + +test(); + diff --git a/js/src/tests/ecma/Statements/12.6.3-10.js b/js/src/tests/ecma/Statements/12.6.3-10.js new file mode 100644 index 000000000..8481458cf --- /dev/null +++ b/js/src/tests/ecma/Statements/12.6.3-10.js @@ -0,0 +1,81 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.6.3-10.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "12.6.3-10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// for ( LeftHandSideExpression in Expression ) +// LeftHandSideExpression:NewExpression:MemberExpression + +var count = 0; +function f() { count++; return new Array("h","e","l","l","o"); } + +var result = ""; +for ( p in f() ) { result += f()[p] }; + +new TestCase( SECTION, + "count = 0; result = \"\"; "+ + "function f() { count++; return new Array(\"h\",\"e\",\"l\",\"l\",\"o\"); }"+ + "for ( p in f() ) { result += f()[p] }; count", + 6, + count ); + +new TestCase( SECTION, + "result", + "hello", + result ); + +// LeftHandSideExpression:NewExpression:MemberExpression [ Expression ] +// LeftHandSideExpression:NewExpression:MemberExpression . Identifier +// LeftHandSideExpression:NewExpression:new MemberExpression Arguments +// LeftHandSideExpression:NewExpression:PrimaryExpression:( Expression ) +// LeftHandSideExpression:CallExpression:MemberExpression Arguments +// LeftHandSideExpression:CallExpression Arguments +// LeftHandSideExpression:CallExpression [ Expression ] +// LeftHandSideExpression:CallExpression . Identifier + +test(); + diff --git a/js/src/tests/ecma/Statements/12.6.3-11.js b/js/src/tests/ecma/Statements/12.6.3-11.js new file mode 100644 index 000000000..8e92635a9 --- /dev/null +++ b/js/src/tests/ecma/Statements/12.6.3-11.js @@ -0,0 +1,64 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.6.3-11.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "12.6.3-11"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +// 5. Get the name of the next property of Result(3) that doesn't have the +// DontEnum attribute. If there is no such property, go to step 14. + +var result = ""; + +for ( p in Number ) { result += String(p) }; + +new TestCase( SECTION, + "result = \"\"; for ( p in Number ) { result += String(p) };", + "", + result ); + +test(); + diff --git a/js/src/tests/ecma/Statements/12.6.3-12.js b/js/src/tests/ecma/Statements/12.6.3-12.js new file mode 100644 index 000000000..140355800 --- /dev/null +++ b/js/src/tests/ecma/Statements/12.6.3-12.js @@ -0,0 +1,69 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.6.3-12.js + ECMA Section: 12.6.3 The for...in Statement + Description: + + This is a regression test for http://bugzilla.mozilla.org/show_bug.cgi?id=9802. + + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "12.6.3-12"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "PASSED"; + +for ( aVar in this ) { + if (aVar == "aVar") { + result = "FAILED" + } +}; + +new TestCase( + SECTION, + "var result=''; for ( aVar in this ) { " + + "if (aVar == 'aVar') {return a failure}; result", + "PASSED", + result ); + +test(); + diff --git a/js/src/tests/ecma/Statements/12.6.3-19.js b/js/src/tests/ecma/Statements/12.6.3-19.js new file mode 100644 index 000000000..fce562cbb --- /dev/null +++ b/js/src/tests/ecma/Statements/12.6.3-19.js @@ -0,0 +1,83 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "12.6.3-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// for ( LeftHandSideExpression in Expression ) +// LeftHandSideExpression:NewExpression:MemberExpression + +var count = 0; +function f() { count++; return new Array("h","e","l","l","o"); } + +var result = ""; +for ( p in f() ) { result += f()[p] }; + +new TestCase( SECTION, + "count = 0; result = \"\"; "+ + "function f() { count++; return new Array(\"h\",\"e\",\"l\",\"l\",\"o\"); }"+ + "for ( p in f() ) { result += f()[p] }; count", + 6, + count ); + +new TestCase( SECTION, + "result", + "hello", + result ); + + + +// LeftHandSideExpression:NewExpression:MemberExpression [ Expression ] +// LeftHandSideExpression:NewExpression:MemberExpression . Identifier +// LeftHandSideExpression:NewExpression:new MemberExpression Arguments +// LeftHandSideExpression:NewExpression:PrimaryExpression:( Expression ) +// LeftHandSideExpression:CallExpression:MemberExpression Arguments +// LeftHandSideExpression:CallExpression Arguments +// LeftHandSideExpression:CallExpression [ Expression ] +// LeftHandSideExpression:CallExpression . Identifier + +test(); + diff --git a/js/src/tests/ecma/Statements/12.6.3-2.js b/js/src/tests/ecma/Statements/12.6.3-2.js new file mode 100644 index 000000000..bbd0a1bed --- /dev/null +++ b/js/src/tests/ecma/Statements/12.6.3-2.js @@ -0,0 +1,29 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.6.3-2.js + ECMA Section: 12.6.3 The for...in Statement + Description: Check the Boolean Object + + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + +var SECTION = "12.6.3-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Boolean.prototype.foo = 34; for ( j in Boolean ) Boolean[j]", + 34, + eval("Boolean.prototype.foo = 34; for ( j in Boolean ) Boolean[j] ") ); + +test(); diff --git a/js/src/tests/ecma/Statements/12.6.3-3.js b/js/src/tests/ecma/Statements/12.6.3-3.js new file mode 100644 index 000000000..6adb35c9f --- /dev/null +++ b/js/src/tests/ecma/Statements/12.6.3-3.js @@ -0,0 +1,39 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.6.3-3.js + ECMA Section: for..in loops + Description: + + This verifies the fix to + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=112156 + for..in should take general lvalue for first argument + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "12.6.3-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var o = {}; + +var result = ""; + +for ( o.a in [1,2,3] ) { result += String( [1,2,3][o.a] ); } + +new TestCase( SECTION, + "for ( o.a in [1,2,3] ) { result += String( [1,2,3][o.a] ); } result", + "123", + result ); + +test(); + diff --git a/js/src/tests/ecma/Statements/12.6.3-4.js b/js/src/tests/ecma/Statements/12.6.3-4.js new file mode 100644 index 000000000..e56b6a6cd --- /dev/null +++ b/js/src/tests/ecma/Statements/12.6.3-4.js @@ -0,0 +1,168 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "12.6.3-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; +var BUGNUMBER="http://scopus.mcom.com/bugsplat/show_bug.cgi?id=344855"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// for ( LeftHandSideExpression in Expression ) +// LeftHandSideExpression:NewExpression:MemberExpression + +var o = new MyObject(); +var result = 0; + +for ( MyObject in o ) { + result += o[MyObject]; +} + +new TestCase( SECTION, + "for ( MyObject in o ) { result += o[MyObject] }", + 6, + result ); + +var result = 0; + +for ( value in o ) { + result += o[value]; +} + +new TestCase( SECTION, + "for ( value in o ) { result += o[value]", + 6, + result ); + +var value = "value"; +var result = 0; +for ( value in o ) { + result += o[value]; +} + +new TestCase( SECTION, + "value = \"value\"; for ( value in o ) { result += o[value]", + 6, + result ); + +var value = 0; +var result = 0; +for ( value in o ) { + result += o[value]; +} + +new TestCase( SECTION, + "value = 0; for ( value in o ) { result += o[value]", + 6, + result ); + +// this causes a segv + +var ob = { 0:"hello" }; +var result = 0; +for ( ob[0] in o ) { + result += o[ob[0]]; +} + +new TestCase( SECTION, + "ob = { 0:\"hello\" }; for ( ob[0] in o ) { result += o[ob[0]]", + 6, + result ); + +var result = 0; +for ( ob["0"] in o ) { + result += o[ob["0"]]; +} + +new TestCase( SECTION, + "value = 0; for ( ob[\"0\"] in o ) { result += o[o[\"0\"]]", + 6, + result ); + +var result = 0; +var ob = { value:"hello" }; +for ( ob[value] in o ) { + result += o[ob[value]]; +} + +new TestCase( SECTION, + "ob = { 0:\"hello\" }; for ( ob[value] in o ) { result += o[ob[value]]", + 6, + result ); + +var result = 0; +for ( ob["value"] in o ) { + result += o[ob["value"]]; +} + +new TestCase( SECTION, + "value = 0; for ( ob[\"value\"] in o ) { result += o[ob[\"value\"]]", + 6, + result ); + +var result = 0; +for ( ob.value in o ) { + result += o[ob.value]; +} + +new TestCase( SECTION, + "value = 0; for ( ob.value in o ) { result += o[ob.value]", + 6, + result ); + +// LeftHandSideExpression:NewExpression:MemberExpression [ Expression ] +// LeftHandSideExpression:NewExpression:MemberExpression . Identifier +// LeftHandSideExpression:NewExpression:new MemberExpression Arguments +// LeftHandSideExpression:NewExpression:PrimaryExpression:( Expression ) +// LeftHandSideExpression:CallExpression:MemberExpression Arguments +// LeftHandSideExpression:CallExpression Arguments +// LeftHandSideExpression:CallExpression [ Expression ] +// LeftHandSideExpression:CallExpression . Identifier + +test(); + +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} diff --git a/js/src/tests/ecma/Statements/12.6.3-5-n.js b/js/src/tests/ecma/Statements/12.6.3-5-n.js new file mode 100644 index 000000000..2465b628b --- /dev/null +++ b/js/src/tests/ecma/Statements/12.6.3-5-n.js @@ -0,0 +1,76 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "12.6.3-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// for ( LeftHandSideExpression in Expression ) +// LeftHandSideExpression:NewExpression:MemberExpression + +DESCRIPTION = "more than one member expression"; +EXPECTED = "error"; + +new TestCase( SECTION, + "more than one member expression", + "error", + eval("var o = new MyObject(); var result = 0; for ( var i, p in this) { result += this[p]; }") ); + +/* + var o = new MyObject(); + var result = 0; + + for ( var i, p in this) { + result += this[p]; + } +*/ + +test(); + +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} diff --git a/js/src/tests/ecma/Statements/12.6.3-6-n.js b/js/src/tests/ecma/Statements/12.6.3-6-n.js new file mode 100644 index 000000000..c217f49bc --- /dev/null +++ b/js/src/tests/ecma/Statements/12.6.3-6-n.js @@ -0,0 +1,75 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "12.6.3-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// for ( LeftHandSideExpression in Expression ) +// LeftHandSideExpression:NewExpression:MemberExpression + +DESCRIPTION = "bad left-hand side expression"; +EXPECTED = "error"; + +new TestCase( SECTION, + "bad left-hand side expression", + "error", + eval("var o = new MyObject(); var result = 0; for ( this in o) { result += this[p]; }") ); +/* + var o = new MyObject(); + var result = 0; + + for ( this in o) { + result += this[p]; + } +*/ + +test(); + +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} diff --git a/js/src/tests/ecma/Statements/12.6.3-7-n.js b/js/src/tests/ecma/Statements/12.6.3-7-n.js new file mode 100644 index 000000000..f420ccbab --- /dev/null +++ b/js/src/tests/ecma/Statements/12.6.3-7-n.js @@ -0,0 +1,76 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "12.6.3-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// for ( LeftHandSideExpression in Expression ) +// LeftHandSideExpression:NewExpression:MemberExpression + +DESCRIPTION = "bad left-hand side expression"; +EXPECTED = "error"; + +new TestCase( SECTION, + "bad left-hand side expression", + "error", + eval("var o = new MyObject(); var result = 0; for ( \"a\" in o) { result += this[p]; } ") ); + +/* + var o = new MyObject(); + var result = 0; + + for ( "a" in o) { + result += this[p]; + } +*/ + +test(); + +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} diff --git a/js/src/tests/ecma/Statements/12.6.3-8-n.js b/js/src/tests/ecma/Statements/12.6.3-8-n.js new file mode 100644 index 000000000..c427bbf6d --- /dev/null +++ b/js/src/tests/ecma/Statements/12.6.3-8-n.js @@ -0,0 +1,76 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.6.3-8-n.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "12.6.3-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// for ( LeftHandSideExpression in Expression ) +// LeftHandSideExpression:NewExpression:MemberExpression + +DESCRIPTION = "bad left-hand side expression"; +EXPECTED = "error"; + +new TestCase( SECTION, + "bad left-hand side expression", + "error", + eval("var o = new MyObject(); var result = 0; for ( 1 in o) { result += this[p]; } ") ); + +/* + var o = new MyObject(); + var result = 0; + + for ( 1 in o) { + result += this[p]; + } +*/ + +test(); + +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} diff --git a/js/src/tests/ecma/Statements/12.6.3-9-n.js b/js/src/tests/ecma/Statements/12.6.3-9-n.js new file mode 100644 index 000000000..c356c3d79 --- /dev/null +++ b/js/src/tests/ecma/Statements/12.6.3-9-n.js @@ -0,0 +1,75 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.6.3-9-n.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "12.6.3-9-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// for ( LeftHandSideExpression in Expression ) +// LeftHandSideExpression:NewExpression:MemberExpression + +DESCRIPTION = "object is not defined"; +EXPECTED = "error"; + +new TestCase( SECTION, + "object is not defined", + "error", + eval("var o = new MyObject(); var result = 0; for ( var o in foo) { result += this[o]; } ") ); +/* + var o = new MyObject(); + var result = 0; + + for ( var o in foo) { + result += this[o]; + } +*/ + +test(); + +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} diff --git a/js/src/tests/ecma/Statements/12.7-1-n.js b/js/src/tests/ecma/Statements/12.7-1-n.js new file mode 100644 index 000000000..3a01aceab --- /dev/null +++ b/js/src/tests/ecma/Statements/12.7-1-n.js @@ -0,0 +1,30 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.7-1-n.js + ECMA Section: 12.7 The continue statement + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "12.7.1-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The continue statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "continue"; +EXPECTED = "error"; + +new TestCase( SECTION, + "continue", + "error", + eval("continue") ); + +test(); diff --git a/js/src/tests/ecma/Statements/12.8-1-n.js b/js/src/tests/ecma/Statements/12.8-1-n.js new file mode 100644 index 000000000..ea8a47436 --- /dev/null +++ b/js/src/tests/ecma/Statements/12.8-1-n.js @@ -0,0 +1,33 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.8-1-n.js + ECMA Section: 12.8 The break statement + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "12.8-1-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The break in statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "break"; +EXPECTED = "error"; + +new TestCase( SECTION, + "break", + "error", + eval("break") ); + + +test(); + diff --git a/js/src/tests/ecma/Statements/12.9-1-n.js b/js/src/tests/ecma/Statements/12.9-1-n.js new file mode 100644 index 000000000..d47f21e9d --- /dev/null +++ b/js/src/tests/ecma/Statements/12.9-1-n.js @@ -0,0 +1,29 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 12.9-1-n.js + ECMA Section: 12.9 The return statement + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "12.9-1-n"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " The return statement"); + +DESCRIPTION = "return"; +EXPECTED = "error"; + +new TestCase( SECTION, + "return", + "error", + eval("return") ); + +test(); diff --git a/js/src/tests/ecma/Statements/browser.js b/js/src/tests/ecma/Statements/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/ecma/Statements/browser.js diff --git a/js/src/tests/ecma/Statements/shell.js b/js/src/tests/ecma/Statements/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/ecma/Statements/shell.js |