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:          11.4.9.js
24    ECMA Section:       11.4.9 Logical NOT Operator (!)
25    Description:        if the ToBoolean( VALUE ) result is true, return
26                        true.  else return false.
27    Author:             christine@netscape.com
28    Date:               7 july 1997
29
30    Static variables:
31        none
32*/
33    var SECTION = "11.4.9";
34    var VERSION = "ECMA_1";
35    startTest();
36    var TITLE   = "Logical NOT operator (!)";
37
38    writeHeaderToLog( SECTION + " "+ TITLE);
39
40//    version("130")
41
42    var testcases = new Array();
43
44    testcases[tc++] = new TestCase( SECTION,   "!(null)",                true,   !(null) );
45    testcases[tc++] = new TestCase( SECTION,   "!(var x)",               true,   !(eval("var x")) );
46    testcases[tc++] = new TestCase( SECTION,   "!(void 0)",              true,   !(void 0) );
47
48    testcases[tc++] = new TestCase( SECTION,   "!(false)",               true,   !(false) );
49    testcases[tc++] = new TestCase( SECTION,   "!(true)",                false,  !(true) );
50    testcases[tc++] = new TestCase( SECTION,   "!()",                    true,   !(eval()) );
51    testcases[tc++] = new TestCase( SECTION,   "!(0)",                   true,   !(0) );
52    testcases[tc++] = new TestCase( SECTION,   "!(-0)",                  true,   !(-0) );
53    testcases[tc++] = new TestCase( SECTION,   "!(NaN)",                 true,   !(Number.NaN) );
54    testcases[tc++] = new TestCase( SECTION,   "!(Infinity)",            false,  !(Number.POSITIVE_INFINITY) );
55    testcases[tc++] = new TestCase( SECTION,   "!(-Infinity)",           false,  !(Number.NEGATIVE_INFINITY) );
56    testcases[tc++] = new TestCase( SECTION,   "!(Math.PI)",             false,  !(Math.PI) );
57    testcases[tc++] = new TestCase( SECTION,   "!(1)",                   false,  !(1) );
58    testcases[tc++] = new TestCase( SECTION,   "!(-1)",                  false,  !(-1) );
59    testcases[tc++] = new TestCase( SECTION,   "!('')",                  true,   !("") );
60    testcases[tc++] = new TestCase( SECTION,   "!('\t')",                false,  !("\t") );
61    testcases[tc++] = new TestCase( SECTION,   "!('0')",                 false,  !("0") );
62    testcases[tc++] = new TestCase( SECTION,   "!('string')",            false,  !("string") );
63    testcases[tc++] = new TestCase( SECTION,   "!(new String(''))",      false,  !(new String("")) );
64    testcases[tc++] = new TestCase( SECTION,   "!(new String('string'))",    false,  !(new String("string")) );
65    testcases[tc++] = new TestCase( SECTION,   "!(new String())",        false,  !(new String()) );
66    testcases[tc++] = new TestCase( SECTION,   "!(new Boolean(true))",   false,   !(new Boolean(true)) );
67    testcases[tc++] = new TestCase( SECTION,   "!(new Boolean(false))",  false,   !(new Boolean(false)) );
68    testcases[tc++] = new TestCase( SECTION,   "!(new Array())",         false,  !(new Array()) );
69    testcases[tc++] = new TestCase( SECTION,   "!(new Array(1,2,3)",     false,  !(new Array(1,2,3)) );
70    testcases[tc++] = new TestCase( SECTION,   "!(new Number())",        false,  !(new Number()) );
71    testcases[tc++] = new TestCase( SECTION,   "!(new Number(0))",       false,  !(new Number(0)) );
72    testcases[tc++] = new TestCase( SECTION,   "!(new Number(NaN))",     false,  !(new Number(Number.NaN)) );
73    testcases[tc++] = new TestCase( SECTION,   "!(new Number(Infinity))", false, !(new Number(Number.POSITIVE_INFINITY)) );
74
75    test();
76
77function test() {
78        for ( tc = 0; tc < testcases.length; tc++ ) {
79            testcases[tc].passed = writeTestCaseResult(
80                    testcases[tc].expect,
81                    testcases[tc].actual,
82                    testcases[tc].description +" = "+ testcases[tc].actual );
83
84            testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "
85        }
86        stopTest();
87
88    //  all tests must return a boolean value
89        return ( testcases );
90}
91