Merge pull request #543 from bocoup/enumerable-helper

Fix verifyEnumerable helper to account for properties with Symbol values
This commit is contained in:
Gorkem Yakin 2016-04-25 16:32:53 -07:00
commit f6475d81bf
9 changed files with 122 additions and 18 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -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]
---*/

View File

@ -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.'
);
}

View File

@ -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.'
);
}

View File

@ -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.'
);
}

View File

@ -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.'
);
}

View File

@ -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);

View File

@ -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]
---*/