Index: test/mjsunit/harmony/symbols.js |
diff --git a/test/mjsunit/harmony/symbols.js b/test/mjsunit/harmony/symbols.js |
index 3fcd06dfdca985fcd81abd8630cb8ededa8fe0d7..ce02a05ace787196eb5971e416d6601beafa55c7 100644 |
--- a/test/mjsunit/harmony/symbols.js |
+++ b/test/mjsunit/harmony/symbols.js |
@@ -273,7 +273,7 @@ function TestKeyGet(obj) { |
} |
-function TestKeyHas() { |
+function TestKeyHas(obj) { |
for (var i in symbols) { |
assertTrue(symbols[i] in obj) |
assertTrue(Object.hasOwnProperty.call(obj, symbols[i])) |
@@ -298,6 +298,15 @@ function TestKeyNames(obj) { |
} |
+function TestGetOwnPropertySymbols(obj) { |
+ var syms = Object.getOwnPropertySymbols(obj) |
+ assertEquals(syms.length, symbols.length) |
+ for (var i in syms) { |
+ assertEquals("symbol", typeof syms[i]) |
+ } |
+} |
+ |
+ |
function TestKeyDescriptor(obj) { |
for (var i in symbols) { |
var desc = Object.getOwnPropertyDescriptor(obj, symbols[i]); |
@@ -331,6 +340,7 @@ for (var i in objs) { |
TestKeyHas(obj) |
TestKeyEnum(obj) |
TestKeyNames(obj) |
+ TestGetOwnPropertySymbols(obj) |
TestKeyDescriptor(obj) |
TestKeyDelete(obj) |
} |
@@ -350,3 +360,44 @@ function TestCachedKeyAfterScavenge() { |
} |
} |
TestCachedKeyAfterScavenge(); |
+ |
+ |
+function TestGetOwnPropertySymbolsWithProto() { |
+ // We need to be have fast properties to have insertion order for property |
+ // keys. The current limit is currently 30 properties. |
+ var syms = symbols.slice(0, 30); |
+ var proto = {} |
+ var object = Object.create(proto) |
+ for (var i = 0; i < syms.length; i++) { |
+ // Even on object, odd on proto. |
+ if (i % 2) { |
+ proto[syms[i]] = i |
+ } else { |
+ object[syms[i]] = i |
+ } |
+ } |
+ |
+ assertTrue(%HasFastProperties(object)); |
+ |
+ var objectOwnSymbols = Object.getOwnPropertySymbols(object) |
+ assertEquals(objectOwnSymbols.length, syms.length / 2) |
+ |
+ for (var i = 0; i < objectOwnSymbols.length; i++) { |
+ assertEquals(objectOwnSymbols[i], syms[i * 2]) |
+ } |
+} |
+TestGetOwnPropertySymbolsWithProto() |
+ |
+ |
+function TestGetOwnPropertySymbolsWithPrivateSymbols() { |
+ var privateSymbol = %CreatePrivateSymbol("private") |
+ var publicSymbol = Symbol() |
+ var publicSymbol2 = Symbol() |
+ var obj = {} |
+ obj[publicSymbol] = 1 |
+ obj[privateSymbol] = 2 |
+ obj[publicSymbol2] = 3 |
+ var syms = Object.getOwnPropertySymbols(obj) |
+ assertEquals(syms, [publicSymbol, publicSymbol2]) |
+} |
+TestGetOwnPropertySymbolsWithPrivateSymbols() |