[JSC] Implement isFinite / isNaN in JS and make DFG ToNumber accept non number values
[WebKit-https.git] / Source / JavaScriptCore / tests / stress / to-number-basics.js
1 function shouldBe(actual, expected) {
2     if (actual !== expected)
3         throw new Error(`bad value: ${String(actual)}`);
4 }
5
6 function test1(value)
7 {
8     return Number(value) <= 42;
9 }
10 noInline(test1);
11
12 // Int32.
13 for (var i = 0; i < 1e4; ++i)
14     shouldBe(test1(42), true);
15
16 // Doubles.
17 for (var i = 0; i < 1e4; ++i)
18     shouldBe(test1(42.195), false);
19
20 // Non numbers.
21 for (var i = 0; i < 1e4; ++i)
22     shouldBe(test1("Hello"), false);