blob: d530bfe23dd8e4ef5b76f1fbd942e2fae8c8750f [file] [log] [blame]
utatane.tea@gmail.com8dae6082017-06-12 03:58:23 +00001function shouldBe(actual, expected)
2{
3 if (actual !== expected)
4 throw new Error('bad value: ' + actual);
5}
6
7(function () {
8 function indexOf(array, value)
9 {
10 return array.indexOf(value);
11 }
12 noInline(indexOf);
13
14 var array = [];
15 for (var i = 0; i < 100; ++i)
16 array.push(i);
17
18 for (var i = 0; i < 1e5; ++i)
19 shouldBe(indexOf(array, 42), 42);
20}());
21
22(function () {
23 function indexOf(array, value)
24 {
25 return array.indexOf(value);
26 }
27 noInline(indexOf);
28
29 var array = [];
30 for (var i = 0; i < 100; ++i)
31 array.push(i + 0.5);
32
33 for (var i = 0; i < 1e5; ++i)
34 shouldBe(indexOf(array, 42 + 0.5), 42);
35}());