utatane.tea@gmail.com | 8dae608 | 2017-06-12 03:58:23 +0000 | [diff] [blame] | 1 | function 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 | }()); |