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/
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.
11 * The Original Code is Mozilla Communicator client code, released March
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
24 ECMA Section: 11.8.3 The less-than-or-equal operator ( <= )
27 Author: christine@netscape.com
28 Date: 12 november 1997
30 var SECTION = "11.8.1";
31 var VERSION = "ECMA_1";
33 var testcases = getTestCases();
35 writeHeaderToLog( SECTION + " The less-than-or-equal operator ( <= )");
39 for ( tc=0; tc < testcases.length; tc++ ) {
40 testcases[tc].passed = writeTestCaseResult(
43 testcases[tc].description +" = "+
44 testcases[tc].actual );
46 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
51 function getTestCases() {
52 var array = new Array();
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 );
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) );
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) );
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) );
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) );
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 );
81 array[item++] = new TestCase( SECTION, "0 <= -0", true, 0 <= -0 );
82 array[item++] = new TestCase( SECTION, "-0 <= 0", true, -0 <= 0 );
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 );
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 );
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 );
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 );
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' );
108 function MyObject(value) {
110 this.valueOf = new Function( "return this.value" );
111 this.toString = new Function( "return this.value +''" );
113 function MyValueObject(value) {
115 this.valueOf = new Function( "return this.value" );
117 function MyStringObject(value) {
119 this.toString = new Function( "return this.value +''" );