OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 a = [0, 1]; |
| 8 a["true"] = "true"; |
| 9 a["false"] = "false"; |
| 10 a["null"] = "null"; |
| 11 a["undefined"] = "undefined"; |
| 12 |
| 13 // Ensure we don't accidentially truncate true when used to index arrays. |
| 14 (function() { |
| 15 function f(x) { return a[x]; } |
| 16 |
| 17 assertEquals(0, f(0)); |
| 18 assertEquals(0, f(0)); |
| 19 %OptimizeFunctionOnNextCall(f); |
| 20 assertEquals("true", f(true)); |
| 21 })(); |
| 22 |
| 23 // Ensure we don't accidentially truncate false when used to index arrays. |
| 24 (function() { |
| 25 function f( x) { return a[x]; } |
| 26 |
| 27 assertEquals(0, f(0)); |
| 28 assertEquals(0, f(0)); |
| 29 %OptimizeFunctionOnNextCall(f); |
| 30 assertEquals("false", f(false)); |
| 31 })(); |
| 32 |
| 33 // Ensure we don't accidentially truncate null when used to index arrays. |
| 34 (function() { |
| 35 function f( x) { return a[x]; } |
| 36 |
| 37 assertEquals(0, f(0)); |
| 38 assertEquals(0, f(0)); |
| 39 %OptimizeFunctionOnNextCall(f); |
| 40 assertEquals("null", f(null)); |
| 41 })(); |
| 42 |
| 43 // Ensure we don't accidentially truncate undefined when used to index arrays. |
| 44 (function() { |
| 45 function f( x) { return a[x]; } |
| 46 |
| 47 assertEquals(0, f(0)); |
| 48 assertEquals(0, f(0)); |
| 49 %OptimizeFunctionOnNextCall(f); |
| 50 assertEquals("undefined", f(undefined)); |
| 51 })(); |
OLD | NEW |