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

Unified Diff: test/mjsunit/es6/unscopables.js

Issue 807893002: ES6: Update unscopables to match spec (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: cleanup Created 6 years 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/contexts.cc ('k') | test/mjsunit/harmony/proxies-with-unscopables.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/unscopables.js
diff --git a/test/mjsunit/es6/unscopables.js b/test/mjsunit/es6/unscopables.js
index 36365d2d8230aa86c9cd64c04085985936605d3f..03612bec533a6c51a0ffd6340ec08ef295d28e12 100644
--- a/test/mjsunit/es6/unscopables.js
+++ b/test/mjsunit/es6/unscopables.js
@@ -143,6 +143,13 @@ function TestBasics(object) {
assertEquals(2, y);
assertEquals(3, z);
}
+
+ object[Symbol.unscopables] = {x: 0, y: undefined};
+ with (object) {
+ assertEquals(1, x);
+ assertEquals(5, y);
+ assertEquals(3, z);
+ }
}
runTest(TestBasics);
@@ -161,6 +168,13 @@ function TestUnscopableChain(object) {
with (object) {
assertEquals(1, x);
}
+
+ object[Symbol.unscopables] = {
+ __proto__: {x: undefined}
+ };
+ with (object) {
+ assertEquals(2, x);
+ }
}
runTest(TestUnscopableChain);
@@ -222,6 +236,14 @@ function TestOnProto(object, proto) {
assertEquals(5, y);
assertEquals(3, z);
}
+
+ proto[Symbol.unscopables] = {y: true};
+ object[Symbol.unscopables] = {x: true, y: undefined};
+ with (object) {
+ assertEquals(1, x);
+ assertEquals(5, y);
+ assertEquals(3, z);
+ }
}
runTest(TestOnProto);
@@ -341,6 +363,20 @@ function TestChangeDuringWithWithPossibleOptimization4(object) {
TestChangeDuringWithWithPossibleOptimization4({});
+function TestChangeDuringWithWithPossibleOptimization4(object) {
+ var x = 1;
+ object.x = 2;
+ object[Symbol.unscopables] = {x: true};
+ with (object) {
+ for (var i = 0; i < 1000; i++) {
+ if (i === 500) object[Symbol.unscopables].x = undefined;
+ assertEquals(i < 500 ? 1 : 2, x);
+ }
+ }
+}
+TestChangeDuringWithWithPossibleOptimization4({});
+
+
function TestAccessorReceiver(object, proto) {
var x = 'local';
@@ -532,9 +568,11 @@ function TestAccessorOnUnscopables(object) {
var x = 1;
object.x = 2;
+ var calls = 0;
var unscopables = {
get x() {
- assertUnreachable();
+ calls++;
+ return calls === 1 ? true : undefined;
}
};
@@ -542,7 +580,9 @@ function TestAccessorOnUnscopables(object) {
assertEquals(2, x);
object[Symbol.unscopables] = unscopables;
assertEquals(1, x);
+ assertEquals(2, x);
}
+ assertEquals(2, calls);
}
runTest(TestAccessorOnUnscopables);
@@ -659,3 +699,25 @@ function TestGetUnscopablesGetterThrows() {
}, CustomError);
}
TestGetUnscopablesGetterThrows();
+
+
+function TestGetUnscopablesGetterThrows2() {
+ var object = {
+ get x() {
+ assertUnreachable();
+ }
+ };
+ function CustomError() {}
+
+ object[Symbol.unscopables] = {
+ get x() {
+ throw new CustomError();
+ }
+ };
+ assertThrows(function() {
+ with (object) {
+ x;
+ }
+ }, CustomError);
+}
+TestGetUnscopablesGetterThrows();
« no previous file with comments | « src/contexts.cc ('k') | test/mjsunit/harmony/proxies-with-unscopables.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698