Remove unused return value from testWithIntlConstructors

This commit is contained in:
André Bargull 2017-12-21 12:08:09 -08:00 committed by Rick Waldron
parent f87aeab893
commit e65c65c293
23 changed files with 5 additions and 47 deletions

View File

@ -14,25 +14,21 @@ author: Norbert Lindenberg
/**
* @description Calls the provided function for every service constructor in
* the Intl object, until f returns a falsy value. It returns the result of the
* last call to f, mapped to a boolean.
* the Intl object.
* @param {Function} f the function to call for each service constructor in
* the Intl object.
* @param {Function} Constructor the constructor object to test with.
* @result {Boolean} whether the test succeeded.
*/
function testWithIntlConstructors(f) {
var constructors = ["Collator", "NumberFormat", "DateTimeFormat"];
return constructors.every(function (constructor) {
constructors.forEach(function (constructor) {
var Constructor = Intl[constructor];
var result;
try {
result = f(Constructor);
f(Constructor);
} catch (e) {
e.message += " (Testing with " + constructor + ".)";
throw e;
}
return result;
});
}

View File

@ -34,5 +34,4 @@ testWithIntlConstructors(function (Constructor) {
// this must not throw an exception for a valid language tag
var obj = new Constructor([tag]);
});
return true;
});

View File

@ -30,5 +30,4 @@ testWithIntlConstructors(function (Constructor) {
var obj = new Constructor([tag]);
}, "Invalid language tag " + tag + " was not rejected.");
});
return true;
});

View File

@ -36,5 +36,4 @@ testWithIntlConstructors(function (Constructor) {
var obj = new Constructor([tag]);
}, "Invalid language tag " + tag + " was not rejected.");
});
return true;
});

View File

@ -55,5 +55,4 @@ testWithIntlConstructors(function (Constructor) {
var supported = Constructor.supportedLocalesOf([tag]);
assert(supported.length === 0 || supported[0] === canonicalizedTags[tag][0], "For " + tag + " got " + supported[0] + "; expected " + canonicalizedTags[tag][0] + ".");
});
return true;
});

View File

@ -13,5 +13,4 @@ includes: [testIntl.js]
testWithIntlConstructors(function (Constructor) {
var defaultLocale = new Constructor().resolvedOptions().locale;
assert(isCanonicalizedStructurallyValidLanguageTag(defaultLocale), "Default locale \"" + defaultLocale + "\" is not canonicalized and structurally valid language tag.");
return true;
});

View File

@ -16,5 +16,4 @@ testWithIntlConstructors(function (Constructor) {
assert.sameValue(supportedForUndefined.length, supportedForEmptyList.length, "Supported locales differ between undefined and empty list input.");
// we don't compare the elements because length should be 0 - let's just verify that
assert.sameValue(supportedForUndefined.length, 0, "Internal test error: Assumption about length being 0 is invalid.");
return true;
});

View File

@ -68,6 +68,4 @@ testWithIntlConstructors(function (Constructor) {
assert.sameValue(error1.name, error2.name, "Single locale string " + locale + " results in error " + error1.name + ", but locale list [" + locale + "] results in error " + error2.name + ".");
}
});
return true;
});

View File

@ -28,6 +28,4 @@ testWithIntlConstructors(function (Constructor) {
assert.sameValue(supportedForNumber.length, supportedForEmptyList.length, "Supported locales differ between numeric and empty list input.");
var supportedForBoolean = Constructor.supportedLocalesOf(true);
assert.sameValue(supportedForBoolean.length, supportedForEmptyList.length, "Supported locales differ between boolean and empty list input.");
return true;
});

View File

@ -16,6 +16,4 @@ testWithIntlConstructors(function (Constructor) {
var supported = Constructor.supportedLocalesOf([value]);
}, "" + value + " as locale was not rejected.");
});
return true;
});

View File

@ -32,6 +32,4 @@ testWithIntlConstructors(function (Constructor) {
var supported = Constructor.supportedLocalesOf(unsupportedByConstructor,
{localeMatcher: "lookup"});
assert.sameValue(supported.length > 0, false, "Locale " + supported[0] + " is returned by supportedLocalesOf but not by resolvedOptions.");
return true;
});

View File

@ -15,6 +15,4 @@ taintProperties(["locale", "extension", "extensionIndex"]);
testWithIntlConstructors(function (Constructor) {
var locale = new Constructor(undefined, {localeMatcher: "lookup"}).resolvedOptions().locale;
assert(isCanonicalizedStructurallyValidLanguageTag(locale), "Constructor returns invalid locale " + locale + ".");
return true;
});

View File

@ -15,6 +15,4 @@ taintProperties(["dataLocale", "nu", "ca", "co", "locale"]);
testWithIntlConstructors(function (Constructor) {
var locale = new Constructor(undefined, {localeMatcher: "lookup"}).resolvedOptions().locale;
assert(isCanonicalizedStructurallyValidLanguageTag(locale), "Constructor returns invalid locale " + locale + ".");
return true;
});

View File

@ -20,6 +20,4 @@ testWithIntlConstructors(function (Constructor) {
{localeMatcher: matcher});
assert.sameValue(canonicalized.length > 1, false, "Canonicalization with matcher " + matcher + " didn't remove duplicate language tags from locale list.");
});
return true;
});

View File

@ -16,6 +16,4 @@ testWithIntlConstructors(function (Constructor) {
var supported = Constructor.supportedLocalesOf([], {localeMatcher: matcher});
assert.sameValue(supported.length, 0, "SupportedLocales with matcher " + matcher + " returned a non-empty list for an empty list.");
});
return true;
});

View File

@ -35,6 +35,4 @@ testWithIntlConstructors(function (Constructor) {
}
});
});
return true;
});

View File

@ -21,6 +21,4 @@ testWithIntlConstructors(function (Constructor) {
assert.sameValue(supported.indexOf(noLinguisticContent), -1, "SupportedLocales returned the \"no linguistic content\" locale with matcher " + matcher + ".");
assert.sameValue(supported.length > 1, false, "SupportedLocales returned stray locales: " + supported.join(", ") + " with matcher " + matcher + ".");
});
return true;
});

View File

@ -22,6 +22,4 @@ testWithIntlConstructors(function (Constructor) {
var supported = Constructor.supportedLocalesOf([defaultLocale], {localeMatcher: value});
}, "Invalid localeMatcher value " + value + " was not rejected.");
});
return true;
});

View File

@ -24,6 +24,4 @@ testWithIntlConstructors(function (Constructor) {
testFrozenProperty(supported, i);
}
testFrozenProperty(supported, "length");
return true;
});

View File

@ -20,6 +20,4 @@ testWithIntlConstructors(function (Constructor) {
obj = Constructor();
newObj = Intl.Collator.call(obj);
assert.notSameValue(obj, newObj, "Collator object created with constructor as function was not ignored as this-value.");
return true;
});

View File

@ -12,7 +12,7 @@ includes: [testIntl.js]
testWithIntlConstructors(function (Constructor) {
if (Constructor === Intl.DateTimeFormat)
return true;
return;
var obj, newObj;
@ -25,6 +25,4 @@ testWithIntlConstructors(function (Constructor) {
obj = Constructor();
newObj = Intl.DateTimeFormat.call(obj);
assert.notSameValue(obj, newObj, "DateTimeFormat object created with constructor as function was not ignored as this-value.");
return true;
});

View File

@ -12,7 +12,7 @@ includes: [testIntl.js]
testWithIntlConstructors(function (Constructor) {
if (Constructor === Intl.NumberFormat)
return true;
return;
var obj, newObj;
@ -25,6 +25,4 @@ testWithIntlConstructors(function (Constructor) {
obj = Constructor();
newObj = Intl.NumberFormat.call(obj);
assert.notSameValue(obj, newObj, "NumberFormat object created with constructor as function was not ignored as this-value.");
return true;
});

View File

@ -22,6 +22,4 @@ testWithIntlConstructors(function (Constructor) {
assert.throws(TypeError, function() {
Intl.PluralRules.call(obj)
}, "Intl.PluralRules throws when called as a function with an Intl-object as this-value");
return true;
});