diff --git a/test/built-ins/Reflect/deleteProperty/delete-properties.js b/test/built-ins/Reflect/deleteProperty/delete-properties.js new file mode 100644 index 0000000000..93656beded --- /dev/null +++ b/test/built-ins/Reflect/deleteProperty/delete-properties.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: 26.1.4 +description: > + Delete property. +info: > + 26.1.4 Reflect.deleteProperty ( target, propertyKey ) + + ... + 4. Return target.[[Delete]](key). +---*/ + +var o = { + prop: 42 +}; + +Reflect.deleteProperty(o, 'prop'); + +assert.sameValue(o.hasOwnProperty('prop'), false); diff --git a/test/built-ins/Reflect/deleteProperty/delete-symbol-properties.js b/test/built-ins/Reflect/deleteProperty/delete-symbol-properties.js new file mode 100644 index 0000000000..d5f1910900 --- /dev/null +++ b/test/built-ins/Reflect/deleteProperty/delete-symbol-properties.js @@ -0,0 +1,30 @@ +// 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.4 +description: > + Delete a symbol property. +info: > + 26.1.4 Reflect.deleteProperty ( target, propertyKey ) + + ... + 2. Let key be ToPropertyKey(propertyKey). + ... + + 7.1.14 ToPropertyKey ( argument ) + + ... + 3. If Type(key) is Symbol, then + a. Return key. + ... +features: [Symbol] +---*/ + +var s = Symbol('1'); +var o = {}; +o[s] = 42; + +Reflect.deleteProperty(o, s); + +assert.sameValue(o.hasOwnProperty(s), false); +assert.sameValue(o[s], undefined); diff --git a/test/built-ins/Reflect/deleteProperty/deleteProperty.js b/test/built-ins/Reflect/deleteProperty/deleteProperty.js new file mode 100644 index 0000000000..9816906099 --- /dev/null +++ b/test/built-ins/Reflect/deleteProperty/deleteProperty.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.4 +description: > + Reflect.deleteProperty is configurable, writable and not enumerable. +info: > + 26.1.4 Reflect.deleteProperty ( target, propertyKey ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(Reflect, 'deleteProperty'); +verifyWritable(Reflect, 'deleteProperty'); +verifyConfigurable(Reflect, 'deleteProperty'); diff --git a/test/built-ins/Reflect/deleteProperty/length.js b/test/built-ins/Reflect/deleteProperty/length.js new file mode 100644 index 0000000000..aa79904dc3 --- /dev/null +++ b/test/built-ins/Reflect/deleteProperty/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.4 +description: > + Reflect.deleteProperty.length value and property descriptor +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Reflect.deleteProperty.length, 2, + 'The value of `Reflect.deleteProperty.length` is `2`' +); + +verifyNotEnumerable(Reflect.deleteProperty, 'length'); +verifyNotWritable(Reflect.deleteProperty, 'length'); +verifyConfigurable(Reflect.deleteProperty, 'length'); diff --git a/test/built-ins/Reflect/deleteProperty/name.js b/test/built-ins/Reflect/deleteProperty/name.js new file mode 100644 index 0000000000..cff57a7edc --- /dev/null +++ b/test/built-ins/Reflect/deleteProperty/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.4 +description: > + Reflect.deleteProperty.name value and property descriptor +info: > + 26.1.4 Reflect.deleteProperty ( target, propertyKey ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Reflect.deleteProperty.name, 'deleteProperty', + 'The value of `Reflect.deleteProperty.name` is `"deleteProperty"`' +); + +verifyNotEnumerable(Reflect.deleteProperty, 'name'); +verifyNotWritable(Reflect.deleteProperty, 'name'); +verifyConfigurable(Reflect.deleteProperty, 'name'); diff --git a/test/built-ins/Reflect/deleteProperty/return-abrupt-from-property-key.js b/test/built-ins/Reflect/deleteProperty/return-abrupt-from-property-key.js new file mode 100644 index 0000000000..fcae8bb08a --- /dev/null +++ b/test/built-ins/Reflect/deleteProperty/return-abrupt-from-property-key.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.4 +description: > + Return abrupt from ToPropertyKey(propertyKey) +info: > + 26.1.4 Reflect.deleteProperty ( target, propertyKey ) + + ... + 2. Let key be ToPropertyKey(propertyKey). + 3. ReturnIfAbrupt(key). + ... +---*/ + +var p = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + Reflect.deleteProperty({}, p); +}); diff --git a/test/built-ins/Reflect/deleteProperty/return-abrupt-from-result.js b/test/built-ins/Reflect/deleteProperty/return-abrupt-from-result.js new file mode 100644 index 0000000000..097071e09e --- /dev/null +++ b/test/built-ins/Reflect/deleteProperty/return-abrupt-from-result.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: 26.1.4 +description: > + Return abrupt result from deleting a property. +info: > + 26.1.4 Reflect.deleteProperty ( target, propertyKey ) + + ... + 6. Return target.[[DefineOwnProperty]](key, desc). + ... +features: [Proxy] +---*/ + +var o = {}; +var p = new Proxy(o, { + deleteProperty: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + Reflect.deleteProperty(p, 'p1'); +}); diff --git a/test/built-ins/Reflect/deleteProperty/return-boolean.js b/test/built-ins/Reflect/deleteProperty/return-boolean.js new file mode 100644 index 0000000000..a7cf4de875 --- /dev/null +++ b/test/built-ins/Reflect/deleteProperty/return-boolean.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.1.4 +description: > + Return boolean result. +info: > + 26.1.4 Reflect.deleteProperty ( target, propertyKey ) + + ... + 4. Return target.[[Delete]](key). +---*/ + +var o = {}; + +o.p1 = 'foo'; +assert.sameValue(Reflect.deleteProperty(o, 'p1'), true); +assert.sameValue(o.hasOwnProperty('p1'), false); + +o.p2 = 'foo'; +Object.freeze(o); +assert.sameValue(Reflect.deleteProperty(o, 'p2'), false); +assert.sameValue(o.hasOwnProperty('p2'), true); diff --git a/test/built-ins/Reflect/deleteProperty/target-is-not-object-throws.js b/test/built-ins/Reflect/deleteProperty/target-is-not-object-throws.js new file mode 100644 index 0000000000..5b898b286d --- /dev/null +++ b/test/built-ins/Reflect/deleteProperty/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.4 +description: > + Throws a TypeError if target is not an Object. +info: > + 26.1.4 Reflect.deleteProperty ( target, propertyKey ) + + 1. If Type(target) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + Reflect.deleteProperty(1, 'p'); +}); + +assert.throws(TypeError, function() { + Reflect.deleteProperty(null, 'p'); +}); + +assert.throws(TypeError, function() { + Reflect.deleteProperty(undefined, 'p'); +}); + +assert.throws(TypeError, function() { + Reflect.deleteProperty('', 'p'); +}); diff --git a/test/built-ins/Reflect/deleteProperty/target-is-symbol-throws.js b/test/built-ins/Reflect/deleteProperty/target-is-symbol-throws.js new file mode 100644 index 0000000000..4bd706716a --- /dev/null +++ b/test/built-ins/Reflect/deleteProperty/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.4 +description: > + Throws a TypeError if target is a Symbol +info: > + 26.1.4 Reflect.deleteProperty ( target, propertyKey ) + + 1. If Type(target) is not Object, throw a TypeError exception. + ... +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + Reflect.deleteProperty(Symbol(1), 'p'); +});