Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(200)

Side by Side Diff: test/mjsunit/harmony/to-string.js

Issue 1319973007: [runtime] Add %ToString and %_ToString and remove the TO_STRING builtin. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/x64/interface-descriptors-x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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));
OLDNEW
« no previous file with comments | « src/x64/interface-descriptors-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698