Debian Codegraph @

rhino/testsrc/tests/ecma/FunctionObjects/15.3.1.1-3.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-3.js';
7
8 /**
9 File Name: 15.3.1.1-3.js
10 ECMA Section: 15.3.1.1 The Function Constructor Called as a Function
11
12 new Function(p1, p2, ..., pn, body )
13
14 Description: The last argument specifies the body (executable code)
15 of a function; any preceeding arguments sepcify formal
16 parameters.
17
18 See the text for description of this section.
19
20 This test examples from the specification.
21
22 Author: [email protected]
23 Date: 28 october 1997
24
25 */
26 var SECTION = "15.3.1.1-3";
27 var VERSION = "ECMA_1";
28 startTest();
29 var TITLE = "The Function Constructor Called as a Function";
30
31 writeHeaderToLog( SECTION + " "+ TITLE);
32
33 var args = "";
34
35 for ( var i = 0; i < 2000; i++ ) {
36 args += "arg"+i;
37 if ( i != 1999 ) {
38 args += ",";
39 }
40 }
41
42 var s = "";
43
44 for ( var i = 0; i < 2000; i++ ) {
45 s += ".0005";
46 if ( i != 1999 ) {
47 s += ",";
48 }
49 }
50
51 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");
52 MyObject = Function( args, "for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; eval('this.arg'+i +'=arg'+i); };");
53
54 var MY_OB = eval( "MyFunc("+ s +")" );
55
56 new TestCase( SECTION, "MyFunc.length", 2000, MyFunc.length );
57 new TestCase( SECTION, "var MY_OB = eval('MyFunc(s)')", 1, MY_OB );
58 new TestCase( SECTION, "var MY_OB = eval('MyFunc(s)')", 1, eval("var MY_OB = MyFunc("+s+"); MY_OB") );
59
60 new TestCase( SECTION, "MyObject.length", 2000, MyObject.length );
61
62 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") );
63 new TestCase( SECTION, "FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1()", 3, eval("FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1()") );
64 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)") );
65
66 test();