Browse Source

test case for less-than comparison details

pull/1/head
Sami Vaarala 12 years ago
parent
commit
f7b78d0c43
  1. 154
      testcases/test-dev-compare-lt.js

154
testcases/test-dev-compare-lt.js

@ -0,0 +1,154 @@
/*
* Tests for E5 Section 11.8.5.
*/
function f(x,y) {
print(x < y);
}
/*===
===*/
/* String cases. */
/* FIXME */
/*===
false
false
false
false
false
false
false
false
false
false
false
false
false
===*/
/* Numeric cases involving NaN (steps c and d) */
f(NaN, Number.NEGATIVE_INFINITY);
f(NaN, -1);
f(NaN, -0);
f(NaN, +0);
f(NaN, 1);
f(NaN, Number.POSITIVE_INFINITY);
f(Number.NEGATIVE_INFINITY, NaN);
f(-1, NaN);
f(-0, NaN);
f(+0, NaN);
f(1, NaN);
f(Number.POSITIVE_INFINITY, NaN);
f(NaN, NaN);
/*===
false
false
false
false
false
false
===*/
/* Cases involving same number value (step e) */
f(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY);
f(-1, -1);
f(-0, -0);
f(+0, +0);
f(1, 1);
f(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY);
/*===
false
false
false
false
===*/
/* Zeroes always compare to false: same sign cases are matched by step e,
* different sign cases by steps f and g.
*/
f(-0, -0);
f(-0, +0);
f(+0, -0);
f(+0, +0);
/*===
false
false
false
false
false
false
true
true
true
true
true
false
false
false
false
false
false
false
false
true
true
true
true
true
===*/
/* Infinity cases */
// step h
f(Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY);
f(Number.POSITIVE_INFINITY, -1);
f(Number.POSITIVE_INFINITY, -0);
f(Number.POSITIVE_INFINITY, +0);
f(Number.POSITIVE_INFINITY, 1);
f(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY); // actually covered by step e -> false
// step i
f(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY);
f(-1, Number.POSITIVE_INFINITY);
f(-0, Number.POSITIVE_INFINITY);
f(+0, Number.POSITIVE_INFINITY);
f(1, Number.POSITIVE_INFINITY);
f(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY); // actually covered by step e -> false
// step j
f(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY); // actually covered by step e -> false
f(-1, Number.NEGATIVE_INFINITY);
f(-0, Number.NEGATIVE_INFINITY);
f(+0, Number.NEGATIVE_INFINITY);
f(1, Number.NEGATIVE_INFINITY);
f(Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY);
// step k
f(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY); // actually covered by step e -> false
f(Number.NEGATIVE_INFINITY, -1);
f(Number.NEGATIVE_INFINITY, -0);
f(Number.NEGATIVE_INFINITY, +0);
f(Number.NEGATIVE_INFINITY, 1);
f(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY);
/*===
true
false
===*/
/* Normal number cases */
f(-1, 1);
f(1, -1);
Loading…
Cancel
Save