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: 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
33
var SECTION = "11.4.9";
34
var VERSION = "ECMA_1";
36
var TITLE = "Logical NOT operator (!)";
38
writeHeaderToLog( SECTION + " "+ TITLE);
42
var testcases = new Array();
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) );
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)) );
78
for ( tc = 0; tc < testcases.length; tc++ ) {
79
testcases[tc].passed = writeTestCaseResult(
82
testcases[tc].description +" = "+ testcases[tc].actual );
84
testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "
88
// all tests must return a boolean value