initial import
[vuplus_webkit] / Source / JavaScriptCore / 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/
5  *
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.
10  *
11  * The Original Code is Mozilla Communicator client code, released March
12  * 31, 1998.
13  *
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
17  * Rights Reserved.
18  *
19  * Contributor(s): 
20  * 
21  */
22 /**
23     File Name:          15.1.2.1-1.js
24     ECMA Section:       15.1.2.1 eval(x)
25
26                         if x is not a string object, return x.
27     Description:
28     Author:             christine@netscape.com
29     Date:               16 september 1997
30 */
31     var SECTION = "15.1.2.1-1";
32     var VERSION = "ECMA_1";
33     startTest();
34     var TITLE   = "eval(x)";
35
36     var BUGNUMBER = "111199";
37
38     writeHeaderToLog( SECTION + " "+ TITLE);
39
40     var testcases = getTestCases();
41
42     test();
43
44 function getTestCases() {
45     var array = new Array();
46     var item = 0;
47
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__ );
53
54     // test cases where argument is not a string.  should return the argument.
55
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 ) );
61
62     array[item++] = new TestCase( SECTION,     "typeof eval(new String('Infinity/-0')", "object",                   typeof eval(new String('Infinity/-0')) );
63
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) );
76
77     return ( array );
78 }
79 function test() {
80     for ( tc=0; tc < testcases.length; tc++ ) {
81         testcases[tc].passed = writeTestCaseResult(
82                             testcases[tc].expect,
83                             testcases[tc].actual,
84                             testcases[tc].description +" = "+ testcases[tc].actual );
85
86         testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
87     }
88
89     stopTest();
90     return ( testcases );
91 }