OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --allow-natives-syntax | 5 // Flags: --allow-natives-syntax |
6 | 6 |
7 assertEquals("1", %ToName(1)); | 7 assertEquals("1", %ToName(1)); |
8 assertEquals("1", %_ToName(1)); | |
9 | 8 |
10 assertEquals("0.5", %ToName(.5)); | 9 assertEquals("0.5", %ToName(.5)); |
11 assertEquals("0.5", %_ToName(.5)); | |
12 | 10 |
13 assertEquals("null", %ToName(null)); | 11 assertEquals("null", %ToName(null)); |
14 assertEquals("null", %_ToName(null)); | |
15 | 12 |
16 assertEquals("true", %ToName(true)); | 13 assertEquals("true", %ToName(true)); |
17 assertEquals("true", %_ToName(true)); | |
18 | 14 |
19 assertEquals("false", %ToName(false)); | 15 assertEquals("false", %ToName(false)); |
20 assertEquals("false", %_ToName(false)); | |
21 | 16 |
22 assertEquals("undefined", %ToName(undefined)); | 17 assertEquals("undefined", %ToName(undefined)); |
23 assertEquals("undefined", %_ToName(undefined)); | |
24 | 18 |
25 assertEquals("random text", %ToName("random text")); | 19 assertEquals("random text", %ToName("random text")); |
26 assertEquals("random text", %_ToName("random text")); | |
27 | 20 |
28 assertEquals(Symbol.toPrimitive, %ToName(Symbol.toPrimitive)); | 21 assertEquals(Symbol.toPrimitive, %ToName(Symbol.toPrimitive)); |
29 assertEquals(Symbol.toPrimitive, %_ToName(Symbol.toPrimitive)); | |
30 | 22 |
31 var a = { toString: function() { return "xyz" }}; | 23 var a = { toString: function() { return "xyz" }}; |
32 assertEquals("xyz", %ToName(a)); | 24 assertEquals("xyz", %ToName(a)); |
33 assertEquals("xyz", %_ToName(a)); | |
34 | 25 |
35 var b = { valueOf: function() { return 42 }}; | 26 var b = { valueOf: function() { return 42 }}; |
36 assertEquals("[object Object]", %ToName(b)); | 27 assertEquals("[object Object]", %ToName(b)); |
37 assertEquals("[object Object]", %_ToName(b)); | |
38 | 28 |
39 var c = { | 29 var c = { |
40 toString: function() { return "x"}, | 30 toString: function() { return "x"}, |
41 valueOf: function() { return 123 } | 31 valueOf: function() { return 123 } |
42 }; | 32 }; |
43 assertEquals("x", %ToName(c)); | 33 assertEquals("x", %ToName(c)); |
44 assertEquals("x", %_ToName(c)); | |
45 | 34 |
46 var d = { | 35 var d = { |
47 [Symbol.toPrimitive]: function(hint) { return hint } | 36 [Symbol.toPrimitive]: function(hint) { return hint } |
48 }; | 37 }; |
49 assertEquals("string", %ToName(d)); | 38 assertEquals("string", %ToName(d)); |
50 assertEquals("string", %_ToName(d)); | |
51 | 39 |
52 var e = new Date(0); | 40 var e = new Date(0); |
53 assertEquals(e.toString(), %ToName(e)); | 41 assertEquals(e.toString(), %ToName(e)); |
54 assertEquals(e.toString(), %_ToName(e)); | |
OLD | NEW |