]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma/GlobalObject/15.1.2.1-1.js
1 /* The contents of this file are subject to the Netscape Public
2 * License Version 1.1 (the "License"); you may not use this file
3 * except in compliance with the License. You may obtain a copy of
4 * the License at http://www.mozilla.org/NPL/
6 * Software distributed under the License is distributed on an "AS
7 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8 * implied. See the License for the specific language governing
9 * rights and limitations under the License.
11 * The Original Code is Mozilla Communicator client code, released March
14 * The Initial Developer of the Original Code is Netscape Communications
15 * Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
23 File Name: 15.1.2.1-1.js
24 ECMA Section: 15.1.2.1 eval(x)
26 if x is not a string object, return x.
28 Author: christine@netscape.com
29 Date: 16 september 1997
31 var SECTION
= "15.1.2.1-1" ;
32 var VERSION
= "ECMA_1" ;
34 var TITLE
= "eval(x)" ;
36 var BUGNUMBER
= "111199" ;
38 writeHeaderToLog ( SECTION
+ " " + TITLE
);
40 var testcases
= getTestCases ();
44 function getTestCases () {
45 var array
= new Array ();
48 array
[ item
++] = new TestCase ( SECTION
, "eval.length" , 1 , eval
. length
);
49 array
[ item
++] = new TestCase ( SECTION
, "delete eval.length" , false , delete eval
. length
);
50 array
[ item
++] = new TestCase ( SECTION
, "var PROPS = ''; for ( p in eval ) { PROPS += p }; PROPS" , "" , eval ( "var PROPS = ''; for ( p in eval ) { PROPS += p }; PROPS" ) );
51 array
[ item
++] = new TestCase ( SECTION
, "eval.length = null; eval.length" , 1 , eval ( "eval.length = null; eval.length" ) );
52 // array[item++] = new TestCase( SECTION, "eval.__proto__", Function.prototype, eval.__proto__ );
54 // test cases where argument is not a string. should return the argument.
56 array
[ item
++] = new TestCase ( SECTION
, "eval()" , void 0 , eval () );
57 array
[ item
++] = new TestCase ( SECTION
, "eval(void 0)" , void 0 , eval ( void 0 ) );
58 array
[ item
++] = new TestCase ( SECTION
, "eval(null)" , null , eval ( null ) );
59 array
[ item
++] = new TestCase ( SECTION
, "eval(true)" , true , eval ( true ) );
60 array
[ item
++] = new TestCase ( SECTION
, "eval(false)" , false , eval ( false ) );
62 array
[ item
++] = new TestCase ( SECTION
, "typeof eval(new String('Infinity/-0')" , "object" , typeof eval ( new String ( 'Infinity/-0' )) );
64 array
[ item
++] = new TestCase ( SECTION
, "eval([1,2,3,4,5,6])" , "1,2,3,4,5,6" , "" + eval ([ 1 , 2 , 3 , 4 , 5 , 6 ]) );
65 array
[ item
++] = new TestCase ( SECTION
, "eval(new Array(0,1,2,3)" , "1,2,3" , "" + eval ( new Array ( 1 , 2 , 3 )) );
66 array
[ item
++] = new TestCase ( SECTION
, "eval(1)" , 1 , eval ( 1 ) );
67 array
[ item
++] = new TestCase ( SECTION
, "eval(0)" , 0 , eval ( 0 ) );
68 array
[ item
++] = new TestCase ( SECTION
, "eval(-1)" , - 1 , eval (- 1 ) );
69 array
[ item
++] = new TestCase ( SECTION
, "eval(Number.NaN)" , Number
. NaN
, eval ( Number
. NaN
) );
70 array
[ item
++] = new TestCase ( SECTION
, "eval(Number.MIN_VALUE)" , 5e-308 , eval ( Number
. MIN_VALUE
) );
71 array
[ item
++] = new TestCase ( SECTION
, "eval(-Number.MIN_VALUE)" , - 5e-308 , eval (- Number
. MIN_VALUE
) );
72 array
[ item
++] = new TestCase ( SECTION
, "eval(Number.POSITIVE_INFINITY)" , Number
. POSITIVE_INFINITY
, eval ( Number
. POSITIVE_INFINITY
) );
73 array
[ item
++] = new TestCase ( SECTION
, "eval(Number.NEGATIVE_INFINITY)" , Number
. NEGATIVE_INFINITY
, eval ( Number
. NEGATIVE_INFINITY
) );
74 array
[ item
++] = new TestCase ( SECTION
, "eval( 4294967296 )" , 4294967296 , eval ( 4294967296 ) );
75 array
[ item
++] = new TestCase ( SECTION
, "eval( 2147483648 )" , 2147483648 , eval ( 2147483648 ) );
80 for ( tc
= 0 ; tc
< testcases
. length
; tc
++ ) {
81 testcases
[ tc
]. passed
= writeTestCaseResult (
84 testcases
[ tc
]. description
+ " = " + testcases
[ tc
]. actual
);
86 testcases
[ tc
]. reason
+= ( testcases
[ tc
]. passed
) ? "" : "wrong value " ;