From c3e71dcb0befd3a38378a97b3df359e9cdb18b69 Mon Sep 17 00:00:00 2001 From: Leonardo Balter Date: Tue, 2 Jun 2015 16:53:51 -0400 Subject: [PATCH] Proxy.revocable --- test/built-ins/Proxy/revocable/proxy.js | 23 +++++++++++++++++++ ...voke-consecutive-call-returns-undefined.js | 19 +++++++++++++++ .../revocable/revoke-returns-undefined.js | 16 +++++++++++++ test/built-ins/Proxy/revocable/revoke.js | 15 ++++++++++++ 4 files changed, 73 insertions(+) create mode 100644 test/built-ins/Proxy/revocable/proxy.js create mode 100644 test/built-ins/Proxy/revocable/revoke-consecutive-call-returns-undefined.js create mode 100644 test/built-ins/Proxy/revocable/revoke-returns-undefined.js create mode 100644 test/built-ins/Proxy/revocable/revoke.js diff --git a/test/built-ins/Proxy/revocable/proxy.js b/test/built-ins/Proxy/revocable/proxy.js new file mode 100644 index 0000000000..81a0bf54d9 --- /dev/null +++ b/test/built-ins/Proxy/revocable/proxy.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 26.2.2.1 +description: > + The returned object has a proxy property which is the created Proxy object + built with the given target and handler given parameters. +info: > + Proxy.revocable ( target, handler ) + + 6. Perform CreateDataProperty(result, "proxy", p). +---*/ + +var target = { + attr: "foo" +}; +var r = Proxy.revocable(target, { + get: function(t, prop) { + return t[prop] + "!"; + } +}); + +assert.sameValue(r.proxy.attr, "foo!"); diff --git a/test/built-ins/Proxy/revocable/revoke-consecutive-call-returns-undefined.js b/test/built-ins/Proxy/revocable/revoke-consecutive-call-returns-undefined.js new file mode 100644 index 0000000000..2d54d9d71b --- /dev/null +++ b/test/built-ins/Proxy/revocable/revoke-consecutive-call-returns-undefined.js @@ -0,0 +1,19 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 26.2.2.1.1 +description: > + Calling the revoked function again will return undefined +info: > + Proxy Revocation Functions + + ... + 1. Let p be the value of F’s [[RevocableProxy]] internal slot. + 2. If p is null, return undefined. +---*/ + +var r = Proxy.revocable({}, {}); + +r.revoke(); + +assert.sameValue(r.revoke(), undefined); diff --git a/test/built-ins/Proxy/revocable/revoke-returns-undefined.js b/test/built-ins/Proxy/revocable/revoke-returns-undefined.js new file mode 100644 index 0000000000..746916aabc --- /dev/null +++ b/test/built-ins/Proxy/revocable/revoke-returns-undefined.js @@ -0,0 +1,16 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 26.2.2.1.1 +description: > + Calling the revoked function returns undefined +info: > + Proxy Revocation Functions + + ... + 7. Return undefined. +---*/ + +var r = Proxy.revocable({}, {}); + +assert.sameValue(r.revoke(), undefined); diff --git a/test/built-ins/Proxy/revocable/revoke.js b/test/built-ins/Proxy/revocable/revoke.js new file mode 100644 index 0000000000..a39472d2bf --- /dev/null +++ b/test/built-ins/Proxy/revocable/revoke.js @@ -0,0 +1,15 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 26.2.2.1 +description: > + The returned object has a `revoked` property which is a function +info: > + Proxy.revocable ( target, handler ) + + 7. Perform CreateDataProperty(result, "revoke", revoker). +---*/ + +var r = Proxy.revocable({}, {}); + +assert.sameValue(typeof r.revoke, "function");