Home | History | Annotate | Download | only in Expressions
      1 /**
      2  *  File Name:          StrictEquality-001.js
      3  *  ECMA Section:       11.9.6.js
      4  *  Description:
      5  *
      6  *  Author:             christine (at) netscape.com
      7  *  Date:               4 september 1998
      8  */
      9     var SECTION = "StrictEquality-001 - 11.9.6";
     10     var VERSION = "ECMA_2";
     11     var TITLE   =  "The strict equality operator ( === )";
     12 
     13     startTest();
     14     writeHeaderToLog( SECTION + " "+ TITLE);
     15 
     16     var tc = 0;
     17     var testcases = new Array();
     18 
     19 
     20     // 1. If Type(x) is different from Type(y) return false
     21 
     22     StrictEquality( true, new Boolean(true), false );
     23     StrictEquality( new Boolean(), false, false );
     24     StrictEquality( "", new String(),    false );
     25     StrictEquality( new String("hi"), "hi", false );
     26 
     27     // 2. If Type(x) is not Number go to step 9.
     28 
     29     // 3. If x is NaN, return false
     30     StrictEquality( NaN, NaN,   false );
     31     StrictEquality( NaN, 0,     false );
     32 
     33     // 4. If y is NaN, return false.
     34     StrictEquality( 0,  NaN,    false );
     35 
     36     // 5. if x is the same number value as y, return true
     37 
     38     // 6. If x is +0 and y is -0, return true
     39 
     40     // 7. If x is -0 and y is +0, return true
     41 
     42     // 8. Return false.
     43 
     44 
     45     // 9.  If Type(x) is String, then return true if x and y are exactly
     46     //  the same sequence of characters ( same length and same characters
     47     //  in corresponding positions.) Otherwise return false.
     48 
     49     //  10. If Type(x) is Boolean, return true if x and y are both true or
     50     //  both false. otherwise return false.
     51 
     52 
     53     //  Return true if x and y refer to the same object.  Otherwise return
     54     //  false.
     55 
     56     // Return false.
     57 
     58 
     59     test();
     60 
     61 function StrictEquality( x, y, expect ) {
     62     result = ( x === y );
     63 
     64     testcases[tc++] = new TestCase(
     65         SECTION,
     66         x +" === " + y,
     67         expect,
     68         result );
     69 }
     70 
     71