OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Flags: --allow-natives-syntax |
| 6 |
| 7 var obj = {}; |
| 8 |
| 9 function f(v) { |
| 10 var v1 = -(4/3); |
| 11 var v2 = 1; |
| 12 var arr = new Array(+0, true, 0, -0, false, undefined, null, "0", obj, v1, -(4
/3), -1.3333333333333, "str", v2, 1, false); |
| 13 assertEquals(10, arr.lastIndexOf(-(4/3))); |
| 14 assertEquals(9, arr.indexOf(-(4/3))); |
| 15 |
| 16 assertEquals(10, arr.lastIndexOf(v)); |
| 17 assertEquals(9, arr.indexOf(v)); |
| 18 |
| 19 assertEquals(8, arr.lastIndexOf(obj)); |
| 20 assertEquals(8, arr.indexOf(obj)); |
| 21 } |
| 22 |
| 23 function g(v, x, index) { |
| 24 var arr = new Array({}, x-1.1, x-2, x-3.1); |
| 25 assertEquals(index, arr.indexOf(0)); |
| 26 assertEquals(index, arr.lastIndexOf(0)); |
| 27 |
| 28 assertEquals(index, arr.indexOf(v)); |
| 29 assertEquals(index, arr.lastIndexOf(v)); |
| 30 } |
| 31 |
| 32 f(-(4/3)); |
| 33 f(-(4/3)); |
| 34 %OptimizeFunctionOnNextCall(f); |
| 35 f(-(4/3)); |
| 36 |
| 37 g(0, 2, 2); |
| 38 g(0, 3.1, 3); |
| 39 %OptimizeFunctionOnNextCall(g); |
| 40 g(0, 1.1, 1); |
OLD | NEW |