diff options
author | Steve Block <steveblock@google.com> | 2011-05-06 11:45:16 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2011-05-12 13:44:10 +0100 |
commit | cad810f21b803229eb11403f9209855525a25d57 (patch) | |
tree | 29a6fd0279be608e0fe9ffe9841f722f0f4e4269 /Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts | |
parent | 121b0cf4517156d0ac5111caf9830c51b69bae8f (diff) | |
download | external_webkit-cad810f21b803229eb11403f9209855525a25d57.zip external_webkit-cad810f21b803229eb11403f9209855525a25d57.tar.gz external_webkit-cad810f21b803229eb11403f9209855525a25d57.tar.bz2 |
Merge WebKit at r75315: Initial merge by git.
Change-Id: I570314b346ce101c935ed22a626b48c2af266b84
Diffstat (limited to 'Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts')
24 files changed, 2528 insertions, 0 deletions
diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.3-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.3-1.js new file mode 100644 index 0000000..f827cc7 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.3-1.js @@ -0,0 +1,107 @@ +/* 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: 10.1.3-1.js + ECMA Section: 10.1.3 + Description: + + For each formal parameter, as defined in the FormalParameterList, create + a property of the variable object whose name is the Identifier and whose + attributes are determined by the type of code. The values of the + parameters are supplied by the caller. If the caller supplies fewer + parameter values than there are formal parameters, the extra formal + parameters have value undefined. If two or more formal parameters share + the same name, hence the same property, the corresponding property is + given the value that was supplied for the last parameter with this name. + If the value of this last parameter was not supplied by the caller, + the value of the corresponding property is undefined. + + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=104191 + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "10.1.3-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Variable Instantiation: Formal Parameters"; + var BUGNUMBER="104191"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var myfun1 = new Function( "a", "a", "return a" ); + var myfun2 = new Function( "a", "b", "a", "return a" ); + + function myfun3(a, b, a) { + return a; + } + + // myfun1, myfun2, myfun3 tostring + + + testcases[tc++] = new TestCase( + SECTION, + String(myfun2) +"; myfun2(2,4,8)", + 8, + myfun2(2,4,8) ); + + testcases[tc++] = new TestCase( + SECTION, + "myfun2(2,4)", + void 0, + myfun2(2,4)); + + testcases[tc++] = new TestCase( + SECTION, + String(myfun3) +"; myfun3(2,4,8)", + 8, + myfun3(2,4,8) ); + + testcases[tc++] = new TestCase( + SECTION, + "myfun3(2,4)", + void 0, + myfun3(2,4) ); + + + + + + test(); + +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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.3.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.3.js new file mode 100644 index 0000000..be75451 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.3.js @@ -0,0 +1,160 @@ +/* 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: 10.1.3.js + ECMA Section: 10.1.3.js Variable Instantiation + Description: + Author: christine@netscape.com + Date: 11 september 1997 +*/ + +var SECTION = "10.1.3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Variable instantiation"; +var BUGNUMBER = "20256"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var testcases = getTestCases(); + +test(); + + +function getTestCases() { + var array = new Array(); + var item = 0; + + // overriding a variable or function name with a function should succeed + array[item++] = + new TestCase(SECTION, + "function t() { return \"first\" };" + + "function t() { return \"second\" };t() ", + "second", + eval("function t() { return \"first\" };" + + "function t() { return \"second\" };t()")); + + array[item++] = + new TestCase(SECTION, + "var t; function t(){}; typeof(t)", + "function", + eval("var t; function t(){}; typeof(t)")); + + + // formal parameter tests + array[item++] = + new TestCase(SECTION, + "function t1(a,b) { return b; }; t1( 4 );", + void 0, + eval("function t1(a,b) { return b; }; t1( 4 );") ); + array[item++] = + new TestCase(SECTION, + "function t1(a,b) { return a; }; t1(4);", + 4, + eval("function t1(a,b) { return a; }; t1(4)")); + array[item++] = + new TestCase(SECTION, + "function t1(a,b) { return a; }; t1();", + void 0, + eval("function t1(a,b) { return a; }; t1()")); + array[item++] = + new TestCase(SECTION, + "function t1(a,b) { return a; }; t1(1,2,4);", + 1, + eval("function t1(a,b) { return a; }; t1(1,2,4)")); +/* + array[item++] = + new TestCase(SECTION, "function t1(a,a) { return a; }; t1( 4 );", + void 0, + eval("function t1(a,a) { return a; }; t1( 4 )")); + array[item++] = + new TestCase(SECTION, + "function t1(a,a) { return a; }; t1( 1,2 );", + 2, + eval("function t1(a,a) { return a; }; t1( 1,2 )")); +*/ + // variable declarations + array[item++] = + new TestCase(SECTION, + "function t1(a,b) { return a; }; t1( false, true );", + false, + eval("function t1(a,b) { return a; }; t1( false, true );")); + array[item++] = + new TestCase(SECTION, + "function t1(a,b) { return b; }; t1( false, true );", + true, + eval("function t1(a,b) { return b; }; t1( false, true );")); + array[item++] = + new TestCase(SECTION, + "function t1(a,b) { return a+b; }; t1( 4, 2 );", + 6, + eval("function t1(a,b) { return a+b; }; t1( 4, 2 );")); + array[item++] = + new TestCase(SECTION, + "function t1(a,b) { return a+b; }; t1( 4 );", + Number.NaN, + eval("function t1(a,b) { return a+b; }; t1( 4 );")); + + // overriding a function name with a variable should fail + array[item++] = + new TestCase(SECTION, + "function t() { return 'function' };" + + "var t = 'variable'; typeof(t)", + "string", + eval("function t() { return 'function' };" + + "var t = 'variable'; typeof(t)")); + + // function as a constructor + array[item++] = + new TestCase(SECTION, + "function t1(a,b) { var a = b; return a; } t1(1,3);", + 3, + eval("function t1(a, b){ var a = b; return a;}; t1(1,3)")); + array[item++] = + new TestCase(SECTION, + "function t2(a,b) { this.a = b; } x = new t2(1,3); x.a", + 3, + eval("function t2(a,b) { this.a = b; };" + + "x = new t2(1,3); x.a")); + array[item++] = + new TestCase(SECTION, + "function t2(a,b) { this.a = a; } x = new t2(1,3); x.a", + 1, + eval("function t2(a,b) { this.a = a; };" + + "x = new t2(1,3); x.a")); + array[item++] = + new TestCase(SECTION, + "function t2(a,b) { this.a = b; this.b = a; } " + + "x = new t2(1,3);x.a;", + 3, + eval("function t2(a,b) { this.a = b; this.b = a; };" + + "x = new t2(1,3);x.a;")); + array[item++] = + new TestCase(SECTION, + "function t2(a,b) { this.a = b; this.b = a; }" + + "x = new t2(1,3);x.b;", + 1, + eval("function t2(a,b) { this.a = b; this.b = a; };" + + "x = new t2(1,3);x.b;") ); + + return (array); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-1.js new file mode 100644 index 0000000..6390960 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-1.js @@ -0,0 +1,100 @@ +/* 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: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + + var testcases = getTestCases(); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[tc].description += "( " + INPUT +" )" ; + + with ( MYOBJECT ) { + testcases[tc].actual = eval( INPUT ); + testcases[tc].expect = Math.pow(INPUT,2); + } + + 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 getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "with MyObject, eval should return square of " ); + + return ( array ); +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-10.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-10.js new file mode 100644 index 0000000..6966acf --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-10.js @@ -0,0 +1,94 @@ +/* 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: 10.1.4-10.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-10"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + + var testcases = getTestCases(); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + var VALUE = 12345; + var MYOBJECT = new Number( VALUE ); + + with ( MYOBJECT ) { + testcases[tc].actual = toString(); + testcases[tc].expect = String(VALUE); + } + + 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 getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "MYOBJECT.toString()" ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-2.js new file mode 100644 index 0000000..b42697a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-2.js @@ -0,0 +1,102 @@ +/* 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: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-2"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + + var testcases = getTestCases(); + + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[tc].description += "( "+INPUT +" )" ; + + with ( this ) { + with ( MYOBJECT ) { + testcases[tc].actual = eval( INPUT ); + testcases[tc].expect = Math.pow(INPUT,2); + } + } + + 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 getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "with MyObject, eval should return square of " ); + + return ( array ); +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-3.js new file mode 100644 index 0000000..54980af --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-3.js @@ -0,0 +1,98 @@ +/* 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: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-3"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + + var testcases = getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[tc].description += ( INPUT +"" ); + + with ( MYOBJECT ) { + eval( INPUT ); + } + + 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 getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "with MyObject, eval should be [object Global].eval " ); + + return ( array ); +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-4.js new file mode 100644 index 0000000..88f8241 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-4.js @@ -0,0 +1,101 @@ +/* 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: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + + var testcases = getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[tc].description += ( INPUT +"" ); + + with ( MYOBJECT ) { + eval( INPUT ); + } + + testcases[tc].actual = eval( INPUT ); + testcases[tc].expect = INPUT; + + 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 getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "with MyObject, eval should be [object Global].eval " ); + + return ( array ); +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-5.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-5.js new file mode 100644 index 0000000..f03d120 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-5.js @@ -0,0 +1,101 @@ +/* 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: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + + var testcases = getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[tc].description += ( INPUT +"" ); + + with ( MYOBJECT ) { + eval = null; + } + + testcases[tc].actual = eval( INPUT ); + testcases[tc].expect = INPUT; + + 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 getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "with MyObject, eval should be [object Global].eval " ); + + return ( array ); +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-6.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-6.js new file mode 100644 index 0000000..def668a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-6.js @@ -0,0 +1,83 @@ +/* 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: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + + getTestCases(); + test(); + +function getTestCases() { + testcases[0] = new TestCase( "SECTION", + "with MyObject, eval should be [object Global].eval " ); + + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[0].description += ( INPUT +"" ); + + with ( MYOBJECT ) { + ; + } + testcases[0].actual = eval( INPUT ); + testcases[0].expect = INPUT; + +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-7.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-7.js new file mode 100644 index 0000000..7f900b5 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-7.js @@ -0,0 +1,100 @@ +/* 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: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-7"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + + var testcases = getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[tc].description += ( INPUT +"" ); + + with ( MYOBJECT ) { + delete( eval ); + testcases[tc].actual = eval( INPUT ); + testcases[tc].expect = INPUT; + } + + 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 getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "with MyObject, eval should be [object Global].eval " ); + + return ( array ); +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-8.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-8.js new file mode 100644 index 0000000..288f0ed --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-8.js @@ -0,0 +1,101 @@ +/* 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: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + + var testcases = getTestCases(); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[tc].description += ( INPUT +"" ); + + with ( MYOBJECT ) { + eval = new Function ( "x", "return(Math.pow(Number(x),3))" ); + + testcases[tc].actual = eval( INPUT ); + testcases[tc].expect = Math.pow(INPUT,3); + } + + 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 getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "with MyObject, eval should cube INPUT: " ); + + return ( array ); +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-9.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-9.js new file mode 100644 index 0000000..ec72ecd --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.4-9.js @@ -0,0 +1,98 @@ +/* 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: 10.1.4-9.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.1.4-9"; + var VERSION = "ECMA_2"; + startTest(); + + var testcases = getTestCases(); + + writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + + var MYOBJECT = new MyObject(); + var RESULT = "hello"; + + with ( MYOBJECT ) { + NEW_PROPERTY = RESULT; + } + testcases[tc].actual = NEW_PROPERTY; + testcases[tc].expect = RESULT; + + 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 getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( SECTION, "NEW_PROPERTY = " ); + + return ( array ); +} +function MyObject( n ) { + this.__proto__ = Number.prototype; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.5-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.5-1.js new file mode 100644 index 0000000..0cfb7c3 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.5-1.js @@ -0,0 +1,118 @@ +/* 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: 10.1.5-1.js + ECMA Section: 10.1.5 Global Object + Description: + There is a unique global object which is created before control enters + any execution context. Initially the global object has the following + properties: + + Built-in objects such as Math, String, Date, parseInt, etc. These have + attributes { DontEnum }. + + Additional host defined properties. This may include a property whose + value is the global object itself, for example window in HTML. + + As control enters execution contexts, and as ECMAScript code is executed, + additional properties may be added to the global object and the initial + properties may be changed. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.5.1-1"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Global Ojbect"); + + var testcases = getTestCases(); + + if ( Object == null ) { + testcases[0].reason += " Object == null" ; + } + if ( Function == null ) { + testcases[0].reason += " Function == null"; + } + if ( String == null ) { + testcases[0].reason += " String == null"; + } + if ( Array == null ) { + testcases[0].reason += " Array == null"; + } + if ( Number == null ) { + testcases[0].reason += " Function == null"; + } + if ( Math == null ) { + testcases[0].reason += " Math == null"; + } + if ( Boolean == null ) { + testcases[0].reason += " Boolean == null"; + } + if ( Date == null ) { + testcases[0].reason += " Date == null"; + } +/* + if ( NaN == null ) { + testcases[0].reason += " NaN == null"; + } + if ( Infinity == null ) { + testcases[0].reason += " Infinity == null"; + } +*/ + if ( eval == null ) { + testcases[0].reason += " eval == null"; + } + if ( parseInt == null ) { + testcases[0].reason += " parseInt == null"; + } + + if ( testcases[0].reason != "" ) { + testcases[0].actual = "fail"; + } else { + testcases[0].actual = "pass"; + } + testcases[0].expect = "pass"; + + test(); + +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 ); + + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "Global Code check" ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.5-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.5-2.js new file mode 100644 index 0000000..a09c1ae --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.5-2.js @@ -0,0 +1,101 @@ +/* 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: 10.1.5-2.js + ECMA Section: 10.1.5 Global Object + Description: + There is a unique global object which is created before control enters + any execution context. Initially the global object has the following + properties: + + Built-in objects such as Math, String, Date, parseInt, etc. These have + attributes { DontEnum }. + + Additional host defined properties. This may include a property whose + value is the global object itself, for example window in HTML. + + As control enters execution contexts, and as ECMAScript code is executed, + additional properties may be added to the global object and the initial + properties may be changed. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.5.1-2"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Global Ojbect"); + + var testcases = getTestCases(); + + var EVAL_STRING = 'if ( Object == null ) { testcases[0].reason += " Object == null" ; }' + + 'if ( Function == null ) { testcases[0].reason += " Function == null"; }' + + 'if ( String == null ) { testcases[0].reason += " String == null"; }' + + 'if ( Array == null ) { testcases[0].reason += " Array == null"; }' + + 'if ( Number == null ) { testcases[0].reason += " Function == null";}' + + 'if ( Math == null ) { testcases[0].reason += " Math == null"; }' + + 'if ( Boolean == null ) { testcases[0].reason += " Boolean == null"; }' + + 'if ( Date == null ) { testcases[0].reason += " Date == null"; }' + + 'if ( eval == null ) { testcases[0].reason += " eval == null"; }' + + 'if ( parseInt == null ) { testcases[0].reason += " parseInt == null"; }' ; + + eval( EVAL_STRING ); + +/* + if ( NaN == null ) { + testcases[0].reason += " NaN == null"; + } + if ( Infinity == null ) { + testcases[0].reason += " Infinity == null"; + } +*/ + + if ( testcases[0].reason != "" ) { + testcases[0].actual = "fail"; + } else { + testcases[0].actual = "pass"; + } + testcases[0].expect = "pass"; + + test(); + +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 ); + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "Eval Code check" ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.5-3.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.5-3.js new file mode 100644 index 0000000..7b0f85f --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.5-3.js @@ -0,0 +1,119 @@ +/* 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: 10.1.5-3.js + ECMA Section: 10.1.5 Global Object + Description: + There is a unique global object which is created before control enters + any execution context. Initially the global object has the following + properties: + + Built-in objects such as Math, String, Date, parseInt, etc. These have + attributes { DontEnum }. + + Additional host defined properties. This may include a property whose + value is the global object itself, for example window in HTML. + + As control enters execution contexts, and as ECMAScript code is executed, + additional properties may be added to the global object and the initial + properties may be changed. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.5.1-3"; + var VERSION = "ECMA_1"; + startTest(); + writeHeaderToLog( SECTION + " Global Ojbect"); + + var testcases = getTestCases(); + + test(); + +function test() { + if ( Object == null ) { + testcases[0].reason += " Object == null" ; + } + if ( Function == null ) { + testcases[0].reason += " Function == null"; + } + if ( String == null ) { + testcases[0].reason += " String == null"; + } + if ( Array == null ) { + testcases[0].reason += " Array == null"; + } + if ( Number == null ) { + testcases[0].reason += " Function == null"; + } + if ( Math == null ) { + testcases[0].reason += " Math == null"; + } + if ( Boolean == null ) { + testcases[0].reason += " Boolean == null"; + } + if ( Date == null ) { + testcases[0].reason += " Date == null"; + } +/* + if ( NaN == null ) { + testcases[0].reason += " NaN == null"; + } + if ( Infinity == null ) { + testcases[0].reason += " Infinity == null"; + } +*/ + if ( eval == null ) { + testcases[0].reason += " eval == null"; + } + if ( parseInt == null ) { + testcases[0].reason += " parseInt == null"; + } + + if ( testcases[0].reason != "" ) { + testcases[0].actual = "fail"; + } else { + testcases[0].actual = "pass"; + } + testcases[0].expect = "pass"; + + 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 getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "Function Code check" ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.5-4.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.5-4.js new file mode 100644 index 0000000..2954346 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.5-4.js @@ -0,0 +1,94 @@ +/* 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: 10.1.5-4.js + ECMA Section: 10.1.5 Global Object + Description: + There is a unique global object which is created before control enters + any execution context. Initially the global object has the following + properties: + + Built-in objects such as Math, String, Date, parseInt, etc. These have + attributes { DontEnum }. + + Additional host defined properties. This may include a property whose + value is the global object itself, for example window in HTML. + + As control enters execution contexts, and as ECMAScript code is executed, + additional properties may be added to the global object and the initial + properties may be changed. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "10.5.1-4"; + var VERSION = "ECMA_1"; + startTest(); + + writeHeaderToLog( SECTION + " Global Ojbect"); + + var testcases = getTestCases(); + + var EVAL_STRING = 'if ( Object == null ) { testcases[0].reason += " Object == null" ; }' + + 'if ( Function == null ) { testcases[0].reason += " Function == null"; }' + + 'if ( String == null ) { testcases[0].reason += " String == null"; }' + + 'if ( Array == null ) { testcases[0].reason += " Array == null"; }' + + 'if ( Number == null ) { testcases[0].reason += " Function == null";}' + + 'if ( Math == null ) { testcases[0].reason += " Math == null"; }' + + 'if ( Boolean == null ) { testcases[0].reason += " Boolean == null"; }' + + 'if ( Date == null ) { testcases[0].reason += " Date == null"; }' + + 'if ( eval == null ) { testcases[0].reason += " eval == null"; }' + + 'if ( parseInt == null ) { testcases[0].reason += " parseInt == null"; }' ; + + var NEW_FUNCTION = new Function( EVAL_STRING ); + + if ( testcases[0].reason != "" ) { + testcases[0].actual = "fail"; + } else { + testcases[0].actual = "pass"; + } + testcases[0].expect = "pass"; + + test(); + +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].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +function getTestCases() { + var array = new Array(); + var item = 0; + + array[item++] = new TestCase( "SECTION", "Anonymous Code check" ); + + return ( array ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.6.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.6.js new file mode 100644 index 0000000..8224cb2 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.6.js @@ -0,0 +1,124 @@ +/* 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: 10.1.6 + ECMA Section: Activation Object + Description: + + If the function object being invoked has an arguments property, let x be + the value of that property; the activation object is also given an internal + property [[OldArguments]] whose initial value is x; otherwise, an arguments + property is created for the function object but the activation object is + not given an [[OldArguments]] property. Next, arguments object described + below (the same one stored in the arguments property of the activation + object) is used as the new value of the arguments property of the function + object. This new value is installed even if the arguments property already + exists and has the ReadOnly attribute (as it will for native Function + objects). (These actions are taken to provide compatibility with a form of + program syntax that is now discouraged: to access the arguments object for + function f within the body of f by using the expression f.arguments. + The recommended way to access the arguments object for function f within + the body of f is simply to refer to the variable arguments.) + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "10.1.6"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Activation Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var arguments = "FAILED!"; + + var ARG_STRING = "value of the argument property"; + + testcases[tc++] = new TestCase( SECTION, + "(new TestObject(0,1,2,3,4,5)).length", + 6, + (new TestObject(0,1,2,3,4,5)).length ); + + for ( i = 0; i < 6; i++ ) { + + testcases[tc++] = new TestCase( SECTION, + "(new TestObject(0,1,2,3,4,5))["+i+"]", + i, + (new TestObject(0,1,2,3,4,5))[i]); + } + + + // The current object already has an arguments property. + + testcases[tc++] = new TestCase( SECTION, + "(new AnotherTestObject(1,2,3)).arguments", + ARG_STRING, + (new AnotherTestObject(1,2,3)).arguments ); + + // The function invoked with [[Call]] + + testcases[tc++] = new TestCase( SECTION, + "TestFunction(1,2,3)", + ARG_STRING, + TestFunction() + '' ); + + + test(); + + + +function Prototype() { + this.arguments = ARG_STRING; +} +function TestObject() { + this.__proto__ = new Prototype(); + return arguments; +} +function AnotherTestObject() { + this.__proto__ = new Prototype(); + return this; +} +function TestFunction() { + arguments = ARG_STRING; + return arguments; +} +function AnotherTestFunction() { + this.__proto__ = new Prototype(); + return this; +} + +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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.8-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.8-1.js new file mode 100644 index 0000000..28b403f --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.8-1.js @@ -0,0 +1,132 @@ +/* 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: 10.1.8 + ECMA Section: Arguments Object + Description: + + When control enters an execution context for declared function code, + anonymous code, or implementation-supplied code, an arguments object is + created and initialized as follows: + + The [[Prototype]] of the arguments object is to the original Object + prototype object, the one that is the initial value of Object.prototype + (section 15.2.3.1). + + A property is created with name callee and property attributes {DontEnum}. + The initial value of this property is the function object being executed. + This allows anonymous functions to be recursive. + + A property is created with name length and property attributes {DontEnum}. + The initial value of this property is the number of actual parameter values + supplied by the caller. + + For each non-negative integer, iarg, less than the value of the length + property, a property is created with name ToString(iarg) and property + attributes { DontEnum }. The initial value of this property is the value + of the corresponding actual parameter supplied by the caller. The first + actual parameter value corresponds to iarg = 0, the second to iarg = 1 and + so on. In the case when iarg is less than the number of formal parameters + for the function object, this property shares its value with the + corresponding property of the activation object. This means that changing + this property changes the corresponding property of the activation object + and vice versa. The value sharing mechanism depends on the implementation. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "10.1.8"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Arguments Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var ARG_STRING = "value of the argument property"; + + testcases[tc++] = new TestCase( SECTION, + "GetCallee()", + GetCallee, + GetCallee() ); + + var LIMIT = 100; + + for ( var i = 0, args = "" ; i < LIMIT; i++ ) { + args += String(i) + ( i+1 < LIMIT ? "," : "" ); + + } + + var LENGTH = eval( "GetLength("+ args +")" ); + + testcases[tc++] = new TestCase( SECTION, + "GetLength("+args+")", + 100, + LENGTH ); + + var ARGUMENTS = eval( "GetArguments( " +args+")" ); + + for ( var i = 0; i < 100; i++ ) { + testcases[tc++] = new TestCase( SECTION, + "GetArguments("+args+")["+i+"]", + i, + ARGUMENTS[i] ); + } + + test(); + +function TestFunction() { + var arg_proto = arguments.__proto__; +} +function GetCallee() { + var c = arguments.callee; + return c; +} +function GetArguments() { + var a = arguments; + return a; +} +function GetLength() { + var l = arguments.length; + return l; +} + +function AnotherTestFunction() { + this.__proto__ = new Prototype(); + return this; +} + +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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.8-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.8-2.js new file mode 100644 index 0000000..b4ff578 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.1.8-2.js @@ -0,0 +1,117 @@ +/* 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: 10.1.8-2 + ECMA Section: Arguments Object + Description: + + When control enters an execution context for declared function code, + anonymous code, or implementation-supplied code, an arguments object is + created and initialized as follows: + + The [[Prototype]] of the arguments object is to the original Object + prototype object, the one that is the initial value of Object.prototype + (section 15.2.3.1). + + A property is created with name callee and property attributes {DontEnum}. + The initial value of this property is the function object being executed. + This allows anonymous functions to be recursive. + + A property is created with name length and property attributes {DontEnum}. + The initial value of this property is the number of actual parameter values + supplied by the caller. + + For each non-negative integer, iarg, less than the value of the length + property, a property is created with name ToString(iarg) and property + attributes { DontEnum }. The initial value of this property is the value + of the corresponding actual parameter supplied by the caller. The first + actual parameter value corresponds to iarg = 0, the second to iarg = 1 and + so on. In the case when iarg is less than the number of formal parameters + for the function object, this property shares its value with the + corresponding property of the activation object. This means that changing + this property changes the corresponding property of the activation object + and vice versa. The value sharing mechanism depends on the implementation. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "10.1.8-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Arguments Object"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + +// Tests for anonymous functions + + var GetCallee = new Function( "var c = arguments.callee; return c" ); + var GetArguments = new Function( "var a = arguments; return a" ); + var GetLength = new Function( "var l = arguments.length; return l" ); + + var ARG_STRING = "value of the argument property"; + + testcases[tc++] = new TestCase( SECTION, + "GetCallee()", + GetCallee, + GetCallee() ); + + var LIMIT = 100; + + for ( var i = 0, args = "" ; i < LIMIT; i++ ) { + args += String(i) + ( i+1 < LIMIT ? "," : "" ); + + } + + var LENGTH = eval( "GetLength("+ args +")" ); + + testcases[tc++] = new TestCase( SECTION, + "GetLength("+args+")", + 100, + LENGTH ); + + var ARGUMENTS = eval( "GetArguments( " +args+")" ); + + for ( var i = 0; i < 100; i++ ) { + testcases[tc++] = new TestCase( SECTION, + "GetArguments("+args+")["+i+"]", + i, + ARGUMENTS[i] ); + } + + test(); + +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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.1.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.1.js new file mode 100644 index 0000000..5e5737b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.1.js @@ -0,0 +1,82 @@ +/* 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: 10.2.1.js + ECMA Section: 10.2.1 Global Code + Description: + + The scope chain is created and initialized to contain the global object and + no others. + + Variable instantiation is performed using the global object as the variable + object and using empty property attributes. + + The this value is the global object. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "10.2.1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Global Code"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var THIS = this; + + testcases[tc++] = new TestCase( SECTION, + "this +''", + GLOBAL, + THIS + "" ); + + var GLOBAL_PROPERTIES = new Array(); + var i = 0; + + for ( p in this ) { + GLOBAL_PROPERTIES[i++] = p; + } + + for ( i = 0; i < GLOBAL_PROPERTIES.length; i++ ) { + testcases[tc++] = new TestCase( SECTION, + GLOBAL_PROPERTIES[i] +" == void 0", + false, + eval("GLOBAL_PROPERTIES["+i+"] == void 0")); + } + + test(); + +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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.2-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.2-1.js new file mode 100644 index 0000000..db03ad6 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.2-1.js @@ -0,0 +1,119 @@ +/* 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: 10.2.2-1.js + ECMA Section: 10.2.2 Eval Code + Description: + + When control enters an execution context for eval code, the previous + active execution context, referred to as the calling context, is used to + determine the scope chain, the variable object, and the this value. If + there is no calling context, then initializing the scope chain, variable + instantiation, and determination of the this value are performed just as + for global code. + + The scope chain is initialized to contain the same objects, in the same + order, as the calling context's scope chain. This includes objects added + to the calling context's scope chain by WithStatement. + + Variable instantiation is performed using the calling context's variable + object and using empty property attributes. + + The this value is the same as the this value of the calling context. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "10.2.2-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Eval Code"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var THIS = eval("this"); + + testcases[tc++] = new TestCase( SECTION, + "this +''", + GLOBAL, + THIS + "" ); + + var GLOBAL_PROPERTIES = new Array(); + var i = 0; + + for ( p in THIS ) { + GLOBAL_PROPERTIES[i++] = p; + } + + for ( i = 0; i < GLOBAL_PROPERTIES.length; i++ ) { + testcases[tc++] = new TestCase( SECTION, + GLOBAL_PROPERTIES[i] +" == THIS["+GLOBAL_PROPERTIES[i]+"]", + true, + eval(GLOBAL_PROPERTIES[i]) == eval( "THIS[GLOBAL_PROPERTIES[i]]") ); + } + + // this in eval statements is the same as this value of the calling context + + var RESULT = THIS == this; + + testcases[tc++] = new TestCase( SECTION, + "eval( 'this == THIS' )", + true, + RESULT ); + + var RESULT = THIS +''; + + testcases[tc++] = new TestCase( SECTION, + "eval( 'this + \"\"' )", + GLOBAL, + RESULT ); + + + testcases[tc++] = new TestCase( SECTION, + "eval( 'this == THIS' )", + true, + eval( "this == THIS" ) ); + + testcases[tc++] = new TestCase( SECTION, + "eval( 'this + \"\"' )", + GLOBAL, + eval( "this +''") ); + + + test(); + +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 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.2-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.2-2.js new file mode 100644 index 0000000..c73feff --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.2-2.js @@ -0,0 +1,105 @@ +/* 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: 10.2.2-2.js + ECMA Section: 10.2.2 Eval Code + Description: + + When control enters an execution context for eval code, the previous + active execution context, referred to as the calling context, is used to + determine the scope chain, the variable object, and the this value. If + there is no calling context, then initializing the scope chain, variable + instantiation, and determination of the this value are performed just as + for global code. + + The scope chain is initialized to contain the same objects, in the same + order, as the calling context's scope chain. This includes objects added + to the calling context's scope chain by WithStatement. + + Variable instantiation is performed using the calling context's variable + object and using empty property attributes. + + The this value is the same as the this value of the calling context. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "10.2.2-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Eval Code"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + // Test Objects + + var OBJECT = new MyObject( "hello" ); + var GLOBAL_PROPERTIES = new Array(); + var i = 0; + + for ( p in this ) { + GLOBAL_PROPERTIES[i++] = p; + } + + with ( OBJECT ) { + var THIS = this; + testcases[tc++] = new TestCase( SECTION, "eval( 'this == THIS' )", true, eval("this == THIS") ); + testcases[tc++] = new TestCase( SECTION, "this in a with() block", GLOBAL, this+"" ); + testcases[tc++] = new TestCase( SECTION, "new MyObject('hello').value", "hello", value ); + testcases[tc++] = new TestCase( SECTION, "eval(new MyObject('hello').value)", "hello", eval("value") ); + testcases[tc++] = new TestCase( SECTION, "new MyObject('hello').getClass()", "[object Object]", getClass() ); + testcases[tc++] = new TestCase( SECTION, "eval(new MyObject('hello').getClass())", "[object Object]", eval("getClass()") ); + testcases[tc++] = new TestCase( SECTION, "eval(new MyObject('hello').toString())", "hello", eval("toString()") ); + testcases[tc++] = new TestCase( SECTION, "eval('getClass') == Object.prototype.toString", true, eval("getClass") == Object.prototype.toString ); + + for ( i = 0; i < GLOBAL_PROPERTIES.length; i++ ) { + testcases[tc++] = new TestCase( SECTION, GLOBAL_PROPERTIES[i] + + " == THIS["+GLOBAL_PROPERTIES[i]+"]", true, + eval(GLOBAL_PROPERTIES[i]) == eval( "THIS[GLOBAL_PROPERTIES[i]]") ); + } + + } + + test(); + +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 MyObject( value ) { + this.value = value; + this.getClass = Object.prototype.toString; + this.toString = new Function( "return this.value+''" ); + return this; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.3-1.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.3-1.js new file mode 100644 index 0000000..be1a00f --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.3-1.js @@ -0,0 +1,83 @@ +/* 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: 10.2.3-1.js + ECMA Section: 10.2.3 Function and Anonymous Code + Description: + + The scope chain is initialized to contain the activation object followed + by the global object. Variable instantiation is performed using the + activation by the global object. Variable instantiation is performed using + the activation object as the variable object and using property attributes + { DontDelete }. The caller provides the this value. If the this value + provided by the caller is not an object (including the case where it is + null), then the this value is the global object. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "10.2.3-1"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Eval Code"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var o = new MyObject("hello") + + testcases[tc++] = new TestCase( SECTION, + "var o = new MyObject('hello'); o.THIS == x", + true, + o.THIS == o ); + + var o = MyFunction(); + + testcases[tc++] = new TestCase( SECTION, + "var o = MyFunction(); o == this", + true, + o == this ); + + test(); + +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 MyFunction( value ) { + return this; +} +function MyObject( value ) { + this.THIS = this; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.3-2.js b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.3-2.js new file mode 100644 index 0000000..084d72f --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma/ExecutionContexts/10.2.3-2.js @@ -0,0 +1,89 @@ +/* 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: 10.2.3-2.js + ECMA Section: 10.2.3 Function and Anonymous Code + Description: + + The scope chain is initialized to contain the activation object followed + by the global object. Variable instantiation is performed using the + activation by the global object. Variable instantiation is performed using + the activation object as the variable object and using property attributes + { DontDelete }. The caller provides the this value. If the this value + provided by the caller is not an object (including the case where it is + null), then the this value is the global object. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "10.2.3-2"; + var VERSION = "ECMA_1"; + startTest(); + var TITLE = "Function and Anonymous Code"; + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var o = new MyObject("hello") + + testcases[tc++] = new TestCase( SECTION, + "MyFunction(\"PASSED!\")", + "PASSED!", + MyFunction("PASSED!") ); + + var o = MyFunction(); + + testcases[tc++] = new TestCase( SECTION, + "MyOtherFunction(true);", + false, + MyOtherFunction(true) ); + + test(); + +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 MyFunction( value ) { + var x = value; + delete x; + return x; +} +function MyOtherFunction(value) { + var x = value; + return delete x; +} +function MyObject( value ) { + this.THIS = this; +} |