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

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

Issue 1182303004: All private symbols are own symbols (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: Fix nits Created 5 years, 6 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
« no previous file with comments | « src/runtime/runtime-symbol.cc ('k') | test/mjsunit/own-symbols.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/private.js
diff --git a/test/mjsunit/harmony/private.js b/test/mjsunit/harmony/private.js
index c08daf105055cfcc9ac8ea940c4372bf0b8e0803..0adbb13b21a38f70730cc691416f0b8e31b10f36 100644
--- a/test/mjsunit/harmony/private.js
+++ b/test/mjsunit/harmony/private.js
@@ -241,7 +241,8 @@ function TestKeyGet(obj) {
var obj2 = Object.create(obj)
for (var i in symbols) {
assertEquals(i|0, obj[symbols[i]])
- assertEquals(i|0, obj2[symbols[i]])
+ // Private symbols key own-properties.
+ assertEquals(undefined, obj2[symbols[i]])
}
}
@@ -352,3 +353,52 @@ function TestSealAndFreeze(freeze) {
TestSealAndFreeze(Object.seal)
TestSealAndFreeze(Object.freeze)
TestSealAndFreeze(Object.preventExtensions)
+
+
+var s = %CreatePrivateSymbol("s");
+var s1 = %CreatePrivateSymbol("s1");
+
+function TestSimple() {
+ var p = {}
+ p[s] = "moo";
+
+ var o = Object.create(p);
+
+ assertEquals(undefined, o[s]);
+ assertEquals("moo", p[s]);
+
+ o[s] = "bow-wow";
+ assertEquals("bow-wow", o[s]);
+ assertEquals("moo", p[s]);
+}
+TestSimple();
+
+
+function TestICs() {
+ var p = {}
+ p[s] = "moo";
+
+
+ var o = Object.create(p);
+ o[s1] = "bow-wow";
+ function checkNonOwn(o) {
+ assertEquals(undefined, o[s]);
+ assertEquals("bow-wow", o[s1]);
+ }
+
+ checkNonOwn(o);
+
+ // Test monomorphic/optimized.
+ for (var i = 0; i < 1000; i++) {
+ checkNonOwn(o);
+ }
+
+ // Test non-monomorphic.
+ for (var i = 0; i < 1000; i++) {
+ var oNew = Object.create(p);
+ oNew["s" + i] = i;
+ oNew[s1] = "bow-wow";
+ checkNonOwn(oNew);
+ }
+}
+TestICs();
« no previous file with comments | « src/runtime/runtime-symbol.cc ('k') | test/mjsunit/own-symbols.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698