diff --git a/test/built-ins/Proxy/constructor.js b/test/built-ins/Proxy/constructor.js new file mode 100644 index 0000000000..1fff16b967 --- /dev/null +++ b/test/built-ins/Proxy/constructor.js @@ -0,0 +1,10 @@ +// 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.1 +description: > + The Proxy constructor is the %Proxy% intrinsic object and the + initial value of the Proxy property of the global object. +---*/ + +assert.sameValue(typeof Proxy, "function", "`typeof Proxy` is `'function'`"); diff --git a/test/built-ins/Proxy/create-handler-is-revoked-proxy.js b/test/built-ins/Proxy/create-handler-is-revoked-proxy.js new file mode 100644 index 0000000000..5126e4cb0f --- /dev/null +++ b/test/built-ins/Proxy/create-handler-is-revoked-proxy.js @@ -0,0 +1,20 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.5.15 +description: > + Proxy ( target, handler ) + ... + 4. If handler is a Proxy exotic object and the value of the + [[ProxyHandler]] internal slot of handler is null, throw a + TypeError exception. + ... +---*/ + +var revocable = Proxy.revocable({}, {}); + +revocable.revoke(); + +assert.throws(TypeError, function() { + new Proxy({}, revocable.proxy); +}); diff --git a/test/built-ins/Proxy/create-handler-not-object-throw-boolean.js b/test/built-ins/Proxy/create-handler-not-object-throw-boolean.js new file mode 100644 index 0000000000..891c1826b1 --- /dev/null +++ b/test/built-ins/Proxy/create-handler-not-object-throw-boolean.js @@ -0,0 +1,14 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.5.15 +description: > + Proxy ( target, handler ) + ... + 3. If Type(handler) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + new Proxy({}, false); +}); diff --git a/test/built-ins/Proxy/create-handler-not-object-throw-null.js b/test/built-ins/Proxy/create-handler-not-object-throw-null.js new file mode 100644 index 0000000000..7abcc0b2db --- /dev/null +++ b/test/built-ins/Proxy/create-handler-not-object-throw-null.js @@ -0,0 +1,14 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.5.15 +description: > + Proxy ( target, handler ) + ... + 3. If Type(handler) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + new Proxy({}, null); +}); diff --git a/test/built-ins/Proxy/create-handler-not-object-throw-number.js b/test/built-ins/Proxy/create-handler-not-object-throw-number.js new file mode 100644 index 0000000000..7cb41f20b5 --- /dev/null +++ b/test/built-ins/Proxy/create-handler-not-object-throw-number.js @@ -0,0 +1,14 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.5.15 +description: > + Proxy ( target, handler ) + ... + 3. If Type(handler) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + new Proxy({}, 0); +}); diff --git a/test/built-ins/Proxy/create-handler-not-object-throw-string.js b/test/built-ins/Proxy/create-handler-not-object-throw-string.js new file mode 100644 index 0000000000..25f1982ec3 --- /dev/null +++ b/test/built-ins/Proxy/create-handler-not-object-throw-string.js @@ -0,0 +1,14 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.5.15 +description: > + Proxy ( target, handler ) + ... + 3. If Type(handler) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + new Proxy({}, ""); +}); diff --git a/test/built-ins/Proxy/create-handler-not-object-throw-symbol.js b/test/built-ins/Proxy/create-handler-not-object-throw-symbol.js new file mode 100644 index 0000000000..3801334231 --- /dev/null +++ b/test/built-ins/Proxy/create-handler-not-object-throw-symbol.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: 9.5.15 +description: > + Proxy ( target, handler ) + ... + 3. If Type(handler) is not Object, throw a TypeError exception. + ... +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + new Proxy({}, Symbol()); +}); diff --git a/test/built-ins/Proxy/create-handler-not-object-throw-undefined.js b/test/built-ins/Proxy/create-handler-not-object-throw-undefined.js new file mode 100644 index 0000000000..8dd8f172b4 --- /dev/null +++ b/test/built-ins/Proxy/create-handler-not-object-throw-undefined.js @@ -0,0 +1,14 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.5.15 +description: > + Proxy ( target, handler ) + ... + 3. If Type(handler) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + new Proxy({}, undefined); +}); diff --git a/test/built-ins/Proxy/create-target-is-not-callable.js b/test/built-ins/Proxy/create-target-is-not-callable.js new file mode 100644 index 0000000000..696403483a --- /dev/null +++ b/test/built-ins/Proxy/create-target-is-not-callable.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.5.15 +description: > + A Proxy exotic object is only callable if the given target is callable. +info: > + Proxy ( target, handler ) + + 7. If IsCallable(target) is true, then + a. Set the [[Call]] internal method of P as specified in 9.5.13. + ... + + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall( func, thisValue, arguments, + tailPosition ) + + 4. If IsCallable(func) is false, throw a TypeError exception. +---*/ + +var p = new Proxy({}, {}); + +assert.throws(TypeError, function() { + p.call(); +}); diff --git a/test/built-ins/Proxy/create-target-is-not-constructor.js b/test/built-ins/Proxy/create-target-is-not-constructor.js new file mode 100644 index 0000000000..f69d63d927 --- /dev/null +++ b/test/built-ins/Proxy/create-target-is-not-constructor.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.5.15 +description: > + A Proxy exotic object only accepts a constructor call if target is + constructor. +info: > + Proxy ( target, handler ) + + 7. If IsCallable(target) is true, then + b. If target has a [[Construct]] internal method, then + i. Set the [[Construct]] internal method of P as specified in + 9.5.14. + ... + + 12.3.3.1.1 Runtime Semantics: EvaluateNew(constructProduction, arguments) + + 8. If IsConstructor (constructor) is false, throw a TypeError exception. +---*/ + +var p = new Proxy(eval, {}); + +p(); // the Proxy object is callable + +assert.throws(TypeError, function() { + new p(); +}); diff --git a/test/built-ins/Proxy/create-target-is-revoked-proxy.js b/test/built-ins/Proxy/create-target-is-revoked-proxy.js new file mode 100644 index 0000000000..f68607b36d --- /dev/null +++ b/test/built-ins/Proxy/create-target-is-revoked-proxy.js @@ -0,0 +1,20 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.5.15 +description: > + Proxy ( target, handler ) + ... + 2. If target is a Proxy exotic object and the value of the + [[ProxyHandler]] internal slot of target is null, throw a + TypeError exception. + ... +---*/ + +var revocable = Proxy.revocable({}, {}); + +revocable.revoke(); + +assert.throws(TypeError, function() { + new Proxy(revocable.proxy, {}); +}); diff --git a/test/built-ins/Proxy/create-target-not-object-throw-boolean.js b/test/built-ins/Proxy/create-target-not-object-throw-boolean.js new file mode 100644 index 0000000000..d43e653e98 --- /dev/null +++ b/test/built-ins/Proxy/create-target-not-object-throw-boolean.js @@ -0,0 +1,14 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.5.15 +description: > + Proxy ( target, handler ) + ... + 1. If Type(target) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + new Proxy(false, {}); +}); diff --git a/test/built-ins/Proxy/create-target-not-object-throw-null.js b/test/built-ins/Proxy/create-target-not-object-throw-null.js new file mode 100644 index 0000000000..845cb6592f --- /dev/null +++ b/test/built-ins/Proxy/create-target-not-object-throw-null.js @@ -0,0 +1,14 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.5.15 +description: > + Proxy ( target, handler ) + ... + 1. If Type(target) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + new Proxy(null, {}); +}); diff --git a/test/built-ins/Proxy/create-target-not-object-throw-number.js b/test/built-ins/Proxy/create-target-not-object-throw-number.js new file mode 100644 index 0000000000..2dae22e798 --- /dev/null +++ b/test/built-ins/Proxy/create-target-not-object-throw-number.js @@ -0,0 +1,14 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.5.15 +description: > + Proxy ( target, handler ) + ... + 1. If Type(target) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + new Proxy(0, {}); +}); diff --git a/test/built-ins/Proxy/create-target-not-object-throw-string.js b/test/built-ins/Proxy/create-target-not-object-throw-string.js new file mode 100644 index 0000000000..d442b2e150 --- /dev/null +++ b/test/built-ins/Proxy/create-target-not-object-throw-string.js @@ -0,0 +1,14 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.5.15 +description: > + Proxy ( target, handler ) + ... + 1. If Type(target) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + new Proxy("", {}); +}); diff --git a/test/built-ins/Proxy/create-target-not-object-throw-symbol.js b/test/built-ins/Proxy/create-target-not-object-throw-symbol.js new file mode 100644 index 0000000000..a3569f23db --- /dev/null +++ b/test/built-ins/Proxy/create-target-not-object-throw-symbol.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: 9.5.15 +description: > + Proxy ( target, handler ) + ... + 1. If Type(target) is not Object, throw a TypeError exception. + ... +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + new Proxy(Symbol(), {}); +}); diff --git a/test/built-ins/Proxy/create-target-not-object-throw-undefined.js b/test/built-ins/Proxy/create-target-not-object-throw-undefined.js new file mode 100644 index 0000000000..9cda79c829 --- /dev/null +++ b/test/built-ins/Proxy/create-target-not-object-throw-undefined.js @@ -0,0 +1,14 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 9.5.15 +description: > + Proxy ( target, handler ) + ... + 1. If Type(target) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + new Proxy(undefined, {}); +}); diff --git a/test/built-ins/Proxy/function-prototype.js b/test/built-ins/Proxy/function-prototype.js new file mode 100644 index 0000000000..e501f9160e --- /dev/null +++ b/test/built-ins/Proxy/function-prototype.js @@ -0,0 +1,14 @@ +// 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 +description: > + The value of the [[Prototype]] internal slot of the Proxy + constructor is the intrinsic object %FunctionPrototype% (19.2.3). +---*/ + +assert.sameValue( + Object.getPrototypeOf(Proxy), + Function.prototype, + "`Object.getPrototypeOf(Proxy)` returns `Function.prototype`" +); diff --git a/test/built-ins/Proxy/length.js b/test/built-ins/Proxy/length.js new file mode 100644 index 0000000000..6f3d214494 --- /dev/null +++ b/test/built-ins/Proxy/length.js @@ -0,0 +1,17 @@ +// 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 +description: > + Properties of the Proxy Constructor + + Besides the length property (whose value is 2) + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Proxy.length, 2, "The value of `Proxy.length` is `2`"); + +verifyNotEnumerable(Proxy, "length"); +verifyNotWritable(Proxy, "length"); +verifyConfigurable(Proxy, "length"); diff --git a/test/built-ins/Proxy/name.js b/test/built-ins/Proxy/name.js new file mode 100644 index 0000000000..e081f7e1e3 --- /dev/null +++ b/test/built-ins/Proxy/name.js @@ -0,0 +1,17 @@ +// 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.1.1 +description: > + Proxy ( target, handler ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Proxy.name, "Proxy", "The value of `Proxy.name` is `'Proxy'`"); + +verifyNotEnumerable(Proxy, "name"); +verifyNotWritable(Proxy, "name"); +verifyConfigurable(Proxy, "name"); diff --git a/test/built-ins/Proxy/proxy-newtarget.js b/test/built-ins/Proxy/proxy-newtarget.js new file mode 100644 index 0000000000..2c1ef6f6f9 --- /dev/null +++ b/test/built-ins/Proxy/proxy-newtarget.js @@ -0,0 +1,28 @@ +// 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.1.1 +description: > + Proxy ( target, handler ) + + When Proxy is called with arguments target and handler performs + the following steps: + + ... + 2. Return ProxyCreate(target, handler). (9.5.15) + ... + 9.5.15 ProxyCreate(target, handler) + ... + 5. Let P be a newly created object. + ... + 10. Return P. + +---*/ + +var p1 = new Proxy({}, {}); + +assert.sameValue( + typeof p1, + 'object', + 'Return a newly created Object' +); \ No newline at end of file diff --git a/test/built-ins/Proxy/proxy-no-prototype.js b/test/built-ins/Proxy/proxy-no-prototype.js new file mode 100644 index 0000000000..027a2a8b47 --- /dev/null +++ b/test/built-ins/Proxy/proxy-no-prototype.js @@ -0,0 +1,11 @@ +// 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 +description: > + The Proxy constructor does not have a prototype property because + proxy exotic objects do not have a [[Prototype]] internal slot + that requires initialization. +---*/ + +assert.sameValue(Object.hasOwnProperty.call(Proxy, 'prototype'), false); diff --git a/test/built-ins/Proxy/proxy-undefined-newtarget.js b/test/built-ins/Proxy/proxy-undefined-newtarget.js new file mode 100644 index 0000000000..add91caf8e --- /dev/null +++ b/test/built-ins/Proxy/proxy-undefined-newtarget.js @@ -0,0 +1,22 @@ +// 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.1.1 +description: > + Proxy ( target, handler ) + + When Proxy is called with arguments target and handler performs + the following steps: + + 1. If NewTarget is undefined, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + Proxy(); +}); + +assert.throws(TypeError, function() { + Proxy([]); +}); diff --git a/test/built-ins/Proxy/proxy.js b/test/built-ins/Proxy/proxy.js new file mode 100644 index 0000000000..0ec873338d --- /dev/null +++ b/test/built-ins/Proxy/proxy.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.1.1 +description: > + Proxy ( target, handler ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(this, "Proxy"); +verifyWritable(this, "Proxy"); +verifyConfigurable(this, "Proxy");