diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance')
13 files changed, 317 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/browser.js b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/browser.js diff --git a/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/length.js b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/length.js new file mode 100644 index 0000000000..7a482b0d73 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/length.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: 19.2.3.6 +description: Function.prototye[Symbol.hasInstance] `length` property +info: | + ES6 Section 17: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this value + is equal to the largest number of named arguments shown in the subclause + headings for the function description, including optional parameters. + + [...] + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +features: [Symbol.hasInstance] +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Function.prototype[Symbol.hasInstance].length, 1); + +verifyNotEnumerable(Function.prototype[Symbol.hasInstance], 'length'); +verifyNotWritable(Function.prototype[Symbol.hasInstance], 'length'); +verifyConfigurable(Function.prototype[Symbol.hasInstance], 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/name.js b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/name.js new file mode 100644 index 0000000000..13f5f41f9f --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/name.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.2.3.6 +description: > + The value of the name property of this function is "[Symbol.hasInstance]". + + 17 ECMAScript Standard Built-in Objects +features: [Symbol.hasInstance] +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Function.prototype[Symbol.hasInstance].name, '[Symbol.hasInstance]' +); + +verifyNotEnumerable(Function.prototype[Symbol.hasInstance], 'name'); +verifyNotWritable(Function.prototype[Symbol.hasInstance], 'name'); +verifyConfigurable(Function.prototype[Symbol.hasInstance], 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/prop-desc.js b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/prop-desc.js new file mode 100644 index 0000000000..63a2ac4b91 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/prop-desc.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: 19.2.3.6 +description: Function.prototype[Symbol.hasInstance] property descriptor +info: | + This property has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: false }. +features: [Symbol.hasInstance] +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof Function.prototype[Symbol.hasInstance], 'function'); + +verifyNotEnumerable(Function.prototype, Symbol.hasInstance); +verifyNotWritable(Function.prototype, Symbol.hasInstance); +verifyNotConfigurable(Function.prototype, Symbol.hasInstance); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/shell.js b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/shell.js diff --git a/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/this-val-bound-target.js b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/this-val-bound-target.js new file mode 100644 index 0000000000..771f5d144d --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/this-val-bound-target.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: 19.2.3.6 +description: Invoked on a bound function +info: | + 1. Let F be the this value. + 2. Return OrdinaryHasInstance(F, V). + + 7.3.19 OrdinaryHasInstance (C, O) + + 1. If IsCallable(C) is false, return false. + 2. If C has a [[BoundTargetFunction]] internal slot, then + a. Let BC be the value of C’s [[BoundTargetFunction]] internal slot. + b. Return InstanceofOperator(O,BC) (see 12.9.4). +features: [Symbol.hasInstance] +---*/ + +var BC = function() {}; +var bc = new BC(); +var bound = BC.bind(); + +assert.sameValue(bound[Symbol.hasInstance](bc), true); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/this-val-not-callable.js b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/this-val-not-callable.js new file mode 100644 index 0000000000..886af7198e --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/this-val-not-callable.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: 19.2.3.6 +description: Non-callable `this` value +info: | + 1. Let F be the this value. + 2. Return OrdinaryHasInstance(F, V). + + 7.3.19 OrdinaryHasInstance (C, O) + + 1. If IsCallable(C) is false, return false. +features: [Symbol.hasInstance] +---*/ + +assert.sameValue(Function.prototype[Symbol.hasInstance].call(), false); +assert.sameValue(Function.prototype[Symbol.hasInstance].call({}), false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/this-val-poisoned-prototype.js b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/this-val-poisoned-prototype.js new file mode 100644 index 0000000000..708d28f4d4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/this-val-poisoned-prototype.js @@ -0,0 +1,33 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.2.3.6 +description: Error thrown when accessing `prototype` property of `this` value +info: | + 1. Let F be the this value. + 2. Return OrdinaryHasInstance(F, V). + + 7.3.19 OrdinaryHasInstance (C, O) + + [...] + 4. Let P be Get(C, "prototype"). + 5. ReturnIfAbrupt(P). +features: [Symbol.hasInstance] +---*/ + +// Create a callable object without a `prototype` property +var f = Object.getOwnPropertyDescriptor({ + get f() {} +}, 'f').get; + +Object.defineProperty(f, 'prototype', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + f[Symbol.hasInstance]({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/this-val-prototype-non-obj.js b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/this-val-prototype-non-obj.js new file mode 100644 index 0000000000..db198d3d16 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/this-val-prototype-non-obj.js @@ -0,0 +1,51 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.2.3.6 +description: Error thrown when accessing `prototype` property of `this` value +info: | + 1. Let F be the this value. + 2. Return OrdinaryHasInstance(F, V). + + 7.3.19 OrdinaryHasInstance (C, O) + + [...] + 4. Let P be Get(C, "prototype"). + 5. ReturnIfAbrupt(P). + 6. If Type(P) is not Object, throw a TypeError exception. +features: [Symbol, Symbol.hasInstance] +---*/ + +var f = function() {}; + +f.prototype = undefined; +assert.throws(TypeError, function() { + f[Symbol.hasInstance]({}); +}); + +f.prototype = null; +assert.throws(TypeError, function() { + f[Symbol.hasInstance]({}); +}); + +f.prototype = true; +assert.throws(TypeError, function() { + f[Symbol.hasInstance]({}); +}); + +f.prototype = 'string'; +assert.throws(TypeError, function() { + f[Symbol.hasInstance]({}); +}); + +f.prototype = Symbol(); +assert.throws(TypeError, function() { + f[Symbol.hasInstance]({}); +}); + +f.prototype = 86; +assert.throws(TypeError, function() { + f[Symbol.hasInstance]({}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/value-get-prototype-of-err.js b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/value-get-prototype-of-err.js new file mode 100644 index 0000000000..a661464630 --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/value-get-prototype-of-err.js @@ -0,0 +1,38 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.2.3.6 +description: > + Error thrown when invoking argument's [[GetPrototypeOf]] internal method +info: | + 1. Let F be the this value. + 2. Return OrdinaryHasInstance(F, V). + + 7.3.19 OrdinaryHasInstance (C, O) + + [...] + 7. Repeat + a. Let O be O.[[GetPrototypeOf]](). + b. ReturnIfAbrupt(O). + c. If O is null, return false. + d. If SameValue(P, O) is true, return true. +features: [Proxy, Symbol.hasInstance] +---*/ + +var o = new Proxy({}, { + getPrototypeOf: function() { + throw new Test262Error(); + } +}); +var o2 = Object.create(o); +var f = function() {}; + +assert.throws(Test262Error, function() { + f[Symbol.hasInstance](o); +}); + +assert.throws(Test262Error, function() { + f[Symbol.hasInstance](o2); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/value-negative.js b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/value-negative.js new file mode 100644 index 0000000000..1566aa9cbb --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/value-negative.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.2.3.6 +description: > + Constructor is not defined in the argument's prototype chain +info: | + 1. Let F be the this value. + 2. Return OrdinaryHasInstance(F, V). + + 7.3.19 OrdinaryHasInstance (C, O) + + [...] + 7. Repeat + a. Let O be O.[[GetPrototypeOf]](). + b. ReturnIfAbrupt(O). + c. If O is null, return false. + d. If SameValue(P, O) is true, return true. +features: [Symbol.hasInstance] +---*/ + +var f = function() {}; +var o = Object.create(null); +var o2 = Object.create(o); + +assert.sameValue(f[Symbol.hasInstance](o), false); +assert.sameValue(f[Symbol.hasInstance](o2), false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/value-non-obj.js b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/value-non-obj.js new file mode 100644 index 0000000000..c00cb64fce --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/value-non-obj.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: 19.2.3.6 +description: Non-object argument +info: | + 1. Let F be the this value. + 2. Return OrdinaryHasInstance(F, V). + + 7.3.19 OrdinaryHasInstance (C, O) + + [...] + 3. If Type(O) is not Object, return false. +features: [Symbol, Symbol.hasInstance] +---*/ + +assert.sameValue(function() {}[Symbol.hasInstance](), false); +assert.sameValue(function() {}[Symbol.hasInstance](undefined), false); +assert.sameValue(function() {}[Symbol.hasInstance](null), false); +assert.sameValue(function() {}[Symbol.hasInstance](true), false); +assert.sameValue(function() {}[Symbol.hasInstance]('string'), false); +assert.sameValue(function() {}[Symbol.hasInstance](Symbol()), false); +assert.sameValue(function() {}[Symbol.hasInstance](86), false); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/value-positive.js b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/value-positive.js new file mode 100644 index 0000000000..6077eab13d --- /dev/null +++ b/js/src/tests/test262/built-ins/Function/prototype/Symbol.hasInstance/value-positive.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 19.2.3.6 +description: > + Constructor is defined in the argument's prototype chain +info: | + 1. Let F be the this value. + 2. Return OrdinaryHasInstance(F, V). + + 7.3.19 OrdinaryHasInstance (C, O) + + [...] + 7. Repeat + a. Let O be O.[[GetPrototypeOf]](). + b. ReturnIfAbrupt(O). + c. If O is null, return false. + d. If SameValue(P, O) is true, return true. +features: [Symbol.hasInstance] +---*/ + +var f = function() {}; +var o = new f(); +var o2 = Object.create(o); + +assert.sameValue(f[Symbol.hasInstance](o), true); +assert.sameValue(f[Symbol.hasInstance](o2), true); + +reportCompare(0, 0); |