mirror of
https://github.com/tc39/test262.git
synced 2025-07-14 17:44:39 +02:00
Replace mayHaveProperty with verifyProperty
This commit is contained in:
parent
d249979bc9
commit
20ea611db7
@ -856,22 +856,6 @@ function testProperty(obj, property, valid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests whether the named property of the given object, if present at all, has a valid value
|
|
||||||
* and the default attributes of the properties of an object literal.
|
|
||||||
* @param {Object} obj the object to be tested.
|
|
||||||
* @param {string} property the name of the property
|
|
||||||
* @param {Function|Array} valid either a function that tests value for validity and returns a boolean,
|
|
||||||
* an array of valid values.
|
|
||||||
* @exception if the property is present and has an invalid value.
|
|
||||||
*/
|
|
||||||
function mayHaveProperty(obj, property, valid) {
|
|
||||||
if (obj.hasOwnProperty(property)) {
|
|
||||||
testProperty(obj, property, valid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests whether the given object has the named property with a valid value
|
* Tests whether the given object has the named property with a valid value
|
||||||
* and the default attributes of the properties of an object literal.
|
* and the default attributes of the properties of an object literal.
|
||||||
|
@ -7,7 +7,7 @@ description: >
|
|||||||
Tests that the object returned by
|
Tests that the object returned by
|
||||||
Intl.Collator.prototype.resolvedOptions has the right properties.
|
Intl.Collator.prototype.resolvedOptions has the right properties.
|
||||||
author: Norbert Lindenberg
|
author: Norbert Lindenberg
|
||||||
includes: [testIntl.js]
|
includes: [testIntl.js, propertyHelper.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var actual = new Intl.Collator().resolvedOptions();
|
var actual = new Intl.Collator().resolvedOptions();
|
||||||
@ -41,5 +41,15 @@ mustHaveProperty(actual, "usage", ["sort"]);
|
|||||||
mustHaveProperty(actual, "sensitivity", ["variant"]);
|
mustHaveProperty(actual, "sensitivity", ["variant"]);
|
||||||
mustHaveProperty(actual, "ignorePunctuation", [false]);
|
mustHaveProperty(actual, "ignorePunctuation", [false]);
|
||||||
mustHaveProperty(actual, "collation", collations);
|
mustHaveProperty(actual, "collation", collations);
|
||||||
mayHaveProperty(actual, "numeric", [true, false]);
|
|
||||||
mayHaveProperty(actual, "caseFirst", ["upper", "lower", "false"]);
|
// "numeric" is an optional property.
|
||||||
|
if (actual.hasOwnProperty("numeric")) {
|
||||||
|
assert.notSameValue([true, false].indexOf(actual.numeric), -1);
|
||||||
|
verifyProperty(actual, "numeric", {writable: true, enumerable: true, configurable: true});
|
||||||
|
}
|
||||||
|
|
||||||
|
// "caseFirst" is an optional property.
|
||||||
|
if (actual.hasOwnProperty("caseFirst")) {
|
||||||
|
assert.notSameValue(["upper", "lower", "false"].indexOf(actual.caseFirst), -1);
|
||||||
|
verifyProperty(actual, "caseFirst", {writable: true, enumerable: true, configurable: true});
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user