Use assert-lib: intl402/PluralRules

This commit is contained in:
André Bargull 2017-05-04 21:25:02 +02:00
parent bfac377fca
commit 0271179c4a
6 changed files with 14 additions and 45 deletions

View File

@ -12,10 +12,6 @@ author: Zibi Braniecki
var obj = new Intl.PluralRules();
var actualPrototype = Object.getPrototypeOf(obj);
if (actualPrototype !== Intl.PluralRules.prototype) {
$ERROR("Prototype of object constructed by Intl.PluralRules isn't Intl.PluralRules.prototype; got " + actualPrototype);
}
assert.sameValue(actualPrototype, Intl.PluralRules.prototype, "Prototype of object constructed by Intl.PluralRules isn't Intl.PluralRules.prototype; got " + actualPrototype);
if (!Object.isExtensible(obj)) {
$ERROR("Object constructed by Intl.PluralRules must be extensible.");
}
assert(Object.isExtensible(obj), "Object constructed by Intl.PluralRules must be extensible.");

View File

@ -19,16 +19,8 @@ var invalidTargets = [undefined, null, true, 0, "PluralRules", [], {}];
Object.getOwnPropertyNames(functions).forEach(function (functionName) {
var f = functions[functionName];
invalidTargets.forEach(function (target) {
var error;
try {
assert.throws(TypeError, function () {
f.call(target);
} catch (e) {
error = e;
}
if (error === undefined) {
$ERROR("Calling " + functionName + " on " + target + " was not rejected.");
} else if (error.name !== "TypeError") {
$ERROR("Calling " + functionName + " on " + target + " was rejected with wrong error " + error.name + ".");
}
}, "Calling " + functionName + " on " + target + " was not rejected.");
});
});

View File

@ -9,7 +9,4 @@ description: >
author: Zibi Braniecki
---*/
if (Intl.PluralRules.prototype.constructor !== Intl.PluralRules) {
$ERROR("Intl.PluralRules.prototype.constructor is not the same as " +
"Intl.PluralRules");
}
assert.sameValue(Intl.PluralRules.prototype.constructor, Intl.PluralRules, "Intl.PluralRules.prototype.constructor is not the same as Intl.PluralRules");

View File

@ -8,15 +8,7 @@ author: Zibi Braniecki
---*/
var desc = Object.getOwnPropertyDescriptor(Intl.PluralRules, "prototype");
if (desc === undefined) {
$ERROR("Intl.PluralRules.prototype is not defined.");
}
if (desc.writable) {
$ERROR("Intl.PluralRules.prototype must not be writable.");
}
if (desc.enumerable) {
$ERROR("Intl.PluralRules.prototype must not be enumerable.");
}
if (desc.configurable) {
$ERROR("Intl.PluralRules.prototype must not be configurable.");
}
assert.notSameValue(desc, undefined, "Intl.PluralRules.prototype is not defined.");
assert.sameValue(desc.writable, false, "Intl.PluralRules.prototype must not be writable.");
assert.sameValue(desc.enumerable, false, "Intl.PluralRules.prototype must not be enumerable.");
assert.sameValue(desc.configurable, false, "Intl.PluralRules.prototype must not be configurable.");

View File

@ -14,9 +14,7 @@ includes: [testIntl.js]
var actual = new Intl.PluralRules().resolvedOptions();
var actual2 = new Intl.PluralRules().resolvedOptions();
if (actual2 === actual) {
$ERROR("resolvedOptions returned the same object twice.");
}
assert.notSameValue(actual2, actual, "resolvedOptions returned the same object twice.");
// this assumes the default values where the specification provides them
mustHaveProperty(actual, "locale", isCanonicalizedStructurallyValidLanguageTag);

View File

@ -15,15 +15,9 @@ var requestedLocales = [defaultLocale, notSupported];
var supportedLocales;
if (!Intl.PluralRules.hasOwnProperty('supportedLocalesOf')) {
$ERROR("Intl.PluralRules doesn't have a supportedLocalesOf property.");
}
assert(Intl.PluralRules.hasOwnProperty('supportedLocalesOf'), "Intl.PluralRules doesn't have a supportedLocalesOf property.");
supportedLocales = Intl.PluralRules.supportedLocalesOf(requestedLocales);
if (supportedLocales.length !== 1) {
$ERROR('The length of supported locales list is not 1.');
}
if (supportedLocales[0] !== defaultLocale) {
$ERROR('The default locale is not returned in the supported list.');
}
assert.sameValue(supportedLocales.length, 1, 'The length of supported locales list is not 1.');
assert.sameValue(supportedLocales[0], defaultLocale, 'The default locale is not returned in the supported list.');