mirror of https://github.com/tc39/test262.git
Merge pull request #543 from bocoup/enumerable-helper
Fix verifyEnumerable helper to account for properties with Symbol values
This commit is contained in:
commit
f6475d81bf
|
@ -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) {
|
||||
|
|
|
@ -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);
|
|
@ -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]
|
||||
---*/
|
||||
|
||||
|
|
|
@ -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.'
|
||||
);
|
||||
}
|
|
@ -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.'
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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.'
|
||||
);
|
||||
}
|
|
@ -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.'
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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);
|
|
@ -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]
|
||||
---*/
|
||||
|
||||
|
|
Loading…
Reference in New Issue