From a66ae7cbce24f8575736a477bf02238903aeee83 Mon Sep 17 00:00:00 2001 From: Leonardo Balter Date: Wed, 29 Jul 2015 17:36:07 -0400 Subject: [PATCH] Add tests for Reflect.isExtensible --- .../Reflect/isExtensible/isExtensible.js | 17 +++++++++++ test/built-ins/Reflect/isExtensible/length.js | 17 +++++++++++ test/built-ins/Reflect/isExtensible/name.js | 22 +++++++++++++++ .../isExtensible/return-abrupt-from-result.js | 24 ++++++++++++++++ .../Reflect/isExtensible/return-boolean.js | 18 ++++++++++++ .../target-is-not-object-throws.js | 28 +++++++++++++++++++ .../isExtensible/target-is-symbol-throws.js | 17 +++++++++++ 7 files changed, 143 insertions(+) create mode 100644 test/built-ins/Reflect/isExtensible/isExtensible.js create mode 100644 test/built-ins/Reflect/isExtensible/length.js create mode 100644 test/built-ins/Reflect/isExtensible/name.js create mode 100644 test/built-ins/Reflect/isExtensible/return-abrupt-from-result.js create mode 100644 test/built-ins/Reflect/isExtensible/return-boolean.js create mode 100644 test/built-ins/Reflect/isExtensible/target-is-not-object-throws.js create mode 100644 test/built-ins/Reflect/isExtensible/target-is-symbol-throws.js diff --git a/test/built-ins/Reflect/isExtensible/isExtensible.js b/test/built-ins/Reflect/isExtensible/isExtensible.js new file mode 100644 index 0000000000..5fff578e0b --- /dev/null +++ b/test/built-ins/Reflect/isExtensible/isExtensible.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.1.10 +description: > + Reflect.isExtensible is configurable, writable and not enumerable. +info: > + 26.1.10 Reflect.isExtensible (target) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(Reflect, 'isExtensible'); +verifyWritable(Reflect, 'isExtensible'); +verifyConfigurable(Reflect, 'isExtensible'); diff --git a/test/built-ins/Reflect/isExtensible/length.js b/test/built-ins/Reflect/isExtensible/length.js new file mode 100644 index 0000000000..ac0e2b335c --- /dev/null +++ b/test/built-ins/Reflect/isExtensible/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.1.10 +description: > + Reflect.isExtensible.length value and property descriptor +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Reflect.isExtensible.length, 1, + 'The value of `Reflect.isExtensible.length` is `1`' +); + +verifyNotEnumerable(Reflect.isExtensible, 'length'); +verifyNotWritable(Reflect.isExtensible, 'length'); +verifyConfigurable(Reflect.isExtensible, 'length'); diff --git a/test/built-ins/Reflect/isExtensible/name.js b/test/built-ins/Reflect/isExtensible/name.js new file mode 100644 index 0000000000..ac7b8632f1 --- /dev/null +++ b/test/built-ins/Reflect/isExtensible/name.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.1.10 +description: > + Reflect.isExtensible.name value and property descriptor +info: > + 26.1.10 Reflect.isExtensible (target) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Reflect.isExtensible.name, 'isExtensible', + 'The value of `Reflect.isExtensible.name` is `"isExtensible"`' +); + +verifyNotEnumerable(Reflect.isExtensible, 'name'); +verifyNotWritable(Reflect.isExtensible, 'name'); +verifyConfigurable(Reflect.isExtensible, 'name'); diff --git a/test/built-ins/Reflect/isExtensible/return-abrupt-from-result.js b/test/built-ins/Reflect/isExtensible/return-abrupt-from-result.js new file mode 100644 index 0000000000..cc04257636 --- /dev/null +++ b/test/built-ins/Reflect/isExtensible/return-abrupt-from-result.js @@ -0,0 +1,24 @@ +// 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.1.10 +description: > + Return abrupt result. +info: > + 26.1.10 Reflect.isExtensible (target) + + ... + 2. Return target.[[IsExtensible]](). +features: [Proxy] +---*/ + +var o1 = {}; +var p = new Proxy(o1, { + isExtensible: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + Reflect.isExtensible(p); +}); diff --git a/test/built-ins/Reflect/isExtensible/return-boolean.js b/test/built-ins/Reflect/isExtensible/return-boolean.js new file mode 100644 index 0000000000..2bc37410fb --- /dev/null +++ b/test/built-ins/Reflect/isExtensible/return-boolean.js @@ -0,0 +1,18 @@ +// 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.1.10 +description: > + Returns the boolean result. +info: > + 26.1.10 Reflect.isExtensible (target) + + ... + 2. Return target.[[IsExtensible]](). +---*/ + +var o = {}; +assert.sameValue(Reflect.isExtensible(o), true); + +Object.preventExtensions(o); +assert.sameValue(Reflect.isExtensible(o), false); diff --git a/test/built-ins/Reflect/isExtensible/target-is-not-object-throws.js b/test/built-ins/Reflect/isExtensible/target-is-not-object-throws.js new file mode 100644 index 0000000000..1444a401e9 --- /dev/null +++ b/test/built-ins/Reflect/isExtensible/target-is-not-object-throws.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.1.10 +description: > + Throws a TypeError if target is not an Object. +info: > + 26.1.10 Reflect.isExtensible (target) + + 1. If Type(target) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + Reflect.isExtensible(1); +}); + +assert.throws(TypeError, function() { + Reflect.isExtensible(null); +}); + +assert.throws(TypeError, function() { + Reflect.isExtensible(undefined); +}); + +assert.throws(TypeError, function() { + Reflect.isExtensible(''); +}); diff --git a/test/built-ins/Reflect/isExtensible/target-is-symbol-throws.js b/test/built-ins/Reflect/isExtensible/target-is-symbol-throws.js new file mode 100644 index 0000000000..aaea9eba50 --- /dev/null +++ b/test/built-ins/Reflect/isExtensible/target-is-symbol-throws.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.1.10 +description: > + Throws a TypeError if target is a Symbol +info: > + 26.1.10 Reflect.isExtensible (target) + + 1. If Type(target) is not Object, throw a TypeError exception. + ... +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + Reflect.isExtensible(Symbol(1)); +});