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

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

Issue 1319133002: [es6] Implement spec compliant ToName (actually ToPropertyKey). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@ToPrimitive
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/v8natives.js ('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", %ToName(1));
8 assertEquals("1", %_ToName(1));
9
10 assertEquals("0.5", %ToName(.5));
11 assertEquals("0.5", %_ToName(.5));
12
13 assertEquals("null", %ToName(null));
14 assertEquals("null", %_ToName(null));
15
16 assertEquals("true", %ToName(true));
17 assertEquals("true", %_ToName(true));
18
19 assertEquals("false", %ToName(false));
20 assertEquals("false", %_ToName(false));
21
22 assertEquals("undefined", %ToName(undefined));
23 assertEquals("undefined", %_ToName(undefined));
24
25 assertEquals("random text", %ToName("random text"));
26 assertEquals("random text", %_ToName("random text"));
27
28 assertEquals(Symbol.toPrimitive, %ToName(Symbol.toPrimitive));
29 assertEquals(Symbol.toPrimitive, %_ToName(Symbol.toPrimitive));
30
31 var a = { toString: function() { return "xyz" }};
32 assertEquals("xyz", %ToName(a));
33 assertEquals("xyz", %_ToName(a));
34
35 var b = { valueOf: function() { return 42 }};
36 assertEquals("[object Object]", %ToName(b));
37 assertEquals("[object Object]", %_ToName(b));
38
39 var c = {
40 toString: function() { return "x"},
41 valueOf: function() { return 123 }
42 };
43 assertEquals("x", %ToName(c));
44 assertEquals("x", %_ToName(c));
45
46 var d = {
47 [Symbol.toPrimitive]: function(hint) { return hint }
48 };
49 assertEquals("string", %ToName(d));
50 assertEquals("string", %_ToName(d));
OLDNEW
« no previous file with comments | « src/v8natives.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698