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

Unified Diff: test/mjsunit/harmony/proxies-with-unscopables.js

Issue 1529473002: [proxies] [tests] Un-skip proxies-with-unscopables, delete proxies-symbols (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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 | « test/mjsunit/harmony/proxies-symbols.js ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/proxies-with-unscopables.js
diff --git a/test/mjsunit/harmony/proxies-with-unscopables.js b/test/mjsunit/harmony/proxies-with-unscopables.js
index 1237b2b361041cbba35d369038067d157e82c03f..2cb45f7d266faff443d298ab6ed62b04e69fefa4 100644
--- a/test/mjsunit/harmony/proxies-with-unscopables.js
+++ b/test/mjsunit/harmony/proxies-with-unscopables.js
@@ -5,22 +5,24 @@
// Flags: --harmony-proxies
-// TODO(arv): Once proxies can intercept symbols, add more tests.
+function str(x) {
+ if (typeof x === "symbol") return "<Symbol>";
+ return "" + x;
+}
neis 2015/12/14 15:53:55 Why not use String(x)? Then you can test for "Sym
Jakob Kummerow 2015/12/14 15:59:12 Done.
function TestBasics() {
var log = [];
var proxy = new Proxy({}, {
- getPropertyDescriptor: function(key) {
- log.push(key);
- if (key === 'x') {
- return {
- value: 1,
- configurable: true
- };
- }
- return undefined;
+ get: function(target, key) {
+ log.push("get " + str(key));
+ if (key === 'x') return 1;
+ },
+ has: function(target, key) {
+ log.push("has " + str(key));
+ if (key === 'x') return true;
+ return false;
}
});
@@ -30,27 +32,23 @@ function TestBasics() {
assertEquals(1, x);
}
- // One 'x' for HasBinding and one for GetBindingValue
- assertEquals(['assertEquals', 'x', 'x'], log);
+ assertEquals(['has assertEquals', 'has x', 'get <Symbol>', 'get x'], log);
}
TestBasics();
function TestInconsistent() {
var log = [];
- var calls = 0;
var proxy = new Proxy({}, {
- getPropertyDescriptor: function(key) {
- log.push(key);
- if (key === 'x' && calls < 1) {
- calls++;
- return {
- value: 1,
- configurable: true
- };
- }
+ get: function(target, key) {
+ log.push("get " + str(key));
return undefined;
+ },
+ has: function(target, key) {
+ log.push("has " + str(key));
+ if (key === 'x') return true;
+ return false;
}
});
@@ -60,8 +58,7 @@ function TestInconsistent() {
assertEquals(void 0, x);
}
- // One 'x' for HasBinding and one for GetBindingValue
- assertEquals(['assertEquals', 'x', 'x'], log);
+ assertEquals(['has assertEquals', 'has x', 'get <Symbol>', 'get x'], log);
}
TestInconsistent();
@@ -73,18 +70,13 @@ function TestUseProxyAsUnscopables() {
};
var calls = 0;
var proxy = new Proxy({}, {
- has: function(key) {
+ has: function() {
assertUnreachable();
},
- getPropertyDescriptor: function(key) {
- calls++;
+ get: function(target, key) {
assertEquals('x', key);
- return {
- value: calls === 2 ? true : undefined,
- configurable: true,
- enumerable: true,
- writable: true,
- };
+ calls++;
+ return calls === 2 ? true : undefined;
}
});
@@ -111,10 +103,10 @@ function TestThrowInHasUnscopables() {
var calls = 0;
var proxy = new Proxy({}, {
- has: function(key) {
+ has: function() {
assertUnreachable();
},
- getPropertyDescriptor: function(key) {
+ get: function(target, key) {
if (calls++ === 0) {
throw new CustomError();
}
@@ -137,7 +129,10 @@ var global = this;
function TestGlobalShouldIgnoreUnscopables() {
global.x = 1;
var proxy = new Proxy({}, {
- getPropertyDescriptor: function() {
+ get: function() {
+ assertUnreachable();
+ },
+ has: function() {
assertUnreachable();
}
});
« no previous file with comments | « test/mjsunit/harmony/proxies-symbols.js ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698