diff --git a/harness/propertyHelper.js b/harness/propertyHelper.js index e2627877e4..8ce65ba86c 100644 --- a/harness/propertyHelper.js +++ b/harness/propertyHelper.js @@ -11,14 +11,8 @@ function isConfigurable(obj, name) { } function isEnumerable(obj, name) { - for (var prop in obj) { - if (Object.prototype.hasOwnProperty.call(obj, prop) && - assert._isSameValue(prop, name)) { - return true; - } - } - - return false; + return Object.prototype.hasOwnProperty.call(obj, name) && + Object.prototype.propertyIsEnumerable.call(obj, name); } function isEqualTo(obj, name, expectedValue) { diff --git a/test/harness/propertyhelper-verifyenumerable-enumerable-symbol.js b/test/harness/propertyhelper-verifyenumerable-enumerable-symbol.js new file mode 100644 index 0000000000..e88dfec0c1 --- /dev/null +++ b/test/harness/propertyhelper-verifyenumerable-enumerable-symbol.js @@ -0,0 +1,17 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Objects whose specified symbol property is enumerable satisfy the assertion. +includes: [propertyHelper.js] +features: [Symbol] +---*/ + +var obj = {}; +var s = Symbol('1'); +Object.defineProperty(obj, s, { + enumerable: true +}); + +verifyEnumerable(obj, s); diff --git a/test/harness/propertyhelper-verifyenumerable-enumerable.js b/test/harness/propertyhelper-verifyenumerable-enumerable.js index 7540999802..acaa0d8bc1 100644 --- a/test/harness/propertyhelper-verifyenumerable-enumerable.js +++ b/test/harness/propertyhelper-verifyenumerable-enumerable.js @@ -3,7 +3,7 @@ /*--- description: > - Objects whose specified property is enumerable satisfy the assertion. + Objects whose specified string property is enumerable satisfy the assertion. includes: [propertyHelper.js] ---*/ diff --git a/test/harness/propertyhelper-verifyenumerable-not-enumerable-symbol.js b/test/harness/propertyhelper-verifyenumerable-not-enumerable-symbol.js new file mode 100644 index 0000000000..6968ca896d --- /dev/null +++ b/test/harness/propertyhelper-verifyenumerable-not-enumerable-symbol.js @@ -0,0 +1,35 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Objects whose specified symbol property is not enumerable do not satisfy the + assertion. +includes: [propertyHelper.js] +features: [Symbol] +---*/ + +var threw = false; +var obj = {}; +var s = Symbol('1'); +Object.defineProperty(obj, s, { + enumerable: false +}); + +try { + verifyEnumerable(obj, s); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Test262Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + throw new Test262Error( + 'Expected a Test262Error, but no error was thrown for symbol key.' + ); +} diff --git a/test/harness/propertyhelper-verifyenumerable-not-enumerable.js b/test/harness/propertyhelper-verifyenumerable-not-enumerable.js index 569ac0904a..b6ff01410c 100644 --- a/test/harness/propertyhelper-verifyenumerable-not-enumerable.js +++ b/test/harness/propertyhelper-verifyenumerable-not-enumerable.js @@ -2,8 +2,8 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > - Objects whose specified property is not enumerable do not satisfy the +description: | + Objects whose specified string property is not enumerable do not satisfy the assertion. includes: [propertyHelper.js] ---*/ @@ -19,7 +19,7 @@ try { } catch(err) { threw = true; if (err.constructor !== Test262Error) { - $ERROR( + throw new Test262Error( 'Expected a Test262Error, but a "' + err.constructor.name + '" was thrown.' ); @@ -27,5 +27,7 @@ try { } if (threw === false) { - $ERROR('Expected a Test262Error, but no error was thrown.'); + throw new Test262Error( + 'Expected a Test262Error, but no error was thrown for string key.' + ); } diff --git a/test/harness/propertyhelper-verifynotenumerable-enumerable-symbol.js b/test/harness/propertyhelper-verifynotenumerable-enumerable-symbol.js new file mode 100644 index 0000000000..220c4f79c5 --- /dev/null +++ b/test/harness/propertyhelper-verifynotenumerable-enumerable-symbol.js @@ -0,0 +1,35 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Objects whose specified symbol property is enumerable do not satisfy the + assertion. +includes: [propertyHelper.js] +features: [Symbol] +---*/ + +var threw = false; +var obj = {}; +var s = Symbol('1'); +Object.defineProperty(obj, s, { + enumerable: true +}); + +try { + verifyNotEnumerable(obj, s); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Test262Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + throw new Test262Error( + 'Expected a Test262Error, but no error was thrown for symbol key.' + ); +} diff --git a/test/harness/propertyhelper-verifynotenumerable-enumerable.js b/test/harness/propertyhelper-verifynotenumerable-enumerable.js index 1d838d4f6c..5a9b136870 100644 --- a/test/harness/propertyhelper-verifynotenumerable-enumerable.js +++ b/test/harness/propertyhelper-verifynotenumerable-enumerable.js @@ -2,8 +2,8 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > - Objects whose specified property is enumerable do not satisfy the +description: | + Objects whose specified string property is enumerable do not satisfy the assertion. includes: [propertyHelper.js] ---*/ @@ -27,5 +27,7 @@ try { } if (threw === false) { - $ERROR('Expected a Test262Error, but no error was thrown.'); + throw new Test262Error( + 'Expected a Test262Error, but no error was thrown for string key.' + ); } diff --git a/test/harness/propertyhelper-verifynotenumerable-not-enumerable-symbol.js b/test/harness/propertyhelper-verifynotenumerable-not-enumerable-symbol.js new file mode 100644 index 0000000000..5cc7d53c08 --- /dev/null +++ b/test/harness/propertyhelper-verifynotenumerable-not-enumerable-symbol.js @@ -0,0 +1,18 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Objects whose specified symbol property is not enumerable satisfy the + assertion. +includes: [propertyHelper.js] +features: [Symbol] +---*/ + +var obj = {}; +var s = Symbol('1'); +Object.defineProperty(obj, s, { + enumerable: false +}); + +verifyNotEnumerable(obj, s); diff --git a/test/harness/propertyhelper-verifynotenumerable-not-enumerable.js b/test/harness/propertyhelper-verifynotenumerable-not-enumerable.js index 6e04b69309..29c32fab69 100644 --- a/test/harness/propertyhelper-verifynotenumerable-not-enumerable.js +++ b/test/harness/propertyhelper-verifynotenumerable-not-enumerable.js @@ -2,8 +2,9 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: > - Objects whose specified property is not enumerable satisfy the assertion. +description: | + Objects whose specified string property is not enumerable satisfy the + assertion. includes: [propertyHelper.js] ---*/