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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial