]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma/GlobalObject/15.1.2.6.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / mozilla / ecma / GlobalObject / 15.1.2.6.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.6.js
24 ECMA Section: 15.1.2.6 isNaN( x )
25
26 Description: Applies ToNumber to its argument, then returns true if
27 the result isNaN and otherwise returns false.
28
29 Author: christine@netscape.com
30 Date: 28 october 1997
31
32 */
33 var SECTION = "15.1.2.6";
34 var VERSION = "ECMA_1";
35 startTest();
36 var TITLE = "isNaN( x )";
37
38 var BUGNUMBER = "77391";
39
40 writeHeaderToLog( SECTION + " "+ TITLE);
41
42 var testcases = getTestCases();
43
44 test();
45
46
47 function getTestCases() {
48 var array = new Array();
49 var item = 0;
50
51 array[item++] = new TestCase( SECTION, "isNaN.length", 1, isNaN.length );
52 array[item++] = new TestCase( SECTION, "var MYPROPS=''; for ( var p in isNaN ) { MYPROPS+= p }; MYPROPS", "", eval("var MYPROPS=''; for ( var p in isNaN ) { MYPROPS+= p }; MYPROPS") );
53 array[item++] = new TestCase( SECTION, "isNaN.length = null; isNaN.length", 1, eval("isNaN.length=null; isNaN.length") );
54 array[item++] = new TestCase( SECTION, "delete isNaN.length", false, delete isNaN.length );
55 array[item++] = new TestCase( SECTION, "delete isNaN.length; isNaN.length", 1, eval("delete isNaN.length; isNaN.length") );
56
57 // array[item++] = new TestCase( SECTION, "isNaN.__proto__", Function.prototype, isNaN.__proto__ );
58
59 array[item++] = new TestCase( SECTION, "isNaN()", true, isNaN() );
60 array[item++] = new TestCase( SECTION, "isNaN( null )", false, isNaN(null) );
61 array[item++] = new TestCase( SECTION, "isNaN( void 0 )", true, isNaN(void 0) );
62 array[item++] = new TestCase( SECTION, "isNaN( true )", false, isNaN(true) );
63 array[item++] = new TestCase( SECTION, "isNaN( false)", false, isNaN(false) );
64 array[item++] = new TestCase( SECTION, "isNaN( ' ' )", false, isNaN( " " ) );
65
66 array[item++] = new TestCase( SECTION, "isNaN( 0 )", false, isNaN(0) );
67 array[item++] = new TestCase( SECTION, "isNaN( 1 )", false, isNaN(1) );
68 array[item++] = new TestCase( SECTION, "isNaN( 2 )", false, isNaN(2) );
69 array[item++] = new TestCase( SECTION, "isNaN( 3 )", false, isNaN(3) );
70 array[item++] = new TestCase( SECTION, "isNaN( 4 )", false, isNaN(4) );
71 array[item++] = new TestCase( SECTION, "isNaN( 5 )", false, isNaN(5) );
72 array[item++] = new TestCase( SECTION, "isNaN( 6 )", false, isNaN(6) );
73 array[item++] = new TestCase( SECTION, "isNaN( 7 )", false, isNaN(7) );
74 array[item++] = new TestCase( SECTION, "isNaN( 8 )", false, isNaN(8) );
75 array[item++] = new TestCase( SECTION, "isNaN( 9 )", false, isNaN(9) );
76
77 array[item++] = new TestCase( SECTION, "isNaN( '0' )", false, isNaN('0') );
78 array[item++] = new TestCase( SECTION, "isNaN( '1' )", false, isNaN('1') );
79 array[item++] = new TestCase( SECTION, "isNaN( '2' )", false, isNaN('2') );
80 array[item++] = new TestCase( SECTION, "isNaN( '3' )", false, isNaN('3') );
81 array[item++] = new TestCase( SECTION, "isNaN( '4' )", false, isNaN('4') );
82 array[item++] = new TestCase( SECTION, "isNaN( '5' )", false, isNaN('5') );
83 array[item++] = new TestCase( SECTION, "isNaN( '6' )", false, isNaN('6') );
84 array[item++] = new TestCase( SECTION, "isNaN( '7' )", false, isNaN('7') );
85 array[item++] = new TestCase( SECTION, "isNaN( '8' )", false, isNaN('8') );
86 array[item++] = new TestCase( SECTION, "isNaN( '9' )", false, isNaN('9') );
87
88
89 array[item++] = new TestCase( SECTION, "isNaN( 0x0a )", false, isNaN( 0x0a ) );
90 array[item++] = new TestCase( SECTION, "isNaN( 0xaa )", false, isNaN( 0xaa ) );
91 array[item++] = new TestCase( SECTION, "isNaN( 0x0A )", false, isNaN( 0x0A ) );
92 array[item++] = new TestCase( SECTION, "isNaN( 0xAA )", false, isNaN( 0xAA ) );
93
94 array[item++] = new TestCase( SECTION, "isNaN( '0x0a' )", false, isNaN( "0x0a" ) );
95 array[item++] = new TestCase( SECTION, "isNaN( '0xaa' )", false, isNaN( "0xaa" ) );
96 array[item++] = new TestCase( SECTION, "isNaN( '0x0A' )", false, isNaN( "0x0A" ) );
97 array[item++] = new TestCase( SECTION, "isNaN( '0xAA' )", false, isNaN( "0xAA" ) );
98
99 array[item++] = new TestCase( SECTION, "isNaN( 077 )", false, isNaN( 077 ) );
100 array[item++] = new TestCase( SECTION, "isNaN( '077' )", false, isNaN( "077" ) );
101
102
103 array[item++] = new TestCase( SECTION, "isNaN( Number.NaN )", true, isNaN(Number.NaN) );
104 array[item++] = new TestCase( SECTION, "isNaN( Number.POSITIVE_INFINITY )", false, isNaN(Number.POSITIVE_INFINITY) );
105 array[item++] = new TestCase( SECTION, "isNaN( Number.NEGATIVE_INFINITY )", false, isNaN(Number.NEGATIVE_INFINITY) );
106 array[item++] = new TestCase( SECTION, "isNaN( Number.MAX_VALUE )", false, isNaN(Number.MAX_VALUE) );
107 array[item++] = new TestCase( SECTION, "isNaN( Number.MIN_VALUE )", false, isNaN(Number.MIN_VALUE) );
108
109 array[item++] = new TestCase( SECTION, "isNaN( NaN )", true, isNaN(NaN) );
110 array[item++] = new TestCase( SECTION, "isNaN( Infinity )", false, isNaN(Infinity) );
111
112 array[item++] = new TestCase( SECTION, "isNaN( 'Infinity' )", false, isNaN("Infinity") );
113 array[item++] = new TestCase( SECTION, "isNaN( '-Infinity' )", false, isNaN("-Infinity") );
114
115 return ( array );
116 }
117 function test() {
118 for ( tc=0; tc < testcases.length; tc++ ) {
119 testcases[tc].passed = writeTestCaseResult(
120 testcases[tc].expect,
121 testcases[tc].actual,
122 testcases[tc].description +" = "+ testcases[tc].actual );
123 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
124 }
125 stopTest();
126 return ( testcases );
127 }