diff --git a/harness/propertyHelper.js b/harness/propertyHelper.js index e2627877e4c3bdbc854a1509740c5255b03b4926..8ce65ba86c6f8a8aeaafa1c1b29dd82a71abb359 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 0000000000000000000000000000000000000000..e88dfec0c1299a76f3dc55cdb3acb181df79040a --- /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 754099980232ea64513f570117837b73f79d4dd3..acaa0d8bc147c139f1570af594a982c86a494246 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 0000000000000000000000000000000000000000..6968ca896d2687387e2f5305cbe57a27cc00c046 --- /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 569ac0904a201da133a143e5cef17b6de1fd0dc5..b6ff01410c4e22c7432a4655123a447940c52229 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 0000000000000000000000000000000000000000..220c4f79c5aa8443094209b51ba9a11819bd3400 --- /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 1d838d4f6c3826067338f278276f1d8882e0cd53..5a9b13687075f940fd1bbdd3f234bb5ea439b1b1 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 0000000000000000000000000000000000000000..5cc7d53c089766174df7c1638ded03c8ec85567f --- /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 6e04b69309704c53dcb0712cce09be6f12e0149c..29c32fab6944fb21bc72031debbdb926d0db1aae 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] ---*/