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

Unified Diff: test/mjsunit/harmony/private.js

Issue 118553003: Upgrade Symbol implementation to match current ES6 behavior. (Closed) Base URL: git://github.com/v8/v8.git@bleeding_edge
Patch Set: Allow valueOf()/toString() to be called over Symbol values. Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: test/mjsunit/harmony/private.js
diff --git a/test/mjsunit/harmony/private.js b/test/mjsunit/harmony/private.js
index 09cf7f74084082e36ab1d66391022985dffe492c..3608af97c346ffef064b6bf9c8b26b7708a06623 100644
--- a/test/mjsunit/harmony/private.js
+++ b/test/mjsunit/harmony/private.js
@@ -49,7 +49,6 @@ function TestType() {
assertTrue(typeof symbols[i] === "symbol")
assertTrue(%SymbolIsPrivate(symbols[i]))
assertEquals(null, %_ClassOf(symbols[i]))
- assertEquals("Symbol", %_ClassOf(new Symbol(symbols[i])))
assertEquals("Symbol", %_ClassOf(Object(symbols[i])))
}
}
@@ -67,27 +66,19 @@ TestPrototype()
function TestConstructor() {
for (var i in symbols) {
assertSame(Symbol, symbols[i].__proto__.constructor)
+ assertSame(Symbol, Object(symbols[i]).__proto__.constructor)
}
}
TestConstructor()
-function TestName() {
- for (var i in symbols) {
- var name = symbols[i].name
- assertTrue(name === "66")
- }
-}
-TestName()
-
-
function TestToString() {
for (var i in symbols) {
assertThrows(function() { String(symbols[i]) }, TypeError)
assertThrows(function() { symbols[i] + "" }, TypeError)
- assertThrows(function() { symbols[i].toString() }, TypeError)
- assertThrows(function() { (new Symbol(symbols[i])).toString() }, TypeError)
- assertThrows(function() { Object(symbols[i]).toString() }, TypeError)
+ assertDoesNotThrow(function() { symbols[i].toString() })
rossberg 2014/02/14 10:55:30 We should check the actual results here, not just
sof 2014/02/14 14:20:02 Done, carrying over the predicate from symbols.js
+ assertDoesNotThrow(function() { Object(symbols[i]).toString() })
+ assertDoesNotThrow(function() { Symbol.prototype.toString.call(symbols[i]) })
rossberg 2014/02/14 10:55:30 Nit: line length
assertEquals("[object Symbol]", Object.prototype.toString.call(symbols[i]))
}
}
@@ -128,10 +119,10 @@ function TestEquality() {
assertTrue(Object.is(symbols[i], symbols[i]))
assertTrue(symbols[i] === symbols[i])
assertTrue(symbols[i] == symbols[i])
- assertFalse(symbols[i] === new Symbol(symbols[i]))
rossberg 2014/02/14 10:55:30 We should keep the equivalent of the previous test
sof 2014/02/14 14:20:02 Done.
- assertFalse(new Symbol(symbols[i]) === symbols[i])
- assertTrue(symbols[i] == new Symbol(symbols[i]))
- assertTrue(new Symbol(symbols[i]) == symbols[i])
+ assertTrue(symbols[i] === symbols[i].valueOf())
+ assertTrue(symbols[i].valueOf() === symbols[i])
+ assertTrue(symbols[i] == symbols[i].valueOf())
+ assertTrue(symbols[i].valueOf() == symbols[i])
}
// All symbols should be distinct.
@@ -159,7 +150,7 @@ TestEquality()
function TestGet() {
for (var i in symbols) {
- assertThrows(function() { symbols[i].toString() }, TypeError)
+ assertDoesNotThrow(function() { symbols[i].toString() })
rossberg 2014/02/14 10:55:30 Check result.
sof 2014/02/14 14:20:02 Done.
assertEquals(symbols[i], symbols[i].valueOf())
assertEquals(undefined, symbols[i].a)
assertEquals(undefined, symbols[i]["a" + "b"])
@@ -173,7 +164,7 @@ TestGet()
function TestSet() {
for (var i in symbols) {
symbols[i].toString = 0
- assertThrows(function() { symbols[i].toString() }, TypeError)
+ assertDoesNotThrow(function() { symbols[i].toString() })
rossberg 2014/02/14 10:55:30 Check result.
sof 2014/02/14 14:20:02 Done.
symbols[i].valueOf = 0
assertEquals(symbols[i], symbols[i].valueOf())
symbols[i].a = 0

Powered by Google App Engine
This is Rietveld 408576698