LibJS: Implement Infinity

This commit is contained in:
Linus Groh 2020-04-02 16:59:01 +01:00 committed by Andreas Kling
parent 40b3203941
commit 543c6e00db
Notes: sideshowbarker 2024-07-19 07:59:06 +09:00
5 changed files with 40 additions and 0 deletions

View file

@ -0,0 +1,27 @@
function assert(x) { if (!x) throw 1; }
try {
assert(Infinity + "" === "Infinity");
assert(-Infinity + "" === "-Infinity");
assert(Infinity === Infinity);
assert(Infinity - 1 === Infinity);
assert(Infinity + 1 === Infinity);
assert(-Infinity === -Infinity);
assert(-Infinity - 1 === -Infinity);
assert(-Infinity + 1 === -Infinity);
assert(1 / Infinity === 0);
assert(1 / -Infinity === 0);
assert(1 / 0 === Infinity);
assert(-1 / 0 === -Infinity);
assert(-100 < Infinity);
assert(0 < Infinity);
assert(100 < Infinity);
assert(-Infinity < Infinity);
assert(-100 > -Infinity);
assert(0 > -Infinity);
assert(100 > -Infinity);
assert(Infinity > -Infinity);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}