1/* The contents of this file are subject to the Netscape Public 2 * License Version 1.1 (the "License"); you may not use this file 3 * except in compliance with the License. You may obtain a copy of 4 * the License at http://www.mozilla.org/NPL/ 5 * 6 * Software distributed under the License is distributed on an "AS 7 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 8 * implied. See the License for the specific language governing 9 * rights and limitations under the License. 10 * 11 * The Original Code is Mozilla Communicator client code, released March 12 * 31, 1998. 13 * 14 * The Initial Developer of the Original Code is Netscape Communications 15 * Corporation. Portions created by Netscape are 16 * Copyright (C) 1998 Netscape Communications Corporation. All 17 * Rights Reserved. 18 * 19 * Contributor(s): 20 * 21 */ 22/** 23 File Name: 11.8.3.js 24 ECMA Section: 11.8.3 The less-than-or-equal operator ( <= ) 25 Description: 26 27 Author: christine@netscape.com 28 Date: 12 november 1997 29*/ 30 var SECTION = "11.8.1"; 31 var VERSION = "ECMA_1"; 32 startTest(); 33 var testcases = getTestCases(); 34 35 writeHeaderToLog( SECTION + " The less-than-or-equal operator ( <= )"); 36 test(); 37 38function test() { 39 for ( tc=0; tc < testcases.length; tc++ ) { 40 testcases[tc].passed = writeTestCaseResult( 41 testcases[tc].expect, 42 testcases[tc].actual, 43 testcases[tc].description +" = "+ 44 testcases[tc].actual ); 45 46 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; 47 } 48 stopTest(); 49 return ( testcases ); 50} 51function getTestCases() { 52 var array = new Array(); 53 var item = 0; 54 55 array[item++] = new TestCase( SECTION, "true <= false", false, true <= false ); 56 array[item++] = new TestCase( SECTION, "false <= true", true, false <= true ); 57 array[item++] = new TestCase( SECTION, "false <= false", true, false <= false ); 58 array[item++] = new TestCase( SECTION, "true <= true", true, true <= true ); 59 60 array[item++] = new TestCase( SECTION, "new Boolean(true) <= new Boolean(true)", true, new Boolean(true) <= new Boolean(true) ); 61 array[item++] = new TestCase( SECTION, "new Boolean(true) <= new Boolean(false)", false, new Boolean(true) <= new Boolean(false) ); 62 array[item++] = new TestCase( SECTION, "new Boolean(false) <= new Boolean(true)", true, new Boolean(false) <= new Boolean(true) ); 63 array[item++] = new TestCase( SECTION, "new Boolean(false) <= new Boolean(false)", true, new Boolean(false) <= new Boolean(false) ); 64 65 array[item++] = new TestCase( SECTION, "new MyObject(Infinity) <= new MyObject(Infinity)", true, new MyObject( Number.POSITIVE_INFINITY ) <= new MyObject( Number.POSITIVE_INFINITY) ); 66 array[item++] = new TestCase( SECTION, "new MyObject(-Infinity) <= new MyObject(Infinity)", true, new MyObject( Number.NEGATIVE_INFINITY ) <= new MyObject( Number.POSITIVE_INFINITY) ); 67 array[item++] = new TestCase( SECTION, "new MyObject(-Infinity) <= new MyObject(-Infinity)", true, new MyObject( Number.NEGATIVE_INFINITY ) <= new MyObject( Number.NEGATIVE_INFINITY) ); 68 69 array[item++] = new TestCase( SECTION, "new MyValueObject(false) <= new MyValueObject(true)", true, new MyValueObject(false) <= new MyValueObject(true) ); 70 array[item++] = new TestCase( SECTION, "new MyValueObject(true) <= new MyValueObject(true)", true, new MyValueObject(true) <= new MyValueObject(true) ); 71 array[item++] = new TestCase( SECTION, "new MyValueObject(false) <= new MyValueObject(false)", true, new MyValueObject(false) <= new MyValueObject(false) ); 72 73 array[item++] = new TestCase( SECTION, "new MyStringObject(false) <= new MyStringObject(true)", true, new MyStringObject(false) <= new MyStringObject(true) ); 74 array[item++] = new TestCase( SECTION, "new MyStringObject(true) <= new MyStringObject(true)", true, new MyStringObject(true) <= new MyStringObject(true) ); 75 array[item++] = new TestCase( SECTION, "new MyStringObject(false) <= new MyStringObject(false)", true, new MyStringObject(false) <= new MyStringObject(false) ); 76 77 array[item++] = new TestCase( SECTION, "Number.NaN <= Number.NaN", false, Number.NaN <= Number.NaN ); 78 array[item++] = new TestCase( SECTION, "0 <= Number.NaN", false, 0 <= Number.NaN ); 79 array[item++] = new TestCase( SECTION, "Number.NaN <= 0", false, Number.NaN <= 0 ); 80 81 array[item++] = new TestCase( SECTION, "0 <= -0", true, 0 <= -0 ); 82 array[item++] = new TestCase( SECTION, "-0 <= 0", true, -0 <= 0 ); 83 84 array[item++] = new TestCase( SECTION, "Infinity <= 0", false, Number.POSITIVE_INFINITY <= 0 ); 85 array[item++] = new TestCase( SECTION, "Infinity <= Number.MAX_VALUE", false, Number.POSITIVE_INFINITY <= Number.MAX_VALUE ); 86 array[item++] = new TestCase( SECTION, "Infinity <= Infinity", true, Number.POSITIVE_INFINITY <= Number.POSITIVE_INFINITY ); 87 88 array[item++] = new TestCase( SECTION, "0 <= Infinity", true, 0 <= Number.POSITIVE_INFINITY ); 89 array[item++] = new TestCase( SECTION, "Number.MAX_VALUE <= Infinity", true, Number.MAX_VALUE <= Number.POSITIVE_INFINITY ); 90 91 array[item++] = new TestCase( SECTION, "0 <= -Infinity", false, 0 <= Number.NEGATIVE_INFINITY ); 92 array[item++] = new TestCase( SECTION, "Number.MAX_VALUE <= -Infinity", false, Number.MAX_VALUE <= Number.NEGATIVE_INFINITY ); 93 array[item++] = new TestCase( SECTION, "-Infinity <= -Infinity", true, Number.NEGATIVE_INFINITY <= Number.NEGATIVE_INFINITY ); 94 95 array[item++] = new TestCase( SECTION, "-Infinity <= 0", true, Number.NEGATIVE_INFINITY <= 0 ); 96 array[item++] = new TestCase( SECTION, "-Infinity <= -Number.MAX_VALUE", true, Number.NEGATIVE_INFINITY <= -Number.MAX_VALUE ); 97 array[item++] = new TestCase( SECTION, "-Infinity <= Number.MIN_VALUE", true, Number.NEGATIVE_INFINITY <= Number.MIN_VALUE ); 98 99 array[item++] = new TestCase( SECTION, "'string' <= 'string'", true, 'string' <= 'string' ); 100 array[item++] = new TestCase( SECTION, "'astring' <= 'string'", true, 'astring' <= 'string' ); 101 array[item++] = new TestCase( SECTION, "'strings' <= 'stringy'", true, 'strings' <= 'stringy' ); 102 array[item++] = new TestCase( SECTION, "'strings' <= 'stringier'", false, 'strings' <= 'stringier' ); 103 array[item++] = new TestCase( SECTION, "'string' <= 'astring'", false, 'string' <= 'astring' ); 104 array[item++] = new TestCase( SECTION, "'string' <= 'strings'", true, 'string' <= 'strings' ); 105 106 return ( array ); 107} 108function MyObject(value) { 109 this.value = value; 110 this.valueOf = new Function( "return this.value" ); 111 this.toString = new Function( "return this.value +''" ); 112} 113function MyValueObject(value) { 114 this.value = value; 115 this.valueOf = new Function( "return this.value" ); 116} 117function MyStringObject(value) { 118 this.value = value; 119 this.toString = new Function( "return this.value +''" ); 120} 121