Debian Codegraph @

rhino/testsrc/tests/ecma/FunctionObjects/15.3.1.1-1.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.1.1-1.js';
7
8 /**
9 File Name: 15.3.1.1.js
10 ECMA Section: 15.3.1.1 The Function Constructor Called as a Function
11
12 Description:
13 When the Function function is called with some arguments p1, p2, . . . , pn, body
14 (where n might be 0, that is, there are no "p" arguments, and where body might
15 also not be provided), the following steps are taken:
16
17 1. Create and return a new Function object exactly if the function constructor had
18 been called with the same arguments (15.3.2.1).
19
20 Author: [email protected]
21 Date: 28 october 1997
22
23 */
24 var SECTION = "15.3.1.1-1";
25 var VERSION = "ECMA_1";
26 startTest();
27 var TITLE = "The Function Constructor Called as a Function";
28
29 writeHeaderToLog( SECTION + " "+ TITLE);
30
31 var MyObject = Function( "value", "this.value = value; this.valueOf = Function( 'return this.value' ); this.toString = Function( 'return String(this.value);' )" );
32
33
34 var myfunc = Function();
35 myfunc.toString = Object.prototype.toString;
36
37 // not going to test toString here since it is implementation dependent.
38 // new TestCase( SECTION, "myfunc.toString()", "function anonymous() { }", myfunc.toString() );
39
40 myfunc.toString = Object.prototype.toString;
41 new TestCase( SECTION,
42 "myfunc = Function(); myfunc.toString = Object.prototype.toString; myfunc.toString()",
43 "[object Function]",
44 myfunc.toString() );
45
46 new TestCase( SECTION,
47 "myfunc.length",
48 0,
49 myfunc.length );
50
51 new TestCase( SECTION,
52 "myfunc.prototype.toString()",
53 "[object Object]",
54 myfunc.prototype.toString() );
55
56 new TestCase( SECTION,
57 "myfunc.prototype.constructor",
58 myfunc,
59 myfunc.prototype.constructor );
60
61 new TestCase( SECTION,
62 "myfunc.arguments",
63 null,
64 myfunc.arguments );
65
66 new TestCase( SECTION,
67 "var OBJ = new MyObject(true); OBJ.valueOf()",
68 true,
69 eval("var OBJ = new MyObject(true); OBJ.valueOf()") );
70
71 new TestCase( SECTION,
72 "OBJ.toString()",
73 "true",
74 OBJ.toString() );
75
76 new TestCase( SECTION,
77 "OBJ.toString = Object.prototype.toString; OBJ.toString()",
78 "[object Object]",
79 eval("OBJ.toString = Object.prototype.toString; OBJ.toString()") );
80
81 new TestCase( SECTION,
82 "MyObject.toString = Object.prototype.toString; MyObject.toString()",
83 "[object Function]",
84 eval("MyObject.toString = Object.prototype.toString; MyObject.toString()") );
85
86 new TestCase( SECTION,
87 "MyObject.length",
88 1,
89 MyObject.length );
90
91 new TestCase( SECTION,
92 "MyObject.prototype.constructor",
93 MyObject,
94 MyObject.prototype.constructor );
95
96 new TestCase( SECTION,
97 "MyObject.arguments",
98 null,
99 MyObject.arguments );
100
101 test();
102
103