]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma/Expressions/11.8.1.js
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.1 The less-than operator ( < )
28 Author: christine@netscape.com
29 Date: 12 november 1997
31 var SECTION
= "11.8.1";
32 var VERSION
= "ECMA_1";
34 var testcases
= getTestCases();
36 writeHeaderToLog( SECTION
+ " The less-than operator ( < )");
40 for ( tc
=0; tc
< testcases
.length
; tc
++ ) {
41 testcases
[tc
].passed
= writeTestCaseResult(
44 testcases
[tc
].description
+" = "+
45 testcases
[tc
].actual
);
47 testcases
[tc
].reason
+= ( testcases
[tc
].passed
) ? "" : "wrong value ";
52 function getTestCases() {
53 var array
= new Array();
56 array
[item
++] = new TestCase( SECTION
, "true < false", false, true < false );
57 array
[item
++] = new TestCase( SECTION
, "false < true", true, false < true );
58 array
[item
++] = new TestCase( SECTION
, "false < false", false, false < false );
59 array
[item
++] = new TestCase( SECTION
, "true < true", false, true < true );
61 array
[item
++] = new TestCase( SECTION
, "new Boolean(true) < new Boolean(true)", false, new Boolean(true) < new Boolean(true) );
62 array
[item
++] = new TestCase( SECTION
, "new Boolean(true) < new Boolean(false)", false, new Boolean(true) < new Boolean(false) );
63 array
[item
++] = new TestCase( SECTION
, "new Boolean(false) < new Boolean(true)", true, new Boolean(false) < new Boolean(true) );
64 array
[item
++] = new TestCase( SECTION
, "new Boolean(false) < new Boolean(false)", false, new Boolean(false) < new Boolean(false) );
66 array
[item
++] = new TestCase( SECTION
, "new MyObject(Infinity) < new MyObject(Infinity)", false, new MyObject( Number
.POSITIVE_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
.POSITIVE_INFINITY
) );
68 array
[item
++] = new TestCase( SECTION
, "new MyObject(-Infinity) < new MyObject(-Infinity)", false, new MyObject( Number
.NEGATIVE_INFINITY
) < new MyObject( Number
.NEGATIVE_INFINITY
) );
70 array
[item
++] = new TestCase( SECTION
, "new MyValueObject(false) < new MyValueObject(true)", true, new MyValueObject(false) < new MyValueObject(true) );
71 array
[item
++] = new TestCase( SECTION
, "new MyValueObject(true) < new MyValueObject(true)", false, new MyValueObject(true) < new MyValueObject(true) );
72 array
[item
++] = new TestCase( SECTION
, "new MyValueObject(false) < new MyValueObject(false)", false, new MyValueObject(false) < new MyValueObject(false) );
74 array
[item
++] = new TestCase( SECTION
, "new MyStringObject(false) < new MyStringObject(true)", true, new MyStringObject(false) < new MyStringObject(true) );
75 array
[item
++] = new TestCase( SECTION
, "new MyStringObject(true) < new MyStringObject(true)", false, new MyStringObject(true) < new MyStringObject(true) );
76 array
[item
++] = new TestCase( SECTION
, "new MyStringObject(false) < new MyStringObject(false)", false, new MyStringObject(false) < new MyStringObject(false) );
78 array
[item
++] = new TestCase( SECTION
, "Number.NaN < Number.NaN", false, Number
.NaN
< Number
.NaN
);
79 array
[item
++] = new TestCase( SECTION
, "0 < Number.NaN", false, 0 < Number
.NaN
);
80 array
[item
++] = new TestCase( SECTION
, "Number.NaN < 0", false, Number
.NaN
< 0 );
82 array
[item
++] = new TestCase( SECTION
, "0 < -0", false, 0 < -0 );
83 array
[item
++] = new TestCase( SECTION
, "-0 < 0", false, -0 < 0 );
85 array
[item
++] = new TestCase( SECTION
, "Infinity < 0", false, Number
.POSITIVE_INFINITY
< 0 );
86 array
[item
++] = new TestCase( SECTION
, "Infinity < Number.MAX_VALUE", false, Number
.POSITIVE_INFINITY
< Number
.MAX_VALUE
);
87 array
[item
++] = new TestCase( SECTION
, "Infinity < Infinity", false, Number
.POSITIVE_INFINITY
< Number
.POSITIVE_INFINITY
);
89 array
[item
++] = new TestCase( SECTION
, "0 < Infinity", true, 0 < Number
.POSITIVE_INFINITY
);
90 array
[item
++] = new TestCase( SECTION
, "Number.MAX_VALUE < Infinity", true, Number
.MAX_VALUE
< Number
.POSITIVE_INFINITY
);
92 array
[item
++] = new TestCase( SECTION
, "0 < -Infinity", false, 0 < Number
.NEGATIVE_INFINITY
);
93 array
[item
++] = new TestCase( SECTION
, "Number.MAX_VALUE < -Infinity", false, Number
.MAX_VALUE
< Number
.NEGATIVE_INFINITY
);
94 array
[item
++] = new TestCase( SECTION
, "-Infinity < -Infinity", false, Number
.NEGATIVE_INFINITY
< Number
.NEGATIVE_INFINITY
);
96 array
[item
++] = new TestCase( SECTION
, "-Infinity < 0", true, Number
.NEGATIVE_INFINITY
< 0 );
97 array
[item
++] = new TestCase( SECTION
, "-Infinity < -Number.MAX_VALUE", true, Number
.NEGATIVE_INFINITY
< -Number
.MAX_VALUE
);
98 array
[item
++] = new TestCase( SECTION
, "-Infinity < Number.MIN_VALUE", true, Number
.NEGATIVE_INFINITY
< Number
.MIN_VALUE
);
100 array
[item
++] = new TestCase( SECTION
, "'string' < 'string'", false, 'string' < 'string' );
101 array
[item
++] = new TestCase( SECTION
, "'astring' < 'string'", true, 'astring' < 'string' );
102 array
[item
++] = new TestCase( SECTION
, "'strings' < 'stringy'", true, 'strings' < 'stringy' );
103 array
[item
++] = new TestCase( SECTION
, "'strings' < 'stringier'", false, 'strings' < 'stringier' );
104 array
[item
++] = new TestCase( SECTION
, "'string' < 'astring'", false, 'string' < 'astring' );
105 array
[item
++] = new TestCase( SECTION
, "'string' < 'strings'", true, 'string' < 'strings' );
109 function MyObject(value
) {
111 this.valueOf
= new Function( "return this.value" );
112 this.toString
= new Function( "return this.value +''" );
114 function MyValueObject(value
) {
116 this.valueOf
= new Function( "return this.value" );
118 function MyStringObject(value
) {
120 this.toString
= new Function( "return this.value +''" );