Debian Codegraph @

rhino/testsrc/tests/ecma/FunctionObjects/15.3.2.1-2.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 gTestfile = '15.3.2.1-2.js';
7
8 /**
9 File Name: 15.3.2.1.js
10 ECMA Section: 15.3.2.1 The Function Constructor
11 new Function(p1, p2, ..., pn, body )
12
13 Description:
14 Author: [email protected]
15 Date: 28 october 1997
16
17 */
18 var SECTION = "15.3.2.1-2";
19 var VERSION = "ECMA_1";
20 startTest();
21 var TITLE = "The Function Constructor";
22
23 writeHeaderToLog( SECTION + " "+ TITLE);
24
25
26 var myfunc1 = new Function("a","b","c", "return a+b+c" );
27 var myfunc2 = new Function("a, b, c", "return a+b+c" );
28 var myfunc3 = new Function("a,b", "c", "return a+b+c" );
29
30 myfunc1.toString = Object.prototype.toString;
31 myfunc2.toString = Object.prototype.toString;
32 myfunc3.toString = Object.prototype.toString;
33
34 new TestCase( SECTION, "myfunc1 = new Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()",
35 "[object Function]",
36 myfunc1.toString() );
37
38 new TestCase( SECTION, "myfunc1.length", 3, myfunc1.length );
39 new TestCase( SECTION, "myfunc1.prototype.toString()", "[object Object]", myfunc1.prototype.toString() );
40
41 new TestCase( SECTION, "myfunc1.prototype.constructor", myfunc1, myfunc1.prototype.constructor );
42 new TestCase( SECTION, "myfunc1.arguments", null, myfunc1.arguments );
43 new TestCase( SECTION, "myfunc1(1,2,3)", 6, myfunc1(1,2,3) );
44 new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc1.prototype ) { MYPROPS += p; }; MYPROPS",
45 "",
46 eval("var MYPROPS = ''; for ( var p in myfunc1.prototype ) { MYPROPS += p; }; MYPROPS") );
47
48 new TestCase( SECTION, "myfunc2 = new Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()",
49 "[object Function]",
50 myfunc2.toString() );
51 new TestCase( SECTION, "myfunc2.length", 3, myfunc2.length );
52 new TestCase( SECTION, "myfunc2.prototype.toString()", "[object Object]", myfunc2.prototype.toString() );
53
54 new TestCase( SECTION, "myfunc2.prototype.constructor", myfunc2, myfunc2.prototype.constructor );
55 new TestCase( SECTION, "myfunc2.arguments", null, myfunc2.arguments );
56 new TestCase( SECTION, "myfunc2( 1000, 200, 30 )", 1230, myfunc2(1000,200,30) );
57 new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc2.prototype ) { MYPROPS += p; }; MYPROPS",
58 "",
59 eval("var MYPROPS = ''; for ( var p in myfunc2.prototype ) { MYPROPS += p; }; MYPROPS") );
60
61 new TestCase( SECTION, "myfunc3 = new Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()",
62 "[object Function]",
63 myfunc3.toString() );
64 new TestCase( SECTION, "myfunc3.length", 3, myfunc3.length );
65 new TestCase( SECTION, "myfunc3.prototype.toString()", "[object Object]", myfunc3.prototype.toString() );
66 new TestCase( SECTION, "myfunc3.prototype.valueOf() +''", "[object Object]", myfunc3.prototype.valueOf() +'' );
67 new TestCase( SECTION, "myfunc3.prototype.constructor", myfunc3, myfunc3.prototype.constructor );
68 new TestCase( SECTION, "myfunc3.arguments", null, myfunc3.arguments );
69 new TestCase( SECTION, "myfunc3(-100,100,NaN)", Number.NaN, myfunc3(-100,100,NaN) );
70
71 new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc3.prototype ) { MYPROPS += p; }; MYPROPS",
72 "",
73 eval("var MYPROPS = ''; for ( var p in myfunc3.prototype ) { MYPROPS += p; }; MYPROPS") );
74 test();