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/js1_4 | |
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/js1_4')
14 files changed, 1243 insertions, 0 deletions
diff --git a/Source/JavaScriptCore/tests/mozilla/js1_4/Eval/eval-001.js b/Source/JavaScriptCore/tests/mozilla/js1_4/Eval/eval-001.js new file mode 100644 index 0000000..38f9d04 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/js1_4/Eval/eval-001.js @@ -0,0 +1,75 @@ +/* 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: eval-001.js + * Original Description: (SEE REVISED DESCRIPTION FURTHER BELOW) + * + * The global eval function may not be accessed indirectly and then called. + * This feature will continue to work in JavaScript 1.3 but will result in an + * error in JavaScript 1.4. This restriction is also in place for the With and + * Closure constructors. + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=324451 + * + * Author: christine@netscape.com + * Date: 11 August 1998 + * + * + * REVISION: 05 February 2001 + * Author: pschwartau@netscape.com + * + * Indirect eval IS NOT ILLEGAL per ECMA3!!! See + * + * http://bugzilla.mozilla.org/show_bug.cgi?id=38512 + * + * ------- Additional Comments From Brendan Eich 2001-01-30 17:12 ------- + * ECMA-262 Edition 3 doesn't require implementations to throw EvalError, + * see the short, section-less Chapter 16. It does say an implementation that + * doesn't throw EvalError must allow assignment to eval and indirect calls + * of the evalnative method. + * + */ + var SECTION = "eval-001.js"; + var VERSION = "JS1_4"; + var TITLE = "Calling eval indirectly should NOT fail in version 140"; + var BUGNUMBER="38512"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + var MY_EVAL = eval; + var RESULT = ""; + var EXPECT = "abcdefg"; + + MY_EVAL( "RESULT = EXPECT" ); + + testcases[tc++] = new TestCase( + SECTION, + "Call eval indirectly", + EXPECT, + RESULT ); + + test(); + diff --git a/Source/JavaScriptCore/tests/mozilla/js1_4/Eval/eval-002.js b/Source/JavaScriptCore/tests/mozilla/js1_4/Eval/eval-002.js new file mode 100644 index 0000000..159a9bd --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/js1_4/Eval/eval-002.js @@ -0,0 +1,80 @@ +/* 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: eval-002.js + * Description: (SEE REVISED DESCRIPTION FURTHER BELOW) + * + * The global eval function may not be accessed indirectly and then called. + * This feature will continue to work in JavaScript 1.3 but will result in an + * error in JavaScript 1.4. This restriction is also in place for the With and + * Closure constructors. + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=324451 + * + * Author: christine@netscape.com + * Date: 11 August 1998 + * + * + * REVISION: 05 February 2001 + * Author: pschwartau@netscape.com + * + * Indirect eval IS NOT ILLEGAL per ECMA3!!! See + * + * http://bugzilla.mozilla.org/show_bug.cgi?id=38512 + * + * ------- Additional Comments From Brendan Eich 2001-01-30 17:12 ------- + * ECMA-262 Edition 3 doesn't require implementations to throw EvalError, + * see the short, section-less Chapter 16. It does say an implementation that + * doesn't throw EvalError must allow assignment to eval and indirect calls + * of the evalnative method. + * + */ + var SECTION = "eval-002.js"; + var VERSION = "JS1_4"; + var TITLE = "Calling eval indirectly should NOT fail in version 140"; + var BUGNUMBER="38512"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var MY_EVAL = eval; + var RESULT = ""; + var EXPECT = 1 + "testString" + + EvalTest(); + + test(); + + +function EvalTest() +{ + MY_EVAL( "RESULT = EXPECT" ); + + testcases[tc++] = new TestCase( + SECTION, + "Call eval indirectly", + EXPECT, + RESULT ); +} + diff --git a/Source/JavaScriptCore/tests/mozilla/js1_4/Eval/eval-003.js b/Source/JavaScriptCore/tests/mozilla/js1_4/Eval/eval-003.js new file mode 100644 index 0000000..5c9f1ea --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/js1_4/Eval/eval-003.js @@ -0,0 +1,85 @@ +/* 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: eval-003.js + * Description: (SEE REVISED DESCRIPTION FURTHER BELOW) + * + * The global eval function may not be accessed indirectly and then called. + * This feature will continue to work in JavaScript 1.3 but will result in an + * error in JavaScript 1.4. This restriction is also in place for the With and + * Closure constructors. + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=324451 + * + * Author: christine@netscape.com + * Date: 11 August 1998 + * + * + * REVISION: 05 February 2001 + * Author: pschwartau@netscape.com + * + * Indirect eval IS NOT ILLEGAL per ECMA3!!! See + * + * http://bugzilla.mozilla.org/show_bug.cgi?id=38512 + * + * ------- Additional Comments From Brendan Eich 2001-01-30 17:12 ------- + * ECMA-262 Edition 3 doesn't require implementations to throw EvalError, + * see the short, section-less Chapter 16. It does say an implementation that + * doesn't throw EvalError must allow assignment to eval and indirect calls + * of the evalnative method. + * + */ + var SECTION = "eval-003.js"; + var VERSION = "JS1_4"; + var TITLE = "Calling eval indirectly should NOT fail in version 140"; + var BUGNUMBER="38512"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var MY_EVAL = eval; + var RESULT = ""; + var EXPECT= ""; + var h = function f(x,y){var g = function(z){return Math.exp(z);}; return g(x+y);}; + + + new EvalTest(); + + test(); + +function EvalTest() +{ + with( this ) + { + MY_EVAL( "RESULT = h(-1, 1)" ); + EXPECT = 1; //The base e to the power (-1 + 1), i.e. the power 0, equals 1 .... + + testcases[tc++] = new TestCase( + SECTION, + "Call eval indirectly", + EXPECT, + RESULT ); + } +} + diff --git a/Source/JavaScriptCore/tests/mozilla/js1_4/Functions/function-001.js b/Source/JavaScriptCore/tests/mozilla/js1_4/Functions/function-001.js new file mode 100644 index 0000000..c1e6a3d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/js1_4/Functions/function-001.js @@ -0,0 +1,106 @@ +/* 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: function-001.js + * Description: + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=324455 + * + * Earlier versions of JavaScript supported access to the arguments property + * of the function object. This property held the arguments to the function. + * function f() { + * return f.arguments[0]; // deprecated + * } + * var x = f(3); // x will be 3 + * + * This feature is not a part of the final ECMA standard. Instead, scripts + * should simply use just "arguments": + * + * function f() { + * return arguments[0]; // okay + * } + * + * var x = f(3); // x will be 3 + * + * Again, this feature was motivated by performance concerns. Access to the + * arguments property is not threadsafe, which is of particular concern in + * server environments. Also, the compiler can generate better code for + * functions because it can tell when the arguments are being accessed only by + * name and avoid setting up the arguments object. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "function-001.js"; + var VERSION = "JS1_4"; + var TITLE = "Accessing the arguments property of a function object"; + var BUGNUMBER="324455"; + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( + SECTION, + "return function.arguments", + "P", + TestFunction_2("P", "A","S","S")[0] +""); + + + testcases[tc++] = new TestCase( + SECTION, + "return arguments", + "P", + TestFunction_1( "P", "A", "S", "S" )[0] +""); + + testcases[tc++] = new TestCase( + SECTION, + "return arguments when function contains an arguments property", + "PASS", + TestFunction_3( "P", "A", "S", "S" ) +""); + + testcases[tc++] = new TestCase( + SECTION, + "return function.arguments when function contains an arguments property", + "PASS", + TestFunction_4( "F", "A", "I", "L" ) +""); + + test(); + + function TestFunction_1( a, b, c, d, e ) { + return arguments; + } + + function TestFunction_2( a, b, c, d, e ) { + return TestFunction_2.arguments; + } + + function TestFunction_3( a, b, c, d, e ) { + var arguments = "PASS"; + return arguments; + } + + function TestFunction_4( a, b, c, d, e ) { + var arguments = "PASS"; + return TestFunction_4.arguments; + } + diff --git a/Source/JavaScriptCore/tests/mozilla/js1_4/Regress/date-001-n.js b/Source/JavaScriptCore/tests/mozilla/js1_4/Regress/date-001-n.js new file mode 100644 index 0000000..d6f9f59 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/js1_4/Regress/date-001-n.js @@ -0,0 +1,55 @@ +/* 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: date-001-n.js + * Description: + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=299903 + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "date-001-n.js"; + var VERSION = "JS1_4"; + var TITLE = "Regression test case for 299903"; + var BUGNUMBER="299903"; + + startTest(); + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + function MyDate() { + this.foo = "bar"; + } + MyDate.prototype = new Date(); + + testcases[tc++] = new TestCase( + SECTION, + "function MyDate() { this.foo = \"bar\"; }; "+ + "MyDate.prototype = new Date(); " + + "new MyDate().toString()", + "error", + new MyDate().toString() ); + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/js1_4/Regress/function-001.js b/Source/JavaScriptCore/tests/mozilla/js1_4/Regress/function-001.js new file mode 100644 index 0000000..4fed009 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/js1_4/Regress/function-001.js @@ -0,0 +1,79 @@ +/* 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: function-001.js + * Description: + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=325843 + * js> function f(a){var a,b;} + * + * causes an an assert on a null 'sprop' in the 'Variables' function in + * jsparse.c This will crash non-debug build. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "function-001.js"; + var VERSION = "JS1_4"; + var TITLE = "Regression test case for 325843"; + var BUGNUMBER="3258435"; + startTest(); + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + eval("function f1 (a){ var a,b; }"); + + function f2( a ) { var a, b; }; + + testcases[tc++] = new TestCase( + SECTION, + "eval(\"function f1 (a){ var a,b; }\"); "+ + "function f2( a ) { var a, b; }; typeof f1", + "function", + typeof f1 ); + + // force a function decompilation + + testcases[tc++] = new TestCase( + SECTION, + "typeof f1.toString()", + "string", + typeof f1.toString() ); + + testcases[tc++] = new TestCase( + SECTION, + "typeof f2", + "function", + typeof f2 ); + + // force a function decompilation + + testcases[tc++] = new TestCase( + SECTION, + "typeof f2.toString()", + "string", + typeof f2.toString() ); + + test(); + diff --git a/Source/JavaScriptCore/tests/mozilla/js1_4/Regress/function-002.js b/Source/JavaScriptCore/tests/mozilla/js1_4/Regress/function-002.js new file mode 100644 index 0000000..0476869 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/js1_4/Regress/function-002.js @@ -0,0 +1,123 @@ +/* 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: function-002.js + * Description: + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=330462 + * js> function f(a){var a,b;} + * + * causes an an assert on a null 'sprop' in the 'Variables' function in + * jsparse.c This will crash non-debug build. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + * REVISED: 04 February 2001 + * (changed the comma expressions from trivial to non-trivial) + * Author: pschwartau@netscape.com + * + * Brendan: "The test seemed to require something that ECMA does not + * guarantee, and that JS1.4 didn't either. For example, given + * + * dec2 = "function f2(){1,2}"; + * + * the engine is free to decompile a function object compiled from this source, + * via Function.prototype.toString(), into some other string that compiles to + * an equivalent function. The engine now eliminates the useless comma expression + * 1,2, giving function f2(){}. This should be legal by the testsuite's lights." + * + */ + var SECTION = "function-002.js"; + var VERSION = "JS1_4"; + var TITLE = "Regression test case for 325843"; + var BUGNUMBER="330462"; + + startTest(); + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + dec1 = "function f1(x,y){++x, --y}"; + dec2 = "function f2(){var y; f1(1,2); y=new Date(); print(y.toString())}"; + + eval(dec1); + eval(dec2); + + testcases[tc++] = new TestCase( + SECTION, + "typeof f1", + "function", + typeof f1 ); + + + // force a function decompilation + testcases[tc++] = new TestCase( + SECTION, + "f1.toString() == dec1", + true, + StripSpaces(f1.toString()) == StripSpaces(dec1)); + + testcases[tc++] = new TestCase( + SECTION, + "typeof f2", + "function", + typeof f2 ); + + // force a function decompilation + + testcases[tc++] = new TestCase( + SECTION, + "f2.toString() == dec2", + true, + StripSpaces(f2.toString()) == StripSpaces(dec2)); + + test(); + + function StripSpaces( s ) { + var strippedString = ""; + for ( var currentChar = 0; currentChar < s.length; currentChar++ ) { + if (!IsWhiteSpace(s.charAt(currentChar))) { + strippedString += s.charAt(currentChar); + } + } + return strippedString; + } + + function IsWhiteSpace( string ) { + var cc = string.charCodeAt(0); + + switch (cc) { + case (0x0009): + case (0x000B): + case (0x000C): + case (0x0020): + case (0x000A): + case (0x000D): + case ( 59 ): // let's strip out semicolons, too + return true; + break; + default: + return false; + } + } + diff --git a/Source/JavaScriptCore/tests/mozilla/js1_4/Regress/function-003.js b/Source/JavaScriptCore/tests/mozilla/js1_4/Regress/function-003.js new file mode 100644 index 0000000..1cf1ea3 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/js1_4/Regress/function-003.js @@ -0,0 +1,77 @@ +/* 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: function-003.js + * Description: + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=104766 + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "toString-001.js"; + var VERSION = "JS1_4"; + var TITLE = "Regression test case for 104766"; + var BUGNUMBER="310514"; + + startTest(); + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + testcases[tc++] = new TestCase( + SECTION, + "StripSpaces(Array.prototype.concat.toString()).substring(0,17)", + "functionconcat(){", + StripSpaces(Array.prototype.concat.toString()).substring(0,17)); + + test(); + + function StripSpaces( s ) { + for ( var currentChar = 0, strippedString=""; + currentChar < s.length; currentChar++ ) + { + if (!IsWhiteSpace(s.charAt(currentChar))) { + strippedString += s.charAt(currentChar); + } + } + return strippedString; + } + + function IsWhiteSpace( string ) { + var cc = string.charCodeAt(0); + switch (cc) { + case (0x0009): + case (0x000B): + case (0x000C): + case (0x0020): + case (0x000A): + case (0x000D): + case ( 59 ): // let's strip out semicolons, too + return true; + break; + default: + return false; + } + } + diff --git a/Source/JavaScriptCore/tests/mozilla/js1_4/Regress/function-004-n.js b/Source/JavaScriptCore/tests/mozilla/js1_4/Regress/function-004-n.js new file mode 100644 index 0000000..5b94505 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/js1_4/Regress/function-004-n.js @@ -0,0 +1,51 @@ +/* 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: function-004.js + * Description: + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=310502 + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "funtion-004-n.js"; + var VERSION = "JS1_4"; + var TITLE = "Regression test case for 310502"; + var BUGNUMBER="310502"; + + startTest(); + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + var o = {}; + o.call = Function.prototype.call; + + testcases[tc++] = new TestCase( + SECTION, + "var o = {}; o.call = Function.prototype.call; o.call()", + "error", + o.call() ); + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/js1_4/Regress/regress-7224.js b/Source/JavaScriptCore/tests/mozilla/js1_4/Regress/regress-7224.js new file mode 100644 index 0000000..b63ecaa --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/js1_4/Regress/regress-7224.js @@ -0,0 +1,72 @@ +/* +* 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): +*/ + +/** + * File Name: regress-7224.js + * Reference: js1_2 + * Description: Remove support for the arg + * Author: ** replace with your e-mail address ** + */ + + var SECTION = "regress"; // provide a document reference (ie, ECMA section) + var VERSION = "JS1_4"; // Version of JavaScript or ECMA + var TITLE = "Regression test for bugzilla #7224"; // Provide ECMA section title or a description + var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=7224"; // Provide URL to bugsplat or bugzilla report + + startTest(); // leave this alone + + /* + * Calls to AddTestCase here. AddTestCase is a function that is defined + * in shell.js and takes three arguments: + * - a string representation of what is being tested + * - the expected result + * - the actual result + * + * For example, a test might look like this: + * + * var zip = /[\d]{5}$/; + * + * AddTestCase( + * "zip = /[\d]{5}$/; \"PO Box 12345 Boston, MA 02134\".match(zip)", // description of the test + * "02134", // expected result + * "PO Box 12345 Boston, MA 02134".match(zip) ); // actual result + * + */ + + var f = new Function( "return arguments.caller" ); + var o = {}; + + o.foo = f; + o.foo("a", "b", "c") + + + AddTestCase( + "var f = new Function( 'return arguments.caller' ); f()", + undefined, + f() ); + + AddTestCase( + "var o = {}; o.foo = f; o.foo('a')", + undefined, + o.foo('a') ); + + test(); // leave this alone. this executes the test cases and + // displays results. diff --git a/Source/JavaScriptCore/tests/mozilla/js1_4/Regress/toString-001-n.js b/Source/JavaScriptCore/tests/mozilla/js1_4/Regress/toString-001-n.js new file mode 100644 index 0000000..c075373 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/js1_4/Regress/toString-001-n.js @@ -0,0 +1,53 @@ +/* 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: toString-001-n.js + * Description: + * + * Function.prototype.toString is not generic. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "toString-001.js"; + var VERSION = "JS1_4"; + var TITLE = "Regression test case for 310514"; + var BUGNUMBER="310514"; + + startTest(); + + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + + + var o = {}; + o.toString = Function.prototype.toString; + + + testcases[tc++] = new TestCase( + SECTION, + "var o = {}; o.toString = Function.prototype.toString; o.toString();", + "error", + o.toString() ); + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/js1_4/browser.js b/Source/JavaScriptCore/tests/mozilla/js1_4/browser.js new file mode 100644 index 0000000..5bbdf7c --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/js1_4/browser.js @@ -0,0 +1,80 @@ +/* +* 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): +*/ + +/* + * JavaScript test library shared functions file for running the tests + * in the browser. Overrides the shell's print function with document.write + * and make everything HTML pretty. + * + * To run the tests in the browser, use the mkhtml.pl script to generate + * html pages that include the shell.js, browser.js (this file), and the + * test js file in script tags. + * + * The source of the page that is generated should look something like this: + * <script src="./../shell.js"></script> + * <script src="./../browser.js"></script> + * <script src="./mytest.js"></script> + */ + +onerror = err; + +function startTest() { + if ( BUGNUMBER ) { + writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + } + + testcases = new Array(); + tc = 0; +} + +function writeLineToLog( string ) { + document.write( string + "<br>\n"); +} +function writeHeaderToLog( string ) { + document.write( "<h2>" + string + "</h2>" ); +} +function stopTest() { + var gc; + if ( gc != undefined ) { + gc(); + } + document.write( "<hr>" ); +} +function writeFormattedResult( expect, actual, string, passed ) { + var s = "<tt>"+ string ; + s += "<b>" ; + s += ( passed ) ? "<font color=#009900> " + PASSED + : "<font color=#aa0000> " + FAILED + expect + "</tt>"; + writeLineToLog( s + "</font></b></tt>" ); + return passed; +} +function err( msg, page, line ) { + writeLineToLog( "Test failed with the message: " + msg ); + + testcases[tc].actual = "error"; + testcases[tc].reason = msg; + writeTestCaseResult( testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual + + ": " + testcases[tc].reason ); + stopTest(); + return true; +} diff --git a/Source/JavaScriptCore/tests/mozilla/js1_4/jsref.js b/Source/JavaScriptCore/tests/mozilla/js1_4/jsref.js new file mode 100644 index 0000000..982d14a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/js1_4/jsref.js @@ -0,0 +1,169 @@ +var completed = false; +var testcases; + +var BUGNUMBER=""; +var EXCLUDE = ""; + +var TT = ""; +var TT_ = ""; +var BR = ""; +var NBSP = " "; +var CR = "\n"; +var FONT = ""; +var FONT_ = ""; +var FONT_RED = ""; +var FONT_GREEN = ""; +var B = ""; +var B_ = "" +var H2 = ""; +var H2_ = ""; +var HR = ""; + +var PASSED = " PASSED!" +var FAILED = " FAILED! expected: "; + +version( 140 ); +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 TestCase( n, d, e, a ) { + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; + this.bugnumber = BUGNUMBER; + + this.passed = getTestCaseResult( this.expect, this.actual ); +} +function startTest() { +/* + // JavaScript 1.3 is supposed to be compliant ecma version 1.0 + if ( VERSION == "ECMA_1" ) { + version ( "130" ); + } + if ( VERSION == "JS_1.3" ) { + version ( "130" ); + } + if ( VERSION == "JS_1.2" ) { + version ( "120" ); + } + if ( VERSION == "JS_1.1" ) { + version ( "110" ); + } + // for ecma version 2.0, we will leave the javascript version to + // the default ( for now ). +*/ +} +function getTestCaseResult( expect, actual ) { + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + if ( expect != expect ) { + if ( typeof expect == "object" ) { + expect = "NaN object"; + } else { + expect = "NaN number"; + } + } + + var passed = ( expect == actual ) ? true : false; + + // if both objects are numbers, give a little leeway for rounding. + if ( !passed + && typeof(actual) == "number" + && typeof(expect) == "number" + ) { + if ( Math.abs(actual-expect) < 0.0000001 ) { + passed = true; + } + } + + // verify type is the same + if ( typeof(expect) != typeof(actual) ) { + passed = false; + } + + return passed; +} +function writeTestCaseResult( expect, actual, string ) { + var passed = getTestCaseResult( expect, actual ); + writeFormattedResult( expect, actual, string, passed ); + return passed; +} +function writeFormattedResult( expect, actual, string, passed ) { + var s = TT + string ; + + for ( k = 0; + k < (60 - string.length >= 0 ? 60 - string.length : 5) ; + k++ ) { +// s += NBSP; + } + + s += B ; + s += ( passed ) ? FONT_GREEN + NBSP + PASSED : FONT_RED + NBSP + FAILED + expect + TT_ ; + + writeLineToLog( s + FONT_ + B_ + TT_ ); + + return passed; +} + +function writeLineToLog( string ) { + print( string + BR + CR ); +} +function writeHeaderToLog( string ) { + print( H2 + string + H2_ ); +} +function stopTest() { + var sizeTag = "<#TEST CASES SIZE>"; + var doneTag = "<#TEST CASES DONE>"; + var beginTag = "<#TEST CASE "; + var endTag = ">"; + + print(sizeTag); + print(testcases.length); + for (tc = 0; tc < testcases.length; tc++) + { + print(beginTag + 'PASSED' + endTag); + print(testcases[tc].passed); + print(beginTag + 'NAME' + endTag); + print(testcases[tc].name); + print(beginTag + 'EXPECTED' + endTag); + print(testcases[tc].expect); + print(beginTag + 'ACTUAL' + endTag); + print(testcases[tc].actual); + print(beginTag + 'DESCRIPTION' + endTag); + print(testcases[tc].description); + print(beginTag + 'REASON' + endTag); + print(( testcases[tc].passed ) ? "" : "wrong value "); + print(beginTag + 'BUGNUMBER' + endTag); + print( BUGNUMBER ); + + } + print(doneTag); + gc(); +} +function getFailedCases() { + for ( var i = 0; i < testcases.length; i++ ) { + if ( ! testcases[i].passed ) { + print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); + } + } +} diff --git a/Source/JavaScriptCore/tests/mozilla/js1_4/shell.js b/Source/JavaScriptCore/tests/mozilla/js1_4/shell.js new file mode 100644 index 0000000..3afdc78 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/js1_4/shell.js @@ -0,0 +1,138 @@ +var completed = false; +var testcases; +var tc = 0; + +SECTION = ""; +VERSION = ""; +BUGNUMBER = ""; + +var GLOBAL = "[object global]"; +var PASSED = " PASSED!" +var FAILED = " FAILED! expected: "; + +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 ); +} +/* wrapper for test cas constructor that doesn't require the SECTION + * argument. + */ + +function AddTestCase( description, expect, actual ) { + testcases[tc++] = new TestCase( SECTION, description, expect, actual ); +} + +function TestCase( n, d, e, a ) { + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; + + this.passed = getTestCaseResult( this.expect, this.actual ); +} +function startTest() { +/* + // JavaScript 1.3 is supposed to be compliant ecma version 1.0 + if ( VERSION == "ECMA_1" ) { + version ( 130 ); + } + if ( VERSION == "JS_1.3" ) { + version ( 130 ); + } + if ( VERSION == "JS_1.2" ) { + version ( 120 ); + } + if ( VERSION == "JS_1.1" ) { + version ( 110 ); + } + // for ecma version 2.0, we will leave the javascript version to + // the default ( for now ). +*/ + + if ( BUGNUMBER ) { + writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + } + + testcases = new Array(); + tc = 0; +} +function getTestCaseResult( expect, actual ) { + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + if ( expect != expect ) { + if ( typeof expect == "object" ) { + expect = "NaN object"; + } else { + expect = "NaN number"; + } + } + + var passed = ( expect == actual ) ? true : false; + + // if both objects are numbers, give a little leeway for rounding. + if ( !passed + && typeof(actual) == "number" + && typeof(expect) == "number" + ) { + if ( Math.abs(actual-expect) < 0.0000001 ) { + passed = true; + } + } + + // verify type is the same + if ( typeof(expect) != typeof(actual) ) { + passed = false; + } + + return passed; +} +/* + * Begin printing functions. These functions use the shell's + * print function. When running tests in the browser, these + * functions, override these functions with functions that use + * document.write. + */ + +function writeTestCaseResult( expect, actual, string ) { + var passed = getTestCaseResult( expect, actual ); + writeFormattedResult( expect, actual, string, passed ); + return passed; +} +function writeFormattedResult( expect, actual, string, passed ) { + var s = string ; + s += ( passed ) ? PASSED : FAILED + expect; + writeLineToLog( s); + return passed; +} +function writeLineToLog( string ) { + print( string ); +} +function writeHeaderToLog( string ) { + print( string ); +} +/* end of print functions */ + +function stopTest() { + var gc; + if ( gc != undefined ) { + gc(); + } +} |