yusukesuzuki@slowstart.org | 6f44821 | 2018-09-26 05:16:22 +0000 | [diff] [blame] | 1 | function shouldBe(actual, expected) { |
| 2 | if (actual !== expected) |
| 3 | throw new Error('bad value: ' + actual); |
| 4 | } |
| 5 | |
| 6 | { |
| 7 | let array = [42.195, -0.0]; |
| 8 | shouldBe(array.lastIndexOf(0), 1); |
| 9 | shouldBe(array.lastIndexOf(-0), 1); |
| 10 | } |
| 11 | { |
| 12 | let array = [42.195, 0, -0.0]; |
| 13 | shouldBe(array.lastIndexOf(0), 2); |
| 14 | shouldBe(array.lastIndexOf(-0), 2); |
| 15 | } |
| 16 | { |
| 17 | let array = [42, 0]; |
| 18 | shouldBe(array.lastIndexOf(0), 1); |
| 19 | shouldBe(array.lastIndexOf(-0), 1); |
| 20 | } |
| 21 | { |
| 22 | let array = [42, 0, 44]; |
| 23 | shouldBe(array.lastIndexOf(0), 1); |
| 24 | shouldBe(array.lastIndexOf(-0), 1); |
| 25 | } |