js/src/tests/ecma_2/Expressions/StrictEquality-001.js

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:2a1994f7783e
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
7 /**
8 * File Name: StrictEquality-001.js
9 * ECMA Section: 11.9.6.js
10 * Description:
11 *
12 * Author: christine@netscape.com
13 * Date: 4 september 1998
14 */
15 var SECTION = "StrictEquality-001 - 11.9.6";
16 var VERSION = "ECMA_2";
17 var TITLE = "The strict equality operator ( === )";
18
19 startTest();
20 writeHeaderToLog( SECTION + " "+ TITLE);
21
22
23 // 1. If Type(x) is different from Type(y) return false
24
25 StrictEquality( true, new Boolean(true), false );
26 StrictEquality( new Boolean(), false, false );
27 StrictEquality( "", new String(), false );
28 StrictEquality( new String("hi"), "hi", false );
29
30 // 2. If Type(x) is not Number go to step 9.
31
32 // 3. If x is NaN, return false
33 StrictEquality( NaN, NaN, false );
34 StrictEquality( NaN, 0, false );
35
36 // 4. If y is NaN, return false.
37 StrictEquality( 0, NaN, false );
38
39 // 5. if x is the same number value as y, return true
40
41 // 6. If x is +0 and y is -0, return true
42
43 // 7. If x is -0 and y is +0, return true
44
45 // 8. Return false.
46
47
48 // 9. If Type(x) is String, then return true if x and y are exactly
49 // the same sequence of characters ( same length and same characters
50 // in corresponding positions.) Otherwise return false.
51
52 // 10. If Type(x) is Boolean, return true if x and y are both true or
53 // both false. otherwise return false.
54
55
56 // Return true if x and y refer to the same object. Otherwise return
57 // false.
58
59 // Return false.
60
61
62 test();
63
64 function StrictEquality( x, y, expect ) {
65 result = ( x === y );
66
67 new TestCase(
68 SECTION,
69 x +" === " + y,
70 expect,
71 result );
72 }
73

mercurial