OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Flags: --allow-natives-syntax |
| 6 |
| 7 assertEquals("1", %ToString(1)); |
| 8 assertEquals("1", %_ToString(1)); |
| 9 |
| 10 assertEquals("0.5", %ToString(.5)); |
| 11 assertEquals("0.5", %_ToString(.5)); |
| 12 |
| 13 assertEquals("null", %ToString(null)); |
| 14 assertEquals("null", %_ToString(null)); |
| 15 |
| 16 assertEquals("true", %ToString(true)); |
| 17 assertEquals("true", %_ToString(true)); |
| 18 |
| 19 assertEquals("false", %ToString(false)); |
| 20 assertEquals("false", %_ToString(false)); |
| 21 |
| 22 assertEquals("undefined", %ToString(undefined)); |
| 23 assertEquals("undefined", %_ToString(undefined)); |
| 24 |
| 25 assertEquals("random text", %ToString("random text")); |
| 26 assertEquals("random text", %_ToString("random text")); |
| 27 |
| 28 assertThrows(function() { %ToString(Symbol.toPrimitive) }, TypeError); |
| 29 assertThrows(function() { %_ToString(Symbol.toPrimitive) }, TypeError); |
| 30 |
| 31 var a = { toString: function() { return "xyz" }}; |
| 32 assertEquals("xyz", %ToString(a)); |
| 33 assertEquals("xyz", %_ToString(a)); |
| 34 |
| 35 var b = { valueOf: function() { return 42 }}; |
| 36 assertEquals("[object Object]", %ToString(b)); |
| 37 assertEquals("[object Object]", %_ToString(b)); |
| 38 |
| 39 var c = { |
| 40 toString: function() { return "x"}, |
| 41 valueOf: function() { return 123 } |
| 42 }; |
| 43 assertEquals("x", %ToString(c)); |
| 44 assertEquals("x", %_ToString(c)); |
| 45 |
| 46 var d = { |
| 47 [Symbol.toPrimitive]: function(hint) { return hint } |
| 48 }; |
| 49 assertEquals("string", %ToString(d)); |
| 50 assertEquals("string", %_ToString(d)); |
OLD | NEW |