]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma/Boolean/15.6.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
24 ECMA Section: 15.6.1 The Boolean Function
25 15.6.1.1 Boolean( value )
27 Description: Boolean( value ) should return a Boolean value
28 not a Boolean object) computed by
29 Boolean.toBooleanValue( value)
31 15.6.1.2 Boolean() returns false
33 Author: christine@netscape.com
38 VALUE Argument passed to the Boolean function
39 TYPE typeof VALUE (not used, but helpful in understanding
41 E_RETURN Expected return value of Boolean( VALUE )
43 var SECTION
= "15.6.1";
44 var VERSION
= "ECMA_1";
46 var TITLE
= "The Boolean constructor called as a function: Boolean( value ) and Boolean()";
48 writeHeaderToLog( SECTION
+ " "+ TITLE
);
50 var testcases
= getTestCases();
54 function getTestCases() {
55 var array
= new Array();
58 array
[item
++] = new TestCase( SECTION
, "Boolean(1)", true, Boolean(1) );
59 array
[item
++] = new TestCase( SECTION
, "Boolean(0)", false, Boolean(0) );
60 array
[item
++] = new TestCase( SECTION
, "Boolean(-1)", true, Boolean(-1) );
61 array
[item
++] = new TestCase( SECTION
, "Boolean('1')", true, Boolean("1") );
62 array
[item
++] = new TestCase( SECTION
, "Boolean('0')", true, Boolean("0") );
63 array
[item
++] = new TestCase( SECTION
, "Boolean('-1')", true, Boolean("-1") );
64 array
[item
++] = new TestCase( SECTION
, "Boolean(true)", true, Boolean(true) );
65 array
[item
++] = new TestCase( SECTION
, "Boolean(false)", false, Boolean(false) );
67 array
[item
++] = new TestCase( SECTION
, "Boolean('true')", true, Boolean("true") );
68 array
[item
++] = new TestCase( SECTION
, "Boolean('false')", true, Boolean("false") );
69 array
[item
++] = new TestCase( SECTION
, "Boolean(null)", false, Boolean(null) );
71 array
[item
++] = new TestCase( SECTION
, "Boolean(-Infinity)", true, Boolean(Number
.NEGATIVE_INFINITY
) );
72 array
[item
++] = new TestCase( SECTION
, "Boolean(NaN)", false, Boolean(Number
.NaN
) );
73 array
[item
++] = new TestCase( SECTION
, "Boolean(void(0))", false, Boolean( void(0) ) );
74 array
[item
++] = new TestCase( SECTION
, "Boolean(x=0)", false, Boolean( x
=0 ) );
75 array
[item
++] = new TestCase( SECTION
, "Boolean(x=1)", true, Boolean( x
=1 ) );
76 array
[item
++] = new TestCase( SECTION
, "Boolean(x=false)", false, Boolean( x
=false ) );
77 array
[item
++] = new TestCase( SECTION
, "Boolean(x=true)", true, Boolean( x
=true ) );
78 array
[item
++] = new TestCase( SECTION
, "Boolean(x=null)", false, Boolean( x
=null ) );
79 array
[item
++] = new TestCase( SECTION
, "Boolean()", false, Boolean() );
80 // array[item++] = new TestCase( SECTION, "Boolean(var someVar)", false, Boolean( someVar ) );
85 for ( tc
=0; tc
< testcases
.length
; tc
++ ) {
86 testcases
[tc
].passed
= writeTestCaseResult(
89 testcases
[tc
].description
+" = "+
90 testcases
[tc
].actual
);
92 testcases
[tc
].reason
+= ( testcases
[tc
].passed
) ? "" : "wrong value ";