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 /JavaScriptCore/tests/mozilla/ecma_3/Function | |
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 'JavaScriptCore/tests/mozilla/ecma_3/Function')
15 files changed, 0 insertions, 2385 deletions
diff --git a/JavaScriptCore/tests/mozilla/ecma_3/Function/15.3.4.3-1.js b/JavaScriptCore/tests/mozilla/ecma_3/Function/15.3.4.3-1.js deleted file mode 100644 index 123b944..0000000 --- a/JavaScriptCore/tests/mozilla/ecma_3/Function/15.3.4.3-1.js +++ /dev/null @@ -1,205 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* Version: NPL 1.1/GPL 2.0/LGPL 2.1 -* -* 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 JavaScript Engine testing utilities. -* -* The Initial Developer of the Original Code is Netscape Communications Corp. -* Portions created by the Initial Developer are Copyright (C) 2002 -* the Initial Developer. All Rights Reserved. -* -* Contributor(s): igor3@apochta.com, pschwartau@netscape.com -* -* Alternatively, the contents of this file may be used under the terms of -* either the GNU General Public License Version 2 or later (the "GPL"), or -* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -* in which case the provisions of the GPL or the LGPL are applicable instead -* of those above. If you wish to allow use of your version of this file only -* under the terms of either the GPL or the LGPL, and not to allow others to -* use your version of this file under the terms of the NPL, indicate your -* decision by deleting the provisions above and replace them with the notice -* and other provisions required by the GPL or the LGPL. If you do not delete -* the provisions above, a recipient may use your version of this file under -* the terms of any one of the NPL, the GPL or the LGPL. -* -* ***** END LICENSE BLOCK ***** -* -* -* Date: 21 May 2002 -* SUMMARY: ECMA conformance of Function.prototype.apply -* -* Function.prototype.apply(thisArg, argArray) -* -* See ECMA-262 Edition 3 Final, Section 15.3.4.3 -*/ -//----------------------------------------------------------------------------- -var UBound = 0; -var bug = 145791; -var summary = 'Testing ECMA conformance of Function.prototype.apply'; -var status = ''; -var statusitems = []; -var actual = ''; -var actualvalues = []; -var expect= ''; -var expectedvalues = []; - - -function F0(a) -{ - return "" + this + arguments.length; -} - -function F1(a) -{ - return "" + this + a; -} - -function F2() -{ - return "" + this; -} - - - -/* - * Function.prototype.apply.length should return 2 - */ -status = inSection(1); -actual = Function.prototype.apply.length; -expect = 2; -addThis(); - - -/* - * When |thisArg| is not provided to the apply() method, the - * called function must be passed the global object as |this| - */ -status = inSection(2); -actual = F0.apply(); -expect = "" + this + 0; -addThis(); - - -/* - * If |argArray| is not provided to the apply() method, the - * called function should be invoked with an empty argument list - */ -status = inSection(3); -actual = F0.apply(""); -expect = "" + "" + 0; -addThis(); - -status = inSection(4); -actual = F0.apply(true); -expect = "" + true + 0; -addThis(); - - -/* - * Function.prototype.apply(x) and - * Function.prototype.apply(x, undefined) should return the same result - */ -status = inSection(5); -actual = F1.apply(0, undefined); -expect = F1.apply(0); -addThis(); - -status = inSection(6); -actual = F1.apply("", undefined); -expect = F1.apply(""); -addThis(); - -status = inSection(7); -actual = F1.apply(null, undefined); -expect = F1.apply(null); -addThis(); - -status = inSection(8); -actual = F1.apply(undefined, undefined); -expect = F1.apply(undefined); -addThis(); - - -/* - * Function.prototype.apply(x) and - * Function.prototype.apply(x, null) should return the same result - */ -status = inSection(9); -actual = F1.apply(0, null); -expect = F1.apply(0); -addThis(); - -status = inSection(10); -actual = F1.apply("", null); -expect = F1.apply(""); -addThis(); - -status = inSection(11); -actual = F1.apply(null, null); -expect = F1.apply(null); -addThis(); - -status = inSection(12); -actual = F1.apply(undefined, null); -expect = F1.apply(undefined); -addThis(); - - -/* - * Function.prototype.apply() and - * Function.prototype.apply(undefined) should return the same result - */ -status = inSection(13); -actual = F2.apply(undefined); -expect = F2.apply(); -addThis(); - - -/* - * Function.prototype.apply() and - * Function.prototype.apply(null) should return the same result - */ -status = inSection(14); -actual = F2.apply(null); -expect = F2.apply(); -addThis(); - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = actual; - expectedvalues[UBound] = expect; - UBound++; -} - - -function test() -{ - enterFunc('test'); - printBugNumber(bug); - printStatus(summary); - - for (var i=0; i<UBound; i++) - { - reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); - } - - exitFunc ('test'); -} diff --git a/JavaScriptCore/tests/mozilla/ecma_3/Function/15.3.4.4-1.js b/JavaScriptCore/tests/mozilla/ecma_3/Function/15.3.4.4-1.js deleted file mode 100644 index e9e2b64..0000000 --- a/JavaScriptCore/tests/mozilla/ecma_3/Function/15.3.4.4-1.js +++ /dev/null @@ -1,180 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* Version: NPL 1.1/GPL 2.0/LGPL 2.1 -* -* 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 JavaScript Engine testing utilities. -* -* The Initial Developer of the Original Code is Netscape Communications Corp. -* Portions created by the Initial Developer are Copyright (C) 2002 -* the Initial Developer. All Rights Reserved. -* -* Contributor(s): igor3@apochta.com, pschwartau@netscape.com -* -* Alternatively, the contents of this file may be used under the terms of -* either the GNU General Public License Version 2 or later (the "GPL"), or -* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -* in which case the provisions of the GPL or the LGPL are applicable instead -* of those above. If you wish to allow use of your version of this file only -* under the terms of either the GPL or the LGPL, and not to allow others to -* use your version of this file under the terms of the NPL, indicate your -* decision by deleting the provisions above and replace them with the notice -* and other provisions required by the GPL or the LGPL. If you do not delete -* the provisions above, a recipient may use your version of this file under -* the terms of any one of the NPL, the GPL or the LGPL. -* -* ***** END LICENSE BLOCK ***** -* -* -* Date: 21 May 2002 -* SUMMARY: ECMA conformance of Function.prototype.call -* -* Function.prototype.call(thisArg [,arg1 [,arg2, ...]]) -* -* See ECMA-262 Edition 3 Final, Section 15.3.4.4 -*/ -//----------------------------------------------------------------------------- -var UBound = 0; -var bug = 145791; -var summary = 'Testing ECMA conformance of Function.prototype.call'; -var status = ''; -var statusitems = []; -var actual = ''; -var actualvalues = []; -var expect= ''; -var expectedvalues = []; - - -function F0(a) -{ - return "" + this + arguments.length; -} - -function F1(a) -{ - return "" + this + a; -} - -function F2() -{ - return "" + this; -} - - - -/* - * Function.prototype.call.length should return 1 - */ -status = inSection(1); -actual = Function.prototype.call.length; -expect = 1; -addThis(); - - -/* - * When |thisArg| is not provided to the call() method, the - * called function must be passed the global object as |this| - */ -status = inSection(2); -actual = F0.call(); -expect = "" + this + 0; -addThis(); - - -/* - * If [,arg1 [,arg2, ...]] are not provided to the call() method, - * the called function should be invoked with an empty argument list - */ -status = inSection(3); -actual = F0.call(""); -expect = "" + "" + 0; -addThis(); - -status = inSection(4); -actual = F0.call(true); -expect = "" + true + 0; -addThis(); - - -/* - * Function.prototype.call(x) and - * Function.prototype.call(x, undefined) should return the same result - */ -status = inSection(5); -actual = F1.call(0, undefined); -expect = F1.call(0); -addThis(); - -status = inSection(6); -actual = F1.call("", undefined); -expect = F1.call(""); -addThis(); - -status = inSection(7); -actual = F1.call(null, undefined); -expect = F1.call(null); -addThis(); - -status = inSection(8); -actual = F1.call(undefined, undefined); -expect = F1.call(undefined); -addThis(); - - -/* - * Function.prototype.call() and - * Function.prototype.call(undefined) should return the same result - */ -status = inSection(9); -actual = F2.call(undefined); -expect = F2.call(); -addThis(); - - -/* - * Function.prototype.call() and - * Function.prototype.call(null) should return the same result - */ -status = inSection(10); -actual = F2.call(null); -expect = F2.call(); -addThis(); - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = actual; - expectedvalues[UBound] = expect; - UBound++; -} - - -function test() -{ - enterFunc('test'); - printBugNumber(bug); - printStatus(summary); - - for (var i=0; i<UBound; i++) - { - reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); - } - - exitFunc ('test'); -} diff --git a/JavaScriptCore/tests/mozilla/ecma_3/Function/arguments-001.js b/JavaScriptCore/tests/mozilla/ecma_3/Function/arguments-001.js deleted file mode 100644 index 98aca18..0000000 --- a/JavaScriptCore/tests/mozilla/ecma_3/Function/arguments-001.js +++ /dev/null @@ -1,148 +0,0 @@ -/* -* 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.org code. -* -* 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): brendan@mozilla.org, pschwartau@netscape.com -* Date: 07 May 2001 -* -* SUMMARY: Testing the arguments object -* -* See http://bugzilla.mozilla.org/show_bug.cgi?id=72884 -*/ -//------------------------------------------------------------------------------------------------- -var UBound = 0; -var bug = 72884; -var summary = 'Testing the arguments object'; -var status = ''; -var statusitems = [ ]; -var actual = ''; -var actualvalues = [ ]; -var expect= ''; -var expectedvalues = [ ]; -var a = ''; - - -status = inSection(1); -function f() -{ - delete arguments.length; - return arguments; -} - -a = f(); -actual = a instanceof Object; -expect = true; -addThis(); - -actual = a instanceof Array; -expect = false; -addThis(); - -actual = a.length; -expect = undefined; -addThis(); - - - -status = inSection(2); -a = f(1,2,3); -actual = a instanceof Object; -expect = true; -addThis(); - -actual = a instanceof Array; -expect = false; -addThis(); - -actual = a.length; -expect = undefined; -addThis(); - -actual = a[0]; -expect = 1; -addThis(); - -actual = a[1]; -expect = 2; -addThis(); - -actual = a[2]; -expect = 3; -addThis(); - - - -status = inSection(3); -/* - * Brendan: - * - * Note that only callee and length can be overridden, so deleting an indexed - * property and asking for it again causes it to be recreated by args_resolve: - * - * function g(){delete arguments[0]; return arguments[0]} - * g(42) // should this print 42? - * - * I'm not positive this violates ECMA, which allows in chapter 16 for extensions - * including properties (does it allow for magically reappearing properties?). The - * delete operator successfully deletes arguments[0] and results in true, but that - * is not distinguishable from the case where arguments[0] was delegated to - * Arguments.prototype[0], which was how the bad old code worked. - * - * I'll ponder this last detail... - * - * UPDATE: Per ECMA-262, delete on an arguments[i] should succeed - * and remove that property from the arguments object, leaving any get - * of it after the delete to evaluate to undefined. - */ -function g() -{ - delete arguments[0]; - return arguments[0]; -} -actual = g(42); -expect = undefined; // not 42... -addThis(); - - - -//------------------------------------------------------------------------------------------------- -test(); -//------------------------------------------------------------------------------------------------- - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = actual; - expectedvalues[UBound] = expect; - UBound++; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber (bug); - printStatus (summary); - - for (var i = 0; i < UBound; i++) - { - reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); - } - - exitFunc ('test'); -} diff --git a/JavaScriptCore/tests/mozilla/ecma_3/Function/call-001.js b/JavaScriptCore/tests/mozilla/ecma_3/Function/call-001.js deleted file mode 100644 index f9bdf62..0000000 --- a/JavaScriptCore/tests/mozilla/ecma_3/Function/call-001.js +++ /dev/null @@ -1,131 +0,0 @@ -/* -* 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 expressed -* or implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is mozilla.org code. -* -* 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): pschwartau@netscape.com -* Date: 2001-07-13 -* -* SUMMARY: Applying Function.prototype.call to the Function object itself -* -* -* ECMA-262 15.3.4.4 Function.prototype.call (thisArg [,arg1 [,arg2,…] ] ) -* -* When applied to the Function object itself, thisArg should be ignored. -* As explained by Waldemar (waldemar@netscape.com): -* -* Function.call(obj, "print(this)") is equivalent to invoking -* Function("print(this)") with this set to obj. Now, Function("print(this)") -* is equivalent to new Function("print(this)") (see 15.3.1.1), and the latter -* ignores the this value that you passed it and constructs a function -* (which we'll call F) which will print the value of the this that will be -* passed in when F will be invoked. -* -* With the last set of () you're invoking F(), which means you're calling it -* with no this value. When you don't provide a this value, it defaults to the -* global object. -* -*/ -//----------------------------------------------------------------------------- -var UBound = 0; -var bug = '(none)'; -var summary = 'Applying Function.prototype.call to the Function object itself'; -var status = ''; -var statusitems = []; -var actual = ''; -var actualvalues = []; -var expect= ''; -var expectedvalues = []; -var self = this; // capture a reference to the global object -var cnOBJECT_GLOBAL = self.toString(); -var cnOBJECT_OBJECT = (new Object).toString(); -var cnHello = 'Hello'; -var cnRed = 'red'; -var objTEST = {color:cnRed}; -var f = new Function(); -var g = new Function(); - - -f = Function.call(self, 'return cnHello'); -g = Function.call(objTEST, 'return cnHello'); - -status = 'Section A of test'; -actual = f(); -expect = cnHello; -captureThis(); - -status = 'Section B of test'; -actual = g(); -expect = cnHello; -captureThis(); - - -f = Function.call(self, 'return this.toString()'); -g = Function.call(objTEST, 'return this.toString()'); - -status = 'Section C of test'; -actual = f(); -expect = cnOBJECT_GLOBAL; -captureThis(); - -status = 'Section D of test'; -actual = g(); -expect = cnOBJECT_GLOBAL; -captureThis(); - - -f = Function.call(self, 'return this.color'); -g = Function.call(objTEST, 'return this.color'); - -status = 'Section E of test'; -actual = f(); -expect = undefined; -captureThis(); - -status = 'Section F of test'; -actual = g(); -expect = undefined; -captureThis(); - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - -function captureThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = actual; - expectedvalues[UBound] = expect; - UBound++; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber (bug); - printStatus (summary); - - for (var i = 0; i < UBound; i++) - { - reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); - } - - exitFunc ('test'); -} diff --git a/JavaScriptCore/tests/mozilla/ecma_3/Function/regress-104584.js b/JavaScriptCore/tests/mozilla/ecma_3/Function/regress-104584.js deleted file mode 100644 index db984a2..0000000 --- a/JavaScriptCore/tests/mozilla/ecma_3/Function/regress-104584.js +++ /dev/null @@ -1,56 +0,0 @@ -/* -* 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.org code. -* -* 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): jband@netscape.com, pschwartau@netscape.com -* Date: 14 October 2001 -* -* SUMMARY: Regression test for Bugzilla bug 104584 -* See http://bugzilla.mozilla.org/show_bug.cgi?id=104584 -* -* Testing that we don't crash on this code. The idea is to -* call F,G WITHOUT providing an argument. This caused a crash -* on the second call to obj.toString() or print(obj) below - -*/ -//----------------------------------------------------------------------------- -var bug = 104584; -var summary = "Testing that we don't crash on this code -"; - -printBugNumber (bug); -printStatus (summary); - -F(); -G(); - -function F(obj) -{ - if(!obj) - obj = {}; - obj.toString(); - gc(); - obj.toString(); -} - - -function G(obj) -{ - if(!obj) - obj = {}; - print(obj); - gc(); - print(obj); -} diff --git a/JavaScriptCore/tests/mozilla/ecma_3/Function/regress-131964.js b/JavaScriptCore/tests/mozilla/ecma_3/Function/regress-131964.js deleted file mode 100644 index d90aa17..0000000 --- a/JavaScriptCore/tests/mozilla/ecma_3/Function/regress-131964.js +++ /dev/null @@ -1,191 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* Version: NPL 1.1/GPL 2.0/LGPL 2.1 -* -* 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 JavaScript Engine testing utilities. -* -* The Initial Developer of the Original Code is Netscape Communications Corp. -* Portions created by the Initial Developer are Copyright (C) 2002 -* the Initial Developer. All Rights Reserved. -* -* Contributor(s): pschwartau@netscape.com -* -* Alternatively, the contents of this file may be used under the terms of -* either the GNU General Public License Version 2 or later (the "GPL"), or -* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -* in which case the provisions of the GPL or the LGPL are applicable instead -* of those above. If you wish to allow use of your version of this file only -* under the terms of either the GPL or the LGPL, and not to allow others to -* use your version of this file under the terms of the NPL, indicate your -* decision by deleting the provisions above and replace them with the notice -* and other provisions required by the GPL or the LGPL. If you do not delete -* the provisions above, a recipient may use your version of this file under -* the terms of any one of the NPL, the GPL or the LGPL. -* -* ***** END LICENSE BLOCK ***** -* -* -* Date: 19 Mar 2002 -* SUMMARY: Function declarations in global or function scope are {DontDelete}. -* Function declarations in eval scope are not {DontDelete}. -* -* See http://bugzilla.mozilla.org/show_bug.cgi?id=131964 -* -*/ -//----------------------------------------------------------------------------- -var UBound = 0; -var bug = 131964; -var summary = 'Functions defined in global or function scope are {DontDelete}'; -var status = ''; -var statusitems = []; -var actual = ''; -var actualvalues = []; -var expect= ''; -var expectedvalues = []; - - -status = inSection(1); -function f() -{ - return 'f lives!'; -} -delete f; - -try -{ - actual = f(); -} -catch(e) -{ - actual = 'f was deleted'; -} - -expect = 'f lives!'; -addThis(); - - - -/* - * Try the same test in function scope - - */ -status = inSection(2); -function g() -{ - function f() - { - return 'f lives!'; - } - delete f; - - try - { - actual = f(); - } - catch(e) - { - actual = 'f was deleted'; - } - - expect = 'f lives!'; - addThis(); -} -g(); - - - -/* - * Try the same test in eval scope - here we EXPECT the function to be deleted (?) - */ -status = inSection(3); -var s = ''; -s += 'function h()'; -s += '{ '; -s += ' return "h lives!";'; -s += '}'; -s += 'delete h;'; - -s += 'try'; -s += '{'; -s += ' actual = h();'; -s += '}'; -s += 'catch(e)'; -s += '{'; -s += ' actual = "h was deleted";'; -s += '}'; - -s += 'expect = "h was deleted";'; -s += 'addThis();'; -eval(s); - - -/* - * Define the function in eval scope, but delete it in global scope - - */ -status = inSection(4); -s = ''; -s += 'function k()'; -s += '{ '; -s += ' return "k lives!";'; -s += '}'; -eval(s); - -delete k; - -try -{ - actual = k(); -} -catch(e) -{ - actual = 'k was deleted'; -} - -expect = 'k was deleted'; -addThis(); - - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -function wasDeleted(functionName) -{ - return functionName + ' was deleted...'; -} - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = actual; - expectedvalues[UBound] = expect; - UBound++; -} - - -function test() -{ - enterFunc('test'); - printBugNumber(bug); - printStatus(summary); - - for (var i=0; i<UBound; i++) - { - reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); - } - - exitFunc ('test'); -} diff --git a/JavaScriptCore/tests/mozilla/ecma_3/Function/regress-137181.js b/JavaScriptCore/tests/mozilla/ecma_3/Function/regress-137181.js deleted file mode 100644 index 1417601..0000000 --- a/JavaScriptCore/tests/mozilla/ecma_3/Function/regress-137181.js +++ /dev/null @@ -1,108 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* Version: NPL 1.1/GPL 2.0/LGPL 2.1 -* -* 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 JavaScript Engine testing utilities. -* -* The Initial Developer of the Original Code is Netscape Communications Corp. -* Portions created by the Initial Developer are Copyright (C) 2002 -* the Initial Developer. All Rights Reserved. -* -* Contributor(s): ibukanov8@yahoo.com, pschwartau@netscape.com -* -* Alternatively, the contents of this file may be used under the terms of -* either the GNU General Public License Version 2 or later (the "GPL"), or -* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -* in which case the provisions of the GPL or the LGPL are applicable instead -* of those above. If you wish to allow use of your version of this file only -* under the terms of either the GPL or the LGPL, and not to allow others to -* use your version of this file under the terms of the NPL, indicate your -* decision by deleting the provisions above and replace them with the notice -* and other provisions required by the GPL or the LGPL. If you do not delete -* the provisions above, a recipient may use your version of this file under -* the terms of any one of the NPL, the GPL or the LGPL. -* -* ***** END LICENSE BLOCK ***** -* -* -* Date: 12 Apr 2002 -* SUMMARY: delete arguments[i] should break connection to local reference -* -* See http://bugzilla.mozilla.org/show_bug.cgi?id=137181 -* -*/ -//----------------------------------------------------------------------------- -var UBound = 0; -var bug = 137181; -var summary = 'delete arguments[i] should break connection to local reference'; -var status = ''; -var statusitems = []; -var actual = ''; -var actualvalues = []; -var expect= ''; -var expectedvalues = []; - - -status = inSection(1); -function f1(x) -{ - x = 1; - delete arguments[0]; - return x; -} -actual = f1(0); // (bug: Rhino was returning |undefined|) -expect = 1; -addThis(); - - -status = inSection(2); -function f2(x) -{ - x = 1; - delete arguments[0]; - arguments[0] = -1; - return x; -} -actual = f2(0); // (bug: Rhino was returning -1) -expect = 1; -addThis(); - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = actual; - expectedvalues[UBound] = expect; - UBound++; -} - - -function test() -{ - enterFunc('test'); - printBugNumber(bug); - printStatus(summary); - - for (var i=0; i<UBound; i++) - { - reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); - } - - exitFunc ('test'); -} diff --git a/JavaScriptCore/tests/mozilla/ecma_3/Function/regress-193555.js b/JavaScriptCore/tests/mozilla/ecma_3/Function/regress-193555.js deleted file mode 100644 index cc3c1eb..0000000 --- a/JavaScriptCore/tests/mozilla/ecma_3/Function/regress-193555.js +++ /dev/null @@ -1,131 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* Version: NPL 1.1/GPL 2.0/LGPL 2.1 -* -* 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 JavaScript Engine testing utilities. -* -* The Initial Developer of the Original Code is Netscape Communications Corp. -* Portions created by the Initial Developer are Copyright (C) 2003 -* the Initial Developer. All Rights Reserved. -* -* Contributor(s): igor@icesoft.no, pschwartau@netscape.com -* -* Alternatively, the contents of this file may be used under the terms of -* either the GNU General Public License Version 2 or later (the "GPL"), or -* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -* in which case the provisions of the GPL or the LGPL are applicable instead -* of those above. If you wish to allow use of your version of this file only -* under the terms of either the GPL or the LGPL, and not to allow others to -* use your version of this file under the terms of the NPL, indicate your -* decision by deleting the provisions above and replace them with the notice -* and other provisions required by the GPL or the LGPL. If you do not delete -* the provisions above, a recipient may use your version of this file under -* the terms of any one of the NPL, the GPL or the LGPL. -* -* ***** END LICENSE BLOCK ***** -* -* -* Date: 17 February 2003 -* SUMMARY: Testing access to function name from inside function -* -* See http://bugzilla.mozilla.org/show_bug.cgi?id=193555 -* -*/ -//----------------------------------------------------------------------------- -var UBound = 0; -var bug = 193555; -var summary = 'Testing access to function name from inside function'; -var status = ''; -var statusitems = []; -var actual = ''; -var actualvalues = []; -var expect= ''; -var expectedvalues = []; - - -// test via function statement -status = inSection(1); -function f() {return f.toString();}; -actual = f(); -expect = f.toString(); -addThis(); - -// test via function expression -status = inSection(2); -var x = function g() {return g.toString();}; -actual = x(); -expect = x.toString(); -addThis(); - -// test via eval() outside function -status = inSection(3); -eval ('function a() {return a.toString();}'); -actual = a(); -expect = a.toString(); -addThis(); - -status = inSection(4); -eval ('var y = function b() {return b.toString();}'); -actual = y(); -expect = y.toString(); -addThis(); - -// test via eval() inside function -status = inSection(5); -function c() {return eval('c').toString();}; -actual = c(); -expect = c.toString(); -addThis(); - -status = inSection(6); -var z = function d() {return eval('d').toString();}; -actual = z(); -expect = z.toString(); -addThis(); - -// test via two evals! -status = inSection(7); -eval('var w = function e() {return eval("e").toString();}'); -actual = w(); -expect = w.toString(); -addThis(); - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = actual; - expectedvalues[UBound] = expect; - UBound++; -} - - -function test() -{ - enterFunc('test'); - printBugNumber(bug); - printStatus(summary); - - for (var i=0; i<UBound; i++) - { - reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); - } - - exitFunc ('test'); -} diff --git a/JavaScriptCore/tests/mozilla/ecma_3/Function/regress-49286.js b/JavaScriptCore/tests/mozilla/ecma_3/Function/regress-49286.js deleted file mode 100644 index 5f7093a..0000000 --- a/JavaScriptCore/tests/mozilla/ecma_3/Function/regress-49286.js +++ /dev/null @@ -1,116 +0,0 @@ -/* -* 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 expressed -* or implied. See the License for the specific language governing -* rights and limitations under the License. -* -* The Original Code is mozilla.org code. -* -* 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. -* -* Contributors: jlaprise@delanotech.com,pschwartau@netscape.com -* Date: 2001-07-10 -* -* SUMMARY: Invoking try...catch through Function.call -* See http://bugzilla.mozilla.org/show_bug.cgi?id=49286 -* -* 1) Define a function with a try...catch block in it -* 2) Invoke the function via the call method of Function -* 3) Pass bad syntax to the try...catch block -* 4) We should catch the error! -*/ -//------------------------------------------------------------------------------------------------- -var UBound = 0; -var bug = 49286; -var summary = 'Invoking try...catch through Function.call'; -var cnErrorCaught = 'Error caught'; -var cnErrorNotCaught = 'Error NOT caught'; -var cnGoodSyntax = '1==2'; -var cnBadSyntax = '1=2'; -var status = ''; -var statusitems = []; -var actual = ''; -var actualvalues = []; -var expect= ''; -var expectedvalues = []; - - -var obj = new testObject(); - -status = 'Section A of test: direct call of f'; -actual = f.call(obj); -expect = cnErrorCaught; -addThis(); - -status = 'Section B of test: indirect call of f'; -actual = g.call(obj); -expect = cnErrorCaught; -addThis(); - - - -//----------------------------------------- -test(); -//----------------------------------------- - - -function test() -{ - enterFunc ('test'); - printBugNumber (bug); - printStatus (summary); - - for (var i=0; i<UBound; i++) - { - reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); - } - - exitFunc ('test'); -} - - -// An object storing bad syntax as a property - -function testObject() -{ - this.badSyntax = cnBadSyntax; - this.goodSyntax = cnGoodSyntax; -} - - -// A function wrapping a try...catch block -function f() -{ - try - { - eval(this.badSyntax); - } - catch(e) - { - return cnErrorCaught; - } - return cnErrorNotCaught; -} - - -// A function wrapping a call to f - -function g() -{ - return f.call(this); -} - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = actual; - expectedvalues[UBound] = expect; - UBound++; -} diff --git a/JavaScriptCore/tests/mozilla/ecma_3/Function/regress-58274.js b/JavaScriptCore/tests/mozilla/ecma_3/Function/regress-58274.js deleted file mode 100644 index 8a5c2e6..0000000 --- a/JavaScriptCore/tests/mozilla/ecma_3/Function/regress-58274.js +++ /dev/null @@ -1,221 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* Version: NPL 1.1/GPL 2.0/LGPL 2.1 -* -* 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 JavaScript Engine testing utilities. -* -* The Initial Developer of the Original Code is Netscape Communications Corp. -* Portions created by the Initial Developer are Copyright (C) 2002 -* the Initial Developer. All Rights Reserved. -* -* Contributor(s): rogerl@netscape.com, pschwartau@netscape.com -* -* Alternatively, the contents of this file may be used under the terms of -* either the GNU General Public License Version 2 or later (the "GPL"), or -* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -* in which case the provisions of the GPL or the LGPL are applicable instead -* of those above. If you wish to allow use of your version of this file only -* under the terms of either the GPL or the LGPL, and not to allow others to -* use your version of this file under the terms of the NPL, indicate your -* decision by deleting the provisions above and replace them with the notice -* and other provisions required by the GPL or the LGPL. If you do not delete -* the provisions above, a recipient may use your version of this file under -* the terms of any one of the NPL, the GPL or the LGPL. -* -* ***** END LICENSE BLOCK ***** -* -* -* Date: 15 July 2002 -* SUMMARY: Testing functions with double-byte names -* See http://bugzilla.mozilla.org/show_bug.cgi?id=58274 -* -* Here is a sample of the problem: -* -* js> function f\u02B1 () {} -* -* js> f\u02B1.toSource(); -* function f¦() {} -* -* js> f\u02B1.toSource().toSource(); -* (new String("function f\xB1() {}")) -* -* -* See how the high-byte information (the 02) has been lost? -* The same thing was happening with the toString() method: -* -* js> f\u02B1.toString(); -* -* function f¦() { -* } -* -* js> f\u02B1.toString().toSource(); -* (new String("\nfunction f\xB1() {\n}\n")) -* -*/ -//----------------------------------------------------------------------------- -var UBound = 0; -var bug = 58274; -var summary = 'Testing functions with double-byte names'; -var ERR = 'UNEXPECTED ERROR! \n'; -var ERR_MALFORMED_NAME = ERR + 'Could not find function name in: \n\n'; -var status = ''; -var statusitems = []; -var actual = ''; -var actualvalues = []; -var expect= ''; -var expectedvalues = []; -var sEval; -var sName; - - -sEval = "function f\u02B2() {return 42;}"; -eval(sEval); -sName = getFunctionName(f\u02B2); - -// Test function call - -status = inSection(1); -actual = f\u02B2(); -expect = 42; -addThis(); - -// Test both characters of function name - -status = inSection(2); -actual = sName[0]; -expect = sEval[9]; -addThis(); - -status = inSection(3); -actual = sName[1]; -expect = sEval[10]; -addThis(); - - - -sEval = "function f\u02B2\u0AAA () {return 84;}"; -eval(sEval); -sName = getFunctionName(f\u02B2\u0AAA); - -// Test function call - -status = inSection(4); -actual = f\u02B2\u0AAA(); -expect = 84; -addThis(); - -// Test all three characters of function name - -status = inSection(5); -actual = sName[0]; -expect = sEval[9]; -addThis(); - -status = inSection(6); -actual = sName[1]; -expect = sEval[10]; -addThis(); - -status = inSection(7); -actual = sName[2]; -expect = sEval[11]; -addThis(); - - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -/* - * Goal: test that f.toString() contains the proper function name. - * - * Note, however, f.toString() is implementation-independent. For example, - * it may begin with '\nfunction' instead of 'function'. Therefore we use - * a regexp to make sure we extract the name properly. - * - * Here we assume that f has been defined by means of a function statement, - * and not a function expression (where it wouldn't have to have a name). - * - * Rhino uses a Unicode representation for f.toString(); whereas - * SpiderMonkey uses an ASCII representation, putting escape sequences - * for non-ASCII characters. For example, if a function is called f\u02B1, - * then in Rhino the toString() method will present a 2-character Unicode - * string for its name, whereas SpiderMonkey will present a 7-character - * ASCII string for its name: the string literal 'f\u02B1'. - * - * So we force the lexer to condense the string before using it. - * This will give uniform results in Rhino and SpiderMonkey. - */ -function getFunctionName(f) -{ - var s = condenseStr(f.toString()); - var re = /\s*function\s+(\S+)\s*\(/; - var arr = s.match(re); - - if (!(arr && arr[1])) - return ERR_MALFORMED_NAME + s; - return arr[1]; -} - - -/* - * This function is the opposite of functions like escape(), which take - * Unicode characters and return escape sequences for them. Here, we force - * the lexer to turn escape sequences back into single characters. - * - * Note we can't simply do |eval(str)|, since in practice |str| will be an - * identifier somewhere in the program (e.g. a function name); thus |eval(str)| - * would return the object that the identifier represents: not what we want. - * - * So we surround |str| lexicographically with quotes to force the lexer to - * evaluate it as a string. Have to strip out any linefeeds first, however - - */ -function condenseStr(str) -{ - /* - * You won't be able to do the next step if |str| has - * any carriage returns or linefeeds in it. For example: - * - * js> eval("'" + '\nHello' + "'"); - * 1: SyntaxError: unterminated string literal: - * 1: ' - * 1: ^ - * - * So replace them with the empty string - - */ - str = str.replace(/[\r\n]/g, '') - return eval("'" + str + "'"); -} - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = actual; - expectedvalues[UBound] = expect; - UBound++; -} - - -function test() -{ - enterFunc('test'); - printBugNumber(bug); - printStatus(summary); - - for (var i=0; i<UBound; i++) - { - reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); - } - - exitFunc ('test'); -} diff --git a/JavaScriptCore/tests/mozilla/ecma_3/Function/regress-85880.js b/JavaScriptCore/tests/mozilla/ecma_3/Function/regress-85880.js deleted file mode 100644 index fea243e..0000000 --- a/JavaScriptCore/tests/mozilla/ecma_3/Function/regress-85880.js +++ /dev/null @@ -1,152 +0,0 @@ -/* -* 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.org code. -* -* 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): pschwartau@netscape.com -* Date: 2001-06-14 -* -* SUMMARY: Regression test for Bugzilla bug 85880 -* -* Rhino interpreted mode was nulling out the arguments object of a -* function if it happened to call another function inside its body. -* -* See http://bugzilla.mozilla.org/show_bug.cgi?id=85880 -* -*/ -//------------------------------------------------------------------------------------------------- -var UBound = 0; -var bug = 85880; -var summary = 'Arguments object of g(){f()} should not be null'; -var cnNonNull = 'Arguments != null'; -var cnNull = 'Arguments == null'; -var cnRecurse = true; -var status = ''; -var statusitems = []; -var actual = ''; -var actualvalues = []; -var expect= ''; -var expectedvalues = []; - - -function f1(x) -{ -} - - -function f2() -{ - return f2.arguments; -} -status = 'Section A of test'; -actual = (f2() == null); -expect = false; -addThis(); - -status = 'Section B of test'; -actual = (f2(0) == null); -expect = false; -addThis(); - - -function f3() -{ - f1(); - return f3.arguments; -} -status = 'Section C of test'; -actual = (f3() == null); -expect = false; -addThis(); - -status = 'Section D of test'; -actual = (f3(0) == null); -expect = false; -addThis(); - - -function f4() -{ - f1(); - f2(); - f3(); - return f4.arguments; -} -status = 'Section E of test'; -actual = (f4() == null); -expect = false; -addThis(); - -status = 'Section F of test'; -actual = (f4(0) == null); -expect = false; -addThis(); - - -function f5() -{ - if (cnRecurse) - { - cnRecurse = false; - f5(); - } - return f5.arguments; -} -status = 'Section G of test'; -actual = (f5() == null); -expect = false; -addThis(); - -status = 'Section H of test'; -actual = (f5(0) == null); -expect = false; -addThis(); - - - -//------------------------------------------------------------------------------------------------- -test(); -//------------------------------------------------------------------------------------------------- - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = isThisNull(actual); - expectedvalues[UBound] = isThisNull(expect); - UBound++; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber (bug); - printStatus (summary); - - for (var i = 0; i < UBound; i++) - { - reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); - } - - exitFunc ('test'); -} - - -function isThisNull(bool) -{ - return bool? cnNull : cnNonNull -} diff --git a/JavaScriptCore/tests/mozilla/ecma_3/Function/regress-94506.js b/JavaScriptCore/tests/mozilla/ecma_3/Function/regress-94506.js deleted file mode 100644 index de4a3a3..0000000 --- a/JavaScriptCore/tests/mozilla/ecma_3/Function/regress-94506.js +++ /dev/null @@ -1,142 +0,0 @@ -/* -* 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.org code. -* -* 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): deneen@alum.bucknell.edu, shaver@mozilla.org -* Date: 08 August 2001 -* -* SUMMARY: When we invoke a function, the arguments object should take -* a back seat to any local identifier named "arguments". -* -* See http://bugzilla.mozilla.org/show_bug.cgi?id=94506 -*/ -//----------------------------------------------------------------------------- -var UBound = 0; -var bug = 94506; -var summary = 'Testing functions employing identifiers named "arguments"'; -var status = ''; -var statusitems = []; -var actual = ''; -var actualvalues = []; -var expect= ''; -var expectedvalues = []; -var TYPE_OBJECT = typeof new Object(); -var arguments = 5555; - - -// use a parameter named "arguments" -function F1(arguments) -{ - return arguments; -} - - -// use a local variable named "arguments" -function F2() -{ - var arguments = 55; - return arguments; -} - - -// same thing in a different order. CHANGES THE RESULT! -function F3() -{ - return arguments; - var arguments = 555; -} - - -// use the global variable above named "arguments" -function F4() -{ - return arguments; -} - - - -/* - * In Sections 1 and 2, expect the local identifier, not the arguments object. - * In Sections 3 and 4, expect the arguments object, not the the identifier. - */ - -status = 'Section 1 of test'; -actual = F1(5); -expect = 5; -addThis(); - - -status = 'Section 2 of test'; -actual = F2(); -expect = 55; -addThis(); - - -status = 'Section 3 of test'; -actual = typeof F3(); -expect = TYPE_OBJECT; -addThis(); - - -status = 'Section 4 of test'; -actual = typeof F4(); -expect = TYPE_OBJECT; -addThis(); - - -// Let's try calling F1 without providing a parameter - -status = 'Section 5 of test'; -actual = F1(); -expect = undefined; -addThis(); - - -// Let's try calling F1 with too many parameters - -status = 'Section 6 of test'; -actual = F1(3,33,333); -expect = 3; -addThis(); - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = actual; - expectedvalues[UBound] = expect; - UBound++; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber (bug); - printStatus (summary); - - for (var i = 0; i < UBound; i++) - { - reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); - } - - exitFunc ('test'); -} diff --git a/JavaScriptCore/tests/mozilla/ecma_3/Function/regress-97921.js b/JavaScriptCore/tests/mozilla/ecma_3/Function/regress-97921.js deleted file mode 100644 index c982673..0000000 --- a/JavaScriptCore/tests/mozilla/ecma_3/Function/regress-97921.js +++ /dev/null @@ -1,131 +0,0 @@ -/* -* 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.org code. -* -* 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): georg@bioshop.de, pschwartau@netscape.com -* Date: 10 September 2001 -* -* SUMMARY: Testing with() statement with nested functions -* See http://bugzilla.mozilla.org/show_bug.cgi?id=97921 -* -* Brendan: "The bug is peculiar to functions that have formal parameters, -* but that are called with fewer actual arguments than the declared number -* of formal parameters." -*/ -//----------------------------------------------------------------------------- -var UBound = 0; -var bug = 97921; -var summary = 'Testing with() statement with nested functions'; -var cnYES = 'Inner value === outer value'; -var cnNO = "Inner value !== outer value!"; -var status = ''; -var statusitems = []; -var actual = ''; -var actualvalues = []; -var expect= ''; -var expectedvalues = []; -var outerValue = ''; -var innerValue = ''; -var useWith = ''; - - -function F(i) -{ - i = 0; - if(useWith) with(1){i;} - i++; - - outerValue = i; // capture value of i in outer function - F1 = function() {innerValue = i;}; // capture value of i in inner function - F1(); -} - - -status = inSection(1); -useWith=false; -F(); // call F without supplying the argument -actual = innerValue === outerValue; -expect = true; -addThis(); - -status = inSection(2); -useWith=true; -F(); // call F without supplying the argument -actual = innerValue === outerValue; -expect = true; -addThis(); - - -function G(i) -{ - i = 0; - with (new Object()) {i=100}; - i++; - - outerValue = i; // capture value of i in outer function - G1 = function() {innerValue = i;}; // capture value of i in inner function - G1(); -} - - -status = inSection(3); -G(); // call G without supplying the argument -actual = innerValue === 101; -expect = true; -addThis(); - -status = inSection(4); -G(); // call G without supplying the argument -actual = innerValue === outerValue; -expect = true; -addThis(); - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = areTheseEqual(actual); - expectedvalues[UBound] = areTheseEqual(expect); - UBound++; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber (bug); - printStatus (summary); - - for (var i = 0; i < UBound; i++) - { - reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); - } - - exitFunc ('test'); -} - - -function areTheseEqual(yes) -{ - return yes? cnYES : cnNO -} diff --git a/JavaScriptCore/tests/mozilla/ecma_3/Function/scope-001.js b/JavaScriptCore/tests/mozilla/ecma_3/Function/scope-001.js deleted file mode 100644 index 9c4e8fa..0000000 --- a/JavaScriptCore/tests/mozilla/ecma_3/Function/scope-001.js +++ /dev/null @@ -1,249 +0,0 @@ -/* -* 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.org code. -* -* 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): pschwartau@netscape.com, rogerl@netscape.com -* Date: 28 May 2001 -* -* SUMMARY: Functions are scoped statically, not dynamically -* -* See ECMA Section 10.1.4 Scope Chain and Identifier Resolution -* (This section defines the scope chain of an execution context) -* -* See ECMA Section 12.10 The with Statement -* -* See ECMA Section 13 Function Definition -* (This section defines the scope chain of a function object as that -* of the running execution context when the function was declared) -*/ -//------------------------------------------------------------------------------------------------- -var UBound = 0; -var bug = '(none)'; -var summary = 'Testing that functions are scoped statically, not dynamically'; -var self = this; // capture a reference to the global object -var status = ''; -var statusitems = [ ]; -var actual = ''; -var actualvalues = [ ]; -var expect= ''; -var expectedvalues = [ ]; - -/* - * In this section the expected value is 1, not 2. - * - * Why? f captures its scope chain from when it's declared, and imposes that chain - * when it's executed. In other words, f's scope chain is from when it was compiled. - * Since f is a top-level function, this is the global object only. Hence 'a' resolves to 1. - */ -status = 'Section A of test'; -var a = 1; -function f() -{ - return a; -} -var obj = {a:2}; -with (obj) -{ - actual = f(); -} -expect = 1; -addThis(); - - -/* - * In this section the expected value is 2, not 1. That is because here - * f's associated scope chain now includes 'obj' before the global object. - */ -status = 'Section B of test'; -var a = 1; -var obj = {a:2}; -with (obj) -{ - function f() - { - return a; - } - actual = f(); -} -// Mozilla result, which contradicts IE and the ECMA spec: expect = 2; -expect = 1; -addThis(); - - -/* - * Like Section B , except that we call f outside the with block. - * By the principles explained above, we still expect 2 - - */ -status = 'Section C of test'; -var a = 1; -var obj = {a:2}; -with (obj) -{ - function f() - { - return a; - } -} -actual = f(); -// Mozilla result, which contradicts IE and the ECMA spec: expect = 2; -expect = 1; -addThis(); - - -/* - * Like Section C, but with one more level of indirection - - */ -status = 'Section D of test'; -var a = 1; -var obj = {a:2, obj:{a:3}}; -with (obj) -{ - with (obj) - { - function f() - { - return a; - } - } -} -actual = f(); -// Mozilla result, which contradicts IE and the ECMA spec: expect = 3; -expect = 1; -addThis(); - - -/* - * Like Section C, but here we actually delete obj before calling f. - * We still expect 2 - - */ -status = 'Section E of test'; -var a = 1; -var obj = {a:2}; -with (obj) -{ - function f() - { - return a; - } -} -delete obj; -actual = f(); -// Mozilla result, which contradicts IE and the ECMA spec: expect = 2; -expect = 1; -addThis(); - - -/* - * Like Section E. Here we redefine obj and call f under with (obj) - - * We still expect 2 - - */ -status = 'Section F of test'; -var a = 1; -var obj = {a:2}; -with (obj) -{ - function f() - { - return a; - } -} -delete obj; -var obj = {a:3}; -with (obj) -{ - actual = f(); -} -// Mozilla result, which contradicts IE and the ECMA spec: expect = 2; // NOT 3 !!! -expect = 1; -addThis(); - - -/* - * Explicitly verify that f exists at global level, even though - * it was defined under the with(obj) block - - */ -status = 'Section G of test'; -var a = 1; -var obj = {a:2}; -with (obj) -{ - function f() - { - return a; - } -} -actual = String([obj.hasOwnProperty('f'), self.hasOwnProperty('f')]); -expect = String([false, true]); -addThis(); - - -/* - * Explicitly verify that f exists at global level, even though - * it was defined under the with(obj) block - - */ -status = 'Section H of test'; -var a = 1; -var obj = {a:2}; -with (obj) -{ - function f() - { - return a; - } -} -actual = String(['f' in obj, 'f' in self]); -expect = String([false, true]); -addThis(); - - - -//------------------------------------------------------------------------------------------------- -test(); -//------------------------------------------------------------------------------------------------- - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = actual; - expectedvalues[UBound] = expect; - UBound++; - resetTestVars(); -} - - -function resetTestVars() -{ - delete a; - delete obj; - delete f; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber (bug); - printStatus (summary); - - for (var i = 0; i < UBound; i++) - { - reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); - } - - exitFunc ('test'); -} diff --git a/JavaScriptCore/tests/mozilla/ecma_3/Function/scope-002.js b/JavaScriptCore/tests/mozilla/ecma_3/Function/scope-002.js deleted file mode 100644 index 8e4626e..0000000 --- a/JavaScriptCore/tests/mozilla/ecma_3/Function/scope-002.js +++ /dev/null @@ -1,224 +0,0 @@ -/* -* 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.org code. -* -* 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): pschwartau@netscape.com, rogerl@netscape.com -* Date: 28 May 2001 -* -* SUMMARY: Functions are scoped statically, not dynamically -* -* See ECMA Section 10.1.4 Scope Chain and Identifier Resolution -* (This section defines the scope chain of an execution context) -* -* See ECMA Section 12.10 The with Statement -* -* See ECMA Section 13 Function Definition -* (This section defines the scope chain of a function object as that -* of the running execution context when the function was declared) -* -* Like scope-001.js, but using assignment var f = function expression -* instead of a function declaration: function f() {} etc. -*/ -//------------------------------------------------------------------------------------------------- -var UBound = 0; -var bug = '(none)'; -var summary = 'Testing that functions are scoped statically, not dynamically'; -var self = this; // capture a reference to the global object -var status = ''; -var statusitems = [ ]; -var actual = ''; -var actualvalues = [ ]; -var expect= ''; -var expectedvalues = [ ]; - - -/* - * In this section the expected value is 1, not 2. - * - * Why? f captures its scope chain from when it's declared, and imposes that chain - * when it's executed. In other words, f's scope chain is from when it was compiled. - * Since f is a top-level function, this is the global object only. Hence 'a' resolves to 1. - */ -status = 'Section A of test'; -var a = 1; -var f = function () {return a;}; -var obj = {a:2}; -with (obj) -{ - actual = f(); -} -expect = 1; -addThis(); - - -/* - * In this section the expected value is 2, not 1. That is because here - * f's associated scope chain now includes 'obj' before the global object. - */ -status = 'Section B of test'; -var a = 1; -var obj = {a:2}; -with (obj) -{ - var f = function () {return a;}; - actual = f(); -} -expect = 2; -addThis(); - - -/* - * Like Section B , except that we call f outside the with block. - * By the principles explained above, we still expect 2 - - */ -status = 'Section C of test'; -var a = 1; -var obj = {a:2}; -with (obj) -{ - var f = function () {return a;}; -} -actual = f(); -expect = 2; -addThis(); - - -/* - * Like Section C, but with one more level of indirection - - */ -status = 'Section D of test'; -var a = 1; -var obj = {a:2, obj:{a:3}}; -with (obj) -{ - with (obj) - { - var f = function () {return a;}; - } -} -actual = f(); -expect = 3; -addThis(); - - -/* - * Like Section C, but here we actually delete obj before calling f. - * We still expect 2 - - */ -status = 'Section E of test'; -var a = 1; -var obj = {a:2}; -with (obj) -{ - var f = function () {return a;}; -} -delete obj; -actual = f(); -expect = 2; -addThis(); - - -/* - * Like Section E. Here we redefine obj and call f under with (obj) - - * We still expect 2 - - */ -status = 'Section F of test'; -var a = 1; -var obj = {a:2}; -with (obj) -{ - var f = function () {return a;}; -} -delete obj; -var obj = {a:3}; -with (obj) -{ - actual = f(); -} -expect = 2; // NOT 3 !!! -addThis(); - - -/* - * Explicitly verify that f exists at global level, even though - * it was defined under the with(obj) block - - */ -status = 'Section G of test'; -var a = 1; -var obj = {a:2}; -with (obj) -{ - var f = function () {return a;}; -} -actual = String([obj.hasOwnProperty('f'), self.hasOwnProperty('f')]); -expect = String([false, true]); -addThis(); - - -/* - * Explicitly verify that f exists at global level, even though - * it was defined under the with(obj) block - - */ -status = 'Section H of test'; -var a = 1; -var obj = {a:2}; -with (obj) -{ - var f = function () {return a;}; -} -actual = String(['f' in obj, 'f' in self]); -expect = String([false, true]); -addThis(); - - - -//------------------------------------------------------------------------------------------------- -test(); -//------------------------------------------------------------------------------------------------- - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = actual; - expectedvalues[UBound] = expect; - UBound++; - resetTestVars(); -} - - -function resetTestVars() -{ - delete a; - delete obj; - delete f; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber (bug); - printStatus (summary); - - for (var i = 0; i < UBound; i++) - { - reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); - } - - exitFunc ('test'); -} |