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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma_2/Expressions/StrictEquality-001.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,73 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +
    1.10 +/**
    1.11 + *  File Name:          StrictEquality-001.js
    1.12 + *  ECMA Section:       11.9.6.js
    1.13 + *  Description:
    1.14 + *
    1.15 + *  Author:             christine@netscape.com
    1.16 + *  Date:               4 september 1998
    1.17 + */
    1.18 +var SECTION = "StrictEquality-001 - 11.9.6";
    1.19 +var VERSION = "ECMA_2";
    1.20 +var TITLE   =  "The strict equality operator ( === )";
    1.21 +
    1.22 +startTest();
    1.23 +writeHeaderToLog( SECTION + " "+ TITLE);
    1.24 +
    1.25 +
    1.26 +// 1. If Type(x) is different from Type(y) return false
    1.27 +
    1.28 +StrictEquality( true, new Boolean(true), false );
    1.29 +StrictEquality( new Boolean(), false, false );
    1.30 +StrictEquality( "", new String(),    false );
    1.31 +StrictEquality( new String("hi"), "hi", false );
    1.32 +
    1.33 +// 2. If Type(x) is not Number go to step 9.
    1.34 +
    1.35 +// 3. If x is NaN, return false
    1.36 +StrictEquality( NaN, NaN,   false );
    1.37 +StrictEquality( NaN, 0,     false );
    1.38 +
    1.39 +// 4. If y is NaN, return false.
    1.40 +StrictEquality( 0,  NaN,    false );
    1.41 +
    1.42 +// 5. if x is the same number value as y, return true
    1.43 +
    1.44 +// 6. If x is +0 and y is -0, return true
    1.45 +
    1.46 +// 7. If x is -0 and y is +0, return true
    1.47 +
    1.48 +// 8. Return false.
    1.49 +
    1.50 +
    1.51 +// 9.  If Type(x) is String, then return true if x and y are exactly
    1.52 +//  the same sequence of characters ( same length and same characters
    1.53 +//  in corresponding positions.) Otherwise return false.
    1.54 +
    1.55 +//  10. If Type(x) is Boolean, return true if x and y are both true or
    1.56 +//  both false. otherwise return false.
    1.57 +
    1.58 +
    1.59 +//  Return true if x and y refer to the same object.  Otherwise return
    1.60 +//  false.
    1.61 +
    1.62 +// Return false.
    1.63 +
    1.64 +
    1.65 +test();
    1.66 +
    1.67 +function StrictEquality( x, y, expect ) {
    1.68 +  result = ( x === y );
    1.69 +
    1.70 +  new TestCase(
    1.71 +    SECTION,
    1.72 +    x +" === " + y,
    1.73 +    expect,
    1.74 +    result );
    1.75 +}
    1.76 +

mercurial