diff options
Diffstat (limited to 'js/src/tests/ecma/FunctionObjects')
19 files changed, 1053 insertions, 0 deletions
diff --git a/js/src/tests/ecma/FunctionObjects/15.3.1.1-1.js b/js/src/tests/ecma/FunctionObjects/15.3.1.1-1.js new file mode 100644 index 000000000..62d66cbc9 --- /dev/null +++ b/js/src/tests/ecma/FunctionObjects/15.3.1.1-1.js @@ -0,0 +1,102 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.3.1.1.js + ECMA Section: 15.3.1.1 The Function Constructor Called as a Function + + Description: + When the Function function is called with some arguments p1, p2, . . . , pn, body + (where n might be 0, that is, there are no "p" arguments, and where body might + also not be provided), the following steps are taken: + + 1. Create and return a new Function object exactly if the function constructor had + been called with the same arguments (15.3.2.1). + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.3.1.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Function Constructor Called as a Function"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var MyObject = Function( "value", "this.value = value; this.valueOf = Function( 'return this.value' ); this.toString = Function( 'return String(this.value);' )" ); + + +var myfunc = Function(); +myfunc.toString = Object.prototype.toString; + +// not going to test toString here since it is implementation dependent. +// new TestCase( SECTION, "myfunc.toString()", "function anonymous() { }", myfunc.toString() ); + +myfunc.toString = Object.prototype.toString; +new TestCase( SECTION, + "myfunc = Function(); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc.toString() ); + +new TestCase( SECTION, + "myfunc.length", + 0, + myfunc.length ); + +new TestCase( SECTION, + "myfunc.prototype.toString()", + "[object Object]", + myfunc.prototype.toString() ); + +new TestCase( SECTION, + "myfunc.prototype.constructor", + myfunc, + myfunc.prototype.constructor ); + +new TestCase( SECTION, + "myfunc.arguments", + null, + myfunc.arguments ); + +new TestCase( SECTION, + "var OBJ = new MyObject(true); OBJ.valueOf()", + true, + eval("var OBJ = new MyObject(true); OBJ.valueOf()") ); + +new TestCase( SECTION, + "OBJ.toString()", + "true", + OBJ.toString() ); + +new TestCase( SECTION, + "OBJ.toString = Object.prototype.toString; OBJ.toString()", + "[object Object]", + eval("OBJ.toString = Object.prototype.toString; OBJ.toString()") ); + +new TestCase( SECTION, + "MyObject.toString = Object.prototype.toString; MyObject.toString()", + "[object Function]", + eval("MyObject.toString = Object.prototype.toString; MyObject.toString()") ); + +new TestCase( SECTION, + "MyObject.length", + 1, + MyObject.length ); + +new TestCase( SECTION, + "MyObject.prototype.constructor", + MyObject, + MyObject.prototype.constructor ); + +new TestCase( SECTION, + "MyObject.arguments", + null, + MyObject.arguments ); + +test(); + + diff --git a/js/src/tests/ecma/FunctionObjects/15.3.1.1-2.js b/js/src/tests/ecma/FunctionObjects/15.3.1.1-2.js new file mode 100644 index 000000000..1cea3c1cc --- /dev/null +++ b/js/src/tests/ecma/FunctionObjects/15.3.1.1-2.js @@ -0,0 +1,149 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.3.1.1-2.js + ECMA Section: 15.3.1.1 The Function Constructor Called as a Function + Function(p1, p2, ..., pn, body ) + + Description: + When the Function function is called with some arguments p1, p2, . . . , pn, + body (where n might be 0, that is, there are no "p" arguments, and where body + might also not be provided), the following steps are taken: + + 1. Create and return a new Function object exactly if the function constructor + had been called with the same arguments (15.3.2.1). + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.3.1.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Function Constructor Called as a Function"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var myfunc1 = Function("a","b","c", "return a+b+c" ); +var myfunc2 = Function("a, b, c", "return a+b+c" ); +var myfunc3 = Function("a,b", "c", "return a+b+c" ); + +myfunc1.toString = Object.prototype.toString; +myfunc2.toString = Object.prototype.toString; +myfunc3.toString = Object.prototype.toString; + +new TestCase( SECTION, + "myfunc1 = Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc1.toString() ); + +new TestCase( SECTION, + "myfunc1.length", + 3, + myfunc1.length ); + +new TestCase( SECTION, + "myfunc1.prototype.toString()", + "[object Object]", + myfunc1.prototype.toString() ); + +new TestCase( SECTION, + "myfunc1.prototype.constructor", + myfunc1, + myfunc1.prototype.constructor ); + +new TestCase( SECTION, + "myfunc1.arguments", + null, + myfunc1.arguments ); + +new TestCase( SECTION, + "myfunc1(1,2,3)", + 6, + myfunc1(1,2,3) ); + +new TestCase( SECTION, + "var MYPROPS = ''; for ( var p in myfunc1.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc1.prototype ) { MYPROPS += p; }; MYPROPS") ); + +new TestCase( SECTION, + "myfunc2 = Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc2.toString() ); + +new TestCase( SECTION, + "myfunc2.length", + 3, + myfunc2.length ); + +new TestCase( SECTION, + "myfunc2.prototype.toString()", + "[object Object]", + myfunc2.prototype.toString() ); + +new TestCase( SECTION, + "myfunc2.prototype.constructor", + myfunc2, + myfunc2.prototype.constructor ); + +new TestCase( SECTION, + "myfunc2.arguments", + null, + myfunc2.arguments ); + +new TestCase( SECTION, + "myfunc2( 1000, 200, 30 )", + 1230, + myfunc2(1000,200,30) ); + +new TestCase( SECTION, + "var MYPROPS = ''; for ( var p in myfunc2.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc2.prototype ) { MYPROPS += p; }; MYPROPS") ); + +new TestCase( SECTION, + "myfunc3 = Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc3.toString() ); + +new TestCase( SECTION, + "myfunc3.length", + 3, + myfunc3.length ); + +new TestCase( SECTION, + "myfunc3.prototype.toString()", + "[object Object]", + myfunc3.prototype.toString() ); + +new TestCase( SECTION, + "myfunc3.prototype.valueOf() +''", + "[object Object]", + myfunc3.prototype.valueOf() +'' ); + +new TestCase( SECTION, + "myfunc3.prototype.constructor", + myfunc3, + myfunc3.prototype.constructor ); + +new TestCase( SECTION, + "myfunc3.arguments", + null, + myfunc3.arguments ); + +new TestCase( SECTION, + "myfunc3(-100,100,NaN)", + Number.NaN, + myfunc3(-100,100,NaN) ); + +new TestCase( SECTION, + "var MYPROPS = ''; for ( var p in myfunc3.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc3.prototype ) { MYPROPS += p; }; MYPROPS") ); + +test(); diff --git a/js/src/tests/ecma/FunctionObjects/15.3.1.1-3.js b/js/src/tests/ecma/FunctionObjects/15.3.1.1-3.js new file mode 100644 index 000000000..7c3e2b006 --- /dev/null +++ b/js/src/tests/ecma/FunctionObjects/15.3.1.1-3.js @@ -0,0 +1,65 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.3.1.1-3.js + ECMA Section: 15.3.1.1 The Function Constructor Called as a Function + + new Function(p1, p2, ..., pn, body ) + + Description: The last argument specifies the body (executable code) + of a function; any preceding arguments sepcify formal + parameters. + + See the text for description of this section. + + This test examples from the specification. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.3.1.1-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Function Constructor Called as a Function"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var args = ""; + +for ( var i = 0; i < 2000; i++ ) { + args += "arg"+i; + if ( i != 1999 ) { + args += ","; + } +} + +var s = ""; + +for ( var i = 0; i < 2000; i++ ) { + s += ".0005"; + if ( i != 1999 ) { + s += ","; + } +} + +MyFunc = Function( args, "var r=0; for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; else r += eval('arg'+i); }; return r"); +MyObject = Function( args, "for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; eval('this.arg'+i +'=arg'+i); };"); + +var MY_OB = eval( "MyFunc("+ s +")" ); + +new TestCase( SECTION, "MyFunc.length", 2000, MyFunc.length ); +new TestCase( SECTION, "var MY_OB = eval('MyFunc(s)')", 1, MY_OB ); +new TestCase( SECTION, "var MY_OB = eval('MyFunc(s)')", 1, eval("var MY_OB = MyFunc("+s+"); MY_OB") ); + +new TestCase( SECTION, "MyObject.length", 2000, MyObject.length ); + +new TestCase( SECTION, "FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1.length", 3, eval("FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1.length") ); +new TestCase( SECTION, "FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1()", 3, eval("FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1()") ); +new TestCase( SECTION, "FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)", 3, eval("FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)") ); + +test(); diff --git a/js/src/tests/ecma/FunctionObjects/15.3.2.1-1.js b/js/src/tests/ecma/FunctionObjects/15.3.2.1-1.js new file mode 100644 index 000000000..2f3334fd8 --- /dev/null +++ b/js/src/tests/ecma/FunctionObjects/15.3.2.1-1.js @@ -0,0 +1,98 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.3.2.1.js + ECMA Section: 15.3.2.1 The Function Constructor + new Function(p1, p2, ..., pn, body ) + + Description: The last argument specifies the body (executable code) + of a function; any preceding arguments sepcify formal + parameters. + + See the text for description of this section. + + This test examples from the specification. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.3.2.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Function Constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var MyObject = new Function( "value", "this.value = value; this.valueOf = new Function( 'return this.value' ); this.toString = new Function( 'return String(this.value);' )" ); + +var myfunc = new Function(); + +// not going to test toString here since it is implementation dependent. +// new TestCase( SECTION, "myfunc.toString()", "function anonymous() { }", myfunc.toString() ); + +myfunc.toString = Object.prototype.toString; + +new TestCase( SECTION, "myfunc = new Function(); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc.toString() ); + +new TestCase( SECTION, + "myfunc.length", + 0, + myfunc.length ); + +new TestCase( SECTION, + "myfunc.prototype.toString()", + "[object Object]", + myfunc.prototype.toString() ); + +new TestCase( SECTION, + "myfunc.prototype.constructor", + myfunc, + myfunc.prototype.constructor ); + +new TestCase( SECTION, + "myfunc.arguments", + null, + myfunc.arguments ); + +new TestCase( SECTION, + "var OBJ = new MyObject(true); OBJ.valueOf()", + true, + eval("var OBJ = new MyObject(true); OBJ.valueOf()") ); + +new TestCase( SECTION, + "OBJ.toString()", + "true", + OBJ.toString() ); + +new TestCase( SECTION, + "OBJ.toString = Object.prototype.toString; OBJ.toString()", "[object Object]", + eval("OBJ.toString = Object.prototype.toString; OBJ.toString()") ); + +new TestCase( SECTION, + "MyObject.toString = Object.prototype.toString; MyObject.toString()", + "[object Function]", + eval("MyObject.toString = Object.prototype.toString; MyObject.toString()") ); + +new TestCase( SECTION, + "MyObject.length", + 1, + MyObject.length ); + +new TestCase( SECTION, + "MyObject.prototype.constructor", + MyObject, + MyObject.prototype.constructor ); + +new TestCase( SECTION, + "MyObject.arguments", + null, + MyObject.arguments ); + +test(); diff --git a/js/src/tests/ecma/FunctionObjects/15.3.2.1-2.js b/js/src/tests/ecma/FunctionObjects/15.3.2.1-2.js new file mode 100644 index 000000000..7740480ab --- /dev/null +++ b/js/src/tests/ecma/FunctionObjects/15.3.2.1-2.js @@ -0,0 +1,73 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.3.2.1.js + ECMA Section: 15.3.2.1 The Function Constructor + new Function(p1, p2, ..., pn, body ) + + Description: + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.3.2.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Function Constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +var myfunc1 = new Function("a","b","c", "return a+b+c" ); +var myfunc2 = new Function("a, b, c", "return a+b+c" ); +var myfunc3 = new Function("a,b", "c", "return a+b+c" ); + +myfunc1.toString = Object.prototype.toString; +myfunc2.toString = Object.prototype.toString; +myfunc3.toString = Object.prototype.toString; + +new TestCase( SECTION, "myfunc1 = new Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc1.toString() ); + +new TestCase( SECTION, "myfunc1.length", 3, myfunc1.length ); +new TestCase( SECTION, "myfunc1.prototype.toString()", "[object Object]", myfunc1.prototype.toString() ); + +new TestCase( SECTION, "myfunc1.prototype.constructor", myfunc1, myfunc1.prototype.constructor ); +new TestCase( SECTION, "myfunc1.arguments", null, myfunc1.arguments ); +new TestCase( SECTION, "myfunc1(1,2,3)", 6, myfunc1(1,2,3) ); +new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc1.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc1.prototype ) { MYPROPS += p; }; MYPROPS") ); + +new TestCase( SECTION, "myfunc2 = new Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc2.toString() ); +new TestCase( SECTION, "myfunc2.length", 3, myfunc2.length ); +new TestCase( SECTION, "myfunc2.prototype.toString()", "[object Object]", myfunc2.prototype.toString() ); + +new TestCase( SECTION, "myfunc2.prototype.constructor", myfunc2, myfunc2.prototype.constructor ); +new TestCase( SECTION, "myfunc2.arguments", null, myfunc2.arguments ); +new TestCase( SECTION, "myfunc2( 1000, 200, 30 )", 1230, myfunc2(1000,200,30) ); +new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc2.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc2.prototype ) { MYPROPS += p; }; MYPROPS") ); + +new TestCase( SECTION, "myfunc3 = new Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc3.toString() ); +new TestCase( SECTION, "myfunc3.length", 3, myfunc3.length ); +new TestCase( SECTION, "myfunc3.prototype.toString()", "[object Object]", myfunc3.prototype.toString() ); +new TestCase( SECTION, "myfunc3.prototype.valueOf() +''", "[object Object]", myfunc3.prototype.valueOf() +'' ); +new TestCase( SECTION, "myfunc3.prototype.constructor", myfunc3, myfunc3.prototype.constructor ); +new TestCase( SECTION, "myfunc3.arguments", null, myfunc3.arguments ); +new TestCase( SECTION, "myfunc3(-100,100,NaN)", Number.NaN, myfunc3(-100,100,NaN) ); + +new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc3.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc3.prototype ) { MYPROPS += p; }; MYPROPS") ); +test(); diff --git a/js/src/tests/ecma/FunctionObjects/15.3.2.1-3.js b/js/src/tests/ecma/FunctionObjects/15.3.2.1-3.js new file mode 100644 index 000000000..36860057d --- /dev/null +++ b/js/src/tests/ecma/FunctionObjects/15.3.2.1-3.js @@ -0,0 +1,61 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.3.2.1-3.js + ECMA Section: 15.3.2.1 The Function Constructor + new Function(p1, p2, ..., pn, body ) + + Description: The last argument specifies the body (executable code) + of a function; any preceding arguments sepcify formal + parameters. + + See the text for description of this section. + + This test examples from the specification. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.3.2.1-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Function Constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var args = ""; + +for ( var i = 0; i < 2000; i++ ) { + args += "arg"+i; + if ( i != 1999 ) { + args += ","; + } +} + +var s = ""; + +for ( var i = 0; i < 2000; i++ ) { + s += ".0005"; + if ( i != 1999 ) { + s += ","; + } +} + +MyFunc = new Function( args, "var r=0; for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; else r += eval('arg'+i); }; return r"); +MyObject = new Function( args, "for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; eval('this.arg'+i +'=arg'+i); };"); + +new TestCase( SECTION, "MyFunc.length", 2000, MyFunc.length ); +new TestCase( SECTION, "var MY_OB = eval('MyFunc(s)')", 1, eval("var MY_OB = MyFunc("+s+"); MY_OB") ); + +new TestCase( SECTION, "MyObject.length", 2000, MyObject.length ); + +new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1.length", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1.length") ); +new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1()", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1()") ); +new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)") ); + +test(); diff --git a/js/src/tests/ecma/FunctionObjects/15.3.3.1-2.js b/js/src/tests/ecma/FunctionObjects/15.3.3.1-2.js new file mode 100644 index 000000000..c3a3f26bf --- /dev/null +++ b/js/src/tests/ecma/FunctionObjects/15.3.3.1-2.js @@ -0,0 +1,36 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.3.3.1-2.js + ECMA Section: 15.3.3.1 Properties of the Function Constructor + Function.prototype + + Description: The initial value of Function.prototype is the built-in + Function prototype object. + + This property shall have the attributes [DontEnum | + DontDelete | ReadOnly] + + This test the DontEnum property of Function.prototype. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.3.3.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function.prototype"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "var str='';for (prop in Function ) str += prop; str;", + "", + eval("var str='';for (prop in Function) str += prop; str;") + ); +test(); diff --git a/js/src/tests/ecma/FunctionObjects/15.3.3.1-3.js b/js/src/tests/ecma/FunctionObjects/15.3.3.1-3.js new file mode 100644 index 000000000..c11928753 --- /dev/null +++ b/js/src/tests/ecma/FunctionObjects/15.3.3.1-3.js @@ -0,0 +1,45 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.3.3.1-3.js + ECMA Section: 15.3.3.1 Properties of the Function Constructor + Function.prototype + + Description: The initial value of Function.prototype is the built-in + Function prototype object. + + This property shall have the attributes [DontEnum | + DontDelete | ReadOnly] + + This test the DontDelete property of Function.prototype. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.3.3.1-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function.prototype"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +var FUN_PROTO = Function.prototype; + +new TestCase( SECTION, + "delete Function.prototype", + false, + delete Function.prototype + ); + +new TestCase( SECTION, + "delete Function.prototype; Function.prototype", + FUN_PROTO, + eval("delete Function.prototype; Function.prototype") + ); +test(); diff --git a/js/src/tests/ecma/FunctionObjects/15.3.3.1-4.js b/js/src/tests/ecma/FunctionObjects/15.3.3.1-4.js new file mode 100644 index 000000000..3b5b64dc4 --- /dev/null +++ b/js/src/tests/ecma/FunctionObjects/15.3.3.1-4.js @@ -0,0 +1,36 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.3.3.1-4.js + ECMA Section: 15.3.3.1 Properties of the Function Constructor + Function.prototype + + Description: The initial value of Function.prototype is the built-in + Function prototype object. + + This property shall have the attributes [DontEnum | + DontDelete | ReadOnly] + + This test the ReadOnly property of Function.prototype. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.3.3.1-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function.prototype"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Function.prototype = null; Function.prototype", + Function.prototype, + eval("Function.prototype = null; Function.prototype") + ); +test(); diff --git a/js/src/tests/ecma/FunctionObjects/15.3.3.2.js b/js/src/tests/ecma/FunctionObjects/15.3.3.2.js new file mode 100644 index 000000000..d92463101 --- /dev/null +++ b/js/src/tests/ecma/FunctionObjects/15.3.3.2.js @@ -0,0 +1,28 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.3.3.2.js + ECMA Section: 15.3.3.2 Properties of the Function Constructor + Function.length + + Description: The length property is 1. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + +var SECTION = "15.3.3.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function.length"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "Function.length", 1, Function.length ); + +test(); diff --git a/js/src/tests/ecma/FunctionObjects/15.3.4-1.js b/js/src/tests/ecma/FunctionObjects/15.3.4-1.js new file mode 100644 index 000000000..49892a382 --- /dev/null +++ b/js/src/tests/ecma/FunctionObjects/15.3.4-1.js @@ -0,0 +1,60 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.3.4-1.js + ECMA Section: 15.3.4 Properties of the Function Prototype Object + + Description: The Function prototype object is itself a Function + object ( its [[Class]] is "Function") that, when + invoked, accepts any arguments and returns undefined. + + The value of the internal [[Prototype]] property + object is the Object prototype object. + + It is a function with an "empty body"; if it is + invoked, it merely returns undefined. + + The Function prototype object does not have a valueOf + property of its own; however it inherits the valueOf + property from the Object prototype Object. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + +var SECTION = "15.3.4-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the Function Prototype Object"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "var myfunc = Function.prototype; myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + eval("var myfunc = Function.prototype; myfunc.toString = Object.prototype.toString; myfunc.toString()")); + + +// new TestCase( SECTION, "Function.prototype.__proto__", Object.prototype, Function.prototype.__proto__ ); + +new TestCase( SECTION, + "Function.prototype.valueOf", + Object.prototype.valueOf, + Function.prototype.valueOf ); + +new TestCase( SECTION, + "Function.prototype()", + (void 0), + Function.prototype() ); + +new TestCase( SECTION, + "Function.prototype(1,true,false,'string', new Date(),null)", + (void 0), + Function.prototype(1,true,false,'string', new Date(),null) ); + +test(); diff --git a/js/src/tests/ecma/FunctionObjects/15.3.4.1.js b/js/src/tests/ecma/FunctionObjects/15.3.4.1.js new file mode 100644 index 000000000..e8f669d48 --- /dev/null +++ b/js/src/tests/ecma/FunctionObjects/15.3.4.1.js @@ -0,0 +1,27 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.3.4.1.js + ECMA Section: 15.3.4.1 Function.prototype.constructor + + Description: The initial value of Function.prototype.constructor + is the built-in Function constructor. + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + +var SECTION = "15.3.4.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function.prototype.constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "Function.prototype.constructor", Function, Function.prototype.constructor ); + +test(); diff --git a/js/src/tests/ecma/FunctionObjects/15.3.4.js b/js/src/tests/ecma/FunctionObjects/15.3.4.js new file mode 100644 index 000000000..3ce16e9f5 --- /dev/null +++ b/js/src/tests/ecma/FunctionObjects/15.3.4.js @@ -0,0 +1,47 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.3.4.js + ECMA Section: 15.3.4 Properties of the Function Prototype Object + + Description: The Function prototype object is itself a Function + object ( its [[Class]] is "Function") that, when + invoked, accepts any arguments and returns undefined. + + The value of the internal [[Prototype]] property + object is the Object prototype object. + + It is a function with an "empty body"; if it is + invoked, it merely returns undefined. + + The Function prototype object does not have a valueOf + property of its own; however it inherits the valueOf + property from the Object prototype Object. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.3.4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the Function Prototype Object"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "var myfunc = Function.prototype; myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + eval("var myfunc = Function.prototype; myfunc.toString = Object.prototype.toString; myfunc.toString()")); + + +// new TestCase( SECTION, "Function.prototype.__proto__", Object.prototype, Function.prototype.__proto__ ); +new TestCase( SECTION, "Function.prototype.valueOf", Object.prototype.valueOf, Function.prototype.valueOf ); +new TestCase( SECTION, "Function.prototype()", (void 0), Function.prototype() ); +new TestCase( SECTION, "Function.prototype(1,true,false,'string', new Date(),null)", (void 0), Function.prototype(1,true,false,'string', new Date(),null) ); + +test(); diff --git a/js/src/tests/ecma/FunctionObjects/15.3.5-1.js b/js/src/tests/ecma/FunctionObjects/15.3.5-1.js new file mode 100644 index 000000000..b6561ab96 --- /dev/null +++ b/js/src/tests/ecma/FunctionObjects/15.3.5-1.js @@ -0,0 +1,83 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.3.5-1.js + ECMA Section: 15.3.5 Properties of Function Instances + new Function(p1, p2, ..., pn, body ) + + Description: + + 15.3.5.1 length + + The value of the length property is usually an integer that indicates + the "typical" number of arguments expected by the function. However, + the language permits the function to be invoked with some other number + of arguments. The behavior of a function when invoked on a number of + arguments other than the number specified by its length property depends + on the function. + + 15.3.5.2 prototype + The value of the prototype property is used to initialize the internal [[ + Prototype]] property of a newly created object before the Function object + is invoked as a constructor for that newly created object. + + 15.3.5.3 arguments + + The value of the arguments property is normally null if there is no + outstanding invocation of the function in progress (that is, the function has been called + but has not yet returned). When a non-internal Function object (15.3.2.1) is invoked, its + arguments property is "dynamically bound" to a newly created object that contains the + arguments on which it was invoked (see 10.1.6 and 10.1.8). Note that the use of this + property is discouraged; it is provided principally for compatibility with existing old code. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + +var SECTION = "15.3.5-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of Function Instances"; + +writeHeaderToLog( SECTION + " "+TITLE); + +var args = ""; + +for ( var i = 0; i < 2000; i++ ) { + args += "arg"+i; + if ( i != 1999 ) { + args += ","; + } +} + +var s = ""; + +for ( var i = 0; i < 2000; i++ ) { + s += ".0005"; + if ( i != 1999 ) { + s += ","; + } +} + +MyFunc = new Function( args, "var r=0; for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; else r += eval('arg'+i); }; return r"); +MyObject = new Function( args, "for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; eval('this.arg'+i +'=arg'+i); };"); + + +new TestCase( SECTION, "MyFunc.length", 2000, MyFunc.length ); +new TestCase( SECTION, "var MY_OB = eval('MyFunc(s)')", 1, eval("var MY_OB = MyFunc("+s+"); MY_OB") ); +new TestCase( SECTION, "MyFunc.prototype.toString()", "[object Object]", MyFunc.prototype.toString() ); +new TestCase( SECTION, "typeof MyFunc.prototype", "object", typeof MyFunc.prototype ); + + +new TestCase( SECTION, "MyObject.length", 2000, MyObject.length ); + +new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1.length", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1.length") ); +new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1()", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1()") ); +new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)") ); + +test(); diff --git a/js/src/tests/ecma/FunctionObjects/15.3.5-2.js b/js/src/tests/ecma/FunctionObjects/15.3.5-2.js new file mode 100644 index 000000000..50593481d --- /dev/null +++ b/js/src/tests/ecma/FunctionObjects/15.3.5-2.js @@ -0,0 +1,56 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.3.5-1.js + ECMA Section: 15.3.5 Properties of Function Instances + new Function(p1, p2, ..., pn, body ) + + Description: + + 15.3.5.1 length + + The value of the length property is usually an integer that indicates + the "typical" number of arguments expected by the function. However, + the language permits the function to be invoked with some other number + of arguments. The behavior of a function when invoked on a number of + arguments other than the number specified by its length property depends + on the function. + + 15.3.5.2 prototype + The value of the prototype property is used to initialize the internal [[ + Prototype]] property of a newly created object before the Function object + is invoked as a constructor for that newly created object. + + 15.3.5.3 arguments + + The value of the arguments property is normally null if there is no + outstanding invocation of the function in progress (that is, the function has been called + but has not yet returned). When a non-internal Function object (15.3.2.1) is invoked, its + arguments property is "dynamically bound" to a newly created object that contains the + arguments on which it was invoked (see 10.1.6 and 10.1.8). Note that the use of this + property is discouraged; it is provided principally for compatibility with existing old code. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + +var SECTION = "15.3.5-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of Function Instances"; + +writeHeaderToLog( SECTION + " "+TITLE); + +var MyObject = new Function( 'a', 'b', 'c', 'this.a = a; this.b = b; this.c = c; this.value = a+b+c; this.valueOf = new Function( "return this.value" )' ); + +new TestCase( SECTION, "MyObject.length", 3, MyObject.length ); +new TestCase( SECTION, "typeof MyObject.prototype", "object", typeof MyObject.prototype ); +new TestCase( SECTION, "typeof MyObject.prototype.constructor", "function", typeof MyObject.prototype.constructor ); +new TestCase( SECTION, "MyObject.arguments", null, MyObject.arguments ); + +test(); diff --git a/js/src/tests/ecma/FunctionObjects/15.3.5.1.js b/js/src/tests/ecma/FunctionObjects/15.3.5.1.js new file mode 100644 index 000000000..5a6eb1451 --- /dev/null +++ b/js/src/tests/ecma/FunctionObjects/15.3.5.1.js @@ -0,0 +1,49 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.3.5.1.js + ECMA Section: Function.length + Description: + + The value of the length property is usually an integer that indicates the + "typical" number of arguments expected by the function. However, the + language permits the function to be invoked with some other number of + arguments. The behavior of a function when invoked on a number of arguments + other than the number specified by its length property depends on the function. + + this test needs a 1.2 version check. + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=104204 + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.3.5.1"; +var VERSION = "ECMA_1"; +var TITLE = "Function.length"; +var BUGNUMBER="104204"; +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + +var f = new Function( "a","b", "c", "return f.length"); + +new TestCase( SECTION, + 'var f = new Function( "a","b", "c", "return f.length"); f()', + 3, + f() ); + + +new TestCase( SECTION, + 'var f = new Function( "a","b", "c", "return f.length"); f(1,2,3,4,5)', + 3, + f(1,2,3,4,5) ); + +test(); + diff --git a/js/src/tests/ecma/FunctionObjects/15.3.5.3.js b/js/src/tests/ecma/FunctionObjects/15.3.5.3.js new file mode 100644 index 000000000..6274d3101 --- /dev/null +++ b/js/src/tests/ecma/FunctionObjects/15.3.5.3.js @@ -0,0 +1,38 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: 15.3.5.3.js + ECMA Section: Function.arguments + Description: + + The value of the arguments property is normally null if there is no + outstanding invocation of the function in progress (that is, the + function has been called but has not yet returned). When a non-internal + Function object (15.3.2.1) is invoked, its arguments property is + "dynamically bound" to a newly created object that contains the arguments + on which it was invoked (see 10.1.6 and 10.1.8). Note that the use of this + property is discouraged; it is provided principally for compatibility + with existing old code. + + See sections 10.1.6 and 10.1.8 for more extensive tests. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.3.5.3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function.arguments"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var MYFUNCTION = new Function( "return this.arguments" ); + +new TestCase( SECTION, "var MYFUNCTION = new Function( 'return this.arguments' ); MYFUNCTION.arguments", null, MYFUNCTION.arguments ); + +test(); diff --git a/js/src/tests/ecma/FunctionObjects/browser.js b/js/src/tests/ecma/FunctionObjects/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/ecma/FunctionObjects/browser.js diff --git a/js/src/tests/ecma/FunctionObjects/shell.js b/js/src/tests/ecma/FunctionObjects/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/ecma/FunctionObjects/shell.js |