michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: michael@0: /** michael@0: * File Name: StrictEquality-001.js michael@0: * ECMA Section: 11.9.6.js michael@0: * Description: michael@0: * michael@0: * Author: christine@netscape.com michael@0: * Date: 4 september 1998 michael@0: */ michael@0: var SECTION = "StrictEquality-001 - 11.9.6"; michael@0: var VERSION = "ECMA_2"; michael@0: var TITLE = "The strict equality operator ( === )"; michael@0: michael@0: startTest(); michael@0: writeHeaderToLog( SECTION + " "+ TITLE); michael@0: michael@0: michael@0: // 1. If Type(x) is different from Type(y) return false michael@0: michael@0: StrictEquality( true, new Boolean(true), false ); michael@0: StrictEquality( new Boolean(), false, false ); michael@0: StrictEquality( "", new String(), false ); michael@0: StrictEquality( new String("hi"), "hi", false ); michael@0: michael@0: // 2. If Type(x) is not Number go to step 9. michael@0: michael@0: // 3. If x is NaN, return false michael@0: StrictEquality( NaN, NaN, false ); michael@0: StrictEquality( NaN, 0, false ); michael@0: michael@0: // 4. If y is NaN, return false. michael@0: StrictEquality( 0, NaN, false ); michael@0: michael@0: // 5. if x is the same number value as y, return true michael@0: michael@0: // 6. If x is +0 and y is -0, return true michael@0: michael@0: // 7. If x is -0 and y is +0, return true michael@0: michael@0: // 8. Return false. michael@0: michael@0: michael@0: // 9. If Type(x) is String, then return true if x and y are exactly michael@0: // the same sequence of characters ( same length and same characters michael@0: // in corresponding positions.) Otherwise return false. michael@0: michael@0: // 10. If Type(x) is Boolean, return true if x and y are both true or michael@0: // both false. otherwise return false. michael@0: michael@0: michael@0: // Return true if x and y refer to the same object. Otherwise return michael@0: // false. michael@0: michael@0: // Return false. michael@0: michael@0: michael@0: test(); michael@0: michael@0: function StrictEquality( x, y, expect ) { michael@0: result = ( x === y ); michael@0: michael@0: new TestCase( michael@0: SECTION, michael@0: x +" === " + y, michael@0: expect, michael@0: result ); michael@0: } michael@0: