Eliminate false positives: Intl.*

This commit is contained in:
Rick Waldron 2018-11-30 11:47:57 -05:00
parent 86deb370e7
commit 3b09d0e2b5
15 changed files with 125 additions and 91 deletions

View File

@ -12,6 +12,8 @@ info: |
features: [Intl.ListFormat]
---*/
assert.sameValue(typeof Intl.ListFormat, "function");
assert.throws(TypeError, function() {
Intl.ListFormat();
});

View File

@ -11,4 +11,7 @@ info: |
features: [Intl.ListFormat]
---*/
assert.throws(TypeError, function() { new Intl.ListFormat([], null) })
assert.sameValue(typeof Intl.ListFormat, "function");
assert.throws(TypeError, function() {
new Intl.ListFormat([], null);
});

View File

@ -12,14 +12,16 @@ info: |
features: [Intl.ListFormat]
---*/
const fn = Intl.ListFormat.prototype.format;
const format = Intl.ListFormat.prototype.format;
assert.throws(TypeError, () => fn.call(undefined), "undefined");
assert.throws(TypeError, () => fn.call(null), "null");
assert.throws(TypeError, () => fn.call(true), "true");
assert.throws(TypeError, () => fn.call(""), "empty string");
assert.throws(TypeError, () => fn.call(Symbol()), "symbol");
assert.throws(TypeError, () => fn.call(1), "1");
assert.throws(TypeError, () => fn.call({}), "plain object");
assert.throws(TypeError, () => fn.call(Intl.ListFormat), "Intl.ListFormat");
assert.throws(TypeError, () => fn.call(Intl.ListFormat.prototype), "Intl.ListFormat.prototype");
assert.sameValue(typeof format, "function");
assert.throws(TypeError, () => format.call(undefined), "undefined");
assert.throws(TypeError, () => format.call(null), "null");
assert.throws(TypeError, () => format.call(true), "true");
assert.throws(TypeError, () => format.call(""), "empty string");
assert.throws(TypeError, () => format.call(Symbol()), "symbol");
assert.throws(TypeError, () => format.call(1), "1");
assert.throws(TypeError, () => format.call({}), "plain object");
assert.throws(TypeError, () => format.call(Intl.ListFormat), "Intl.ListFormat");
assert.throws(TypeError, () => format.call(Intl.ListFormat.prototype), "Intl.ListFormat.prototype");

View File

@ -12,14 +12,15 @@ info: |
features: [Intl.ListFormat]
---*/
const fn = Intl.ListFormat.prototype.formatToParts;
const formatToParts = Intl.ListFormat.prototype.formatToParts;
assert.throws(TypeError, () => fn.call(undefined), "undefined");
assert.throws(TypeError, () => fn.call(null), "null");
assert.throws(TypeError, () => fn.call(true), "true");
assert.throws(TypeError, () => fn.call(""), "empty string");
assert.throws(TypeError, () => fn.call(Symbol()), "symbol");
assert.throws(TypeError, () => fn.call(1), "1");
assert.throws(TypeError, () => fn.call({}), "plain object");
assert.throws(TypeError, () => fn.call(Intl.ListFormat), "Intl.ListFormat");
assert.throws(TypeError, () => fn.call(Intl.ListFormat.prototype), "Intl.ListFormat.prototype");
assert.sameValue(typeof formatToParts, "function");
assert.throws(TypeError, () => formatToParts.call(undefined), "undefined");
assert.throws(TypeError, () => formatToParts.call(null), "null");
assert.throws(TypeError, () => formatToParts.call(true), "true");
assert.throws(TypeError, () => formatToParts.call(""), "empty string");
assert.throws(TypeError, () => formatToParts.call(Symbol()), "symbol");
assert.throws(TypeError, () => formatToParts.call(1), "1");
assert.throws(TypeError, () => formatToParts.call({}), "plain object");
assert.throws(TypeError, () => formatToParts.call(Intl.ListFormat), "Intl.ListFormat");
assert.throws(TypeError, () => formatToParts.call(Intl.ListFormat.prototype), "Intl.ListFormat.prototype");

View File

@ -12,14 +12,15 @@ info: |
features: [Intl.ListFormat]
---*/
const fn = Intl.ListFormat.prototype.resolvedOptions;
const resolvedOptions = Intl.ListFormat.prototype.resolvedOptions;
assert.throws(TypeError, () => fn.call(undefined), "undefined");
assert.throws(TypeError, () => fn.call(null), "null");
assert.throws(TypeError, () => fn.call(true), "true");
assert.throws(TypeError, () => fn.call(""), "empty string");
assert.throws(TypeError, () => fn.call(Symbol()), "symbol");
assert.throws(TypeError, () => fn.call(1), "1");
assert.throws(TypeError, () => fn.call({}), "plain object");
assert.throws(TypeError, () => fn.call(Intl.ListFormat), "Intl.ListFormat");
assert.throws(TypeError, () => fn.call(Intl.ListFormat.prototype), "Intl.ListFormat.prototype");
assert.sameValue(typeof resolvedOptions, "function");
assert.throws(TypeError, () => resolvedOptions.call(undefined), "undefined");
assert.throws(TypeError, () => resolvedOptions.call(null), "null");
assert.throws(TypeError, () => resolvedOptions.call(true), "true");
assert.throws(TypeError, () => resolvedOptions.call(""), "empty string");
assert.throws(TypeError, () => resolvedOptions.call(Symbol()), "symbol");
assert.throws(TypeError, () => resolvedOptions.call(1), "1");
assert.throws(TypeError, () => resolvedOptions.call({}), "plain object");
assert.throws(TypeError, () => resolvedOptions.call(Intl.ListFormat), "Intl.ListFormat");
assert.throws(TypeError, () => resolvedOptions.call(Intl.ListFormat.prototype), "Intl.ListFormat.prototype");

View File

@ -13,7 +13,10 @@ info: |
features: [Intl.Locale]
---*/
const fn = Intl.Locale.prototype.maximize;
const maximize = Intl.Locale.prototype.maximize;
assert.sameValue(typeof maximize, "function");
const invalidValues = [
undefined,
null,
@ -26,5 +29,5 @@ const invalidValues = [
];
for (const invalidValue of invalidValues) {
assert.throws(TypeError, () => fn.call(invalidValue));
assert.throws(TypeError, () => maximize.call(invalidValue));
}

View File

@ -13,7 +13,10 @@ info: |
features: [Intl.Locale]
---*/
const fn = Intl.Locale.prototype.minimize;
const minimize = Intl.Locale.prototype.minimize;
assert.sameValue(typeof minimize, "function");
const invalidValues = [
undefined,
null,
@ -26,5 +29,5 @@ const invalidValues = [
];
for (const invalidValue of invalidValues) {
assert.throws(TypeError, () => fn.call(invalidValue));
assert.throws(TypeError, () => minimize.call(invalidValue));
}

View File

@ -13,7 +13,10 @@ info: |
features: [Intl.Locale]
---*/
const fn = Intl.Locale.prototype.toString;
const toString = Intl.Locale.prototype.toString;
assert.sameValue(typeof toString, "function");
const invalidValues = [
undefined,
null,
@ -26,5 +29,5 @@ const invalidValues = [
];
for (const invalidValue of invalidValues) {
assert.throws(TypeError, () => fn.call(invalidValue));
assert.throws(TypeError, () => toString.call(invalidValue));
}

View File

@ -10,7 +10,10 @@ info: |
features: [Intl.RelativeTimeFormat]
---*/
const fn = Intl.RelativeTimeFormat.supportedLocalesOf;
const supportedLocalesOf = Intl.RelativeTimeFormat.supportedLocalesOf;
assert.sameValue(typeof supportedLocalesOf, "function");
const thisValues = [
undefined,
null,
@ -24,6 +27,6 @@ const thisValues = [
];
for (const thisValue of thisValues) {
const result = fn.call(thisValue);
const result = supportedLocalesOf.call(thisValue);
assert.sameValue(Array.isArray(result), true);
}

View File

@ -11,14 +11,16 @@ info: |
features: [Intl.RelativeTimeFormat]
---*/
const fn = Intl.RelativeTimeFormat.prototype.format;
const format = Intl.RelativeTimeFormat.prototype.format;
assert.throws(TypeError, () => fn.call(undefined), "undefined");
assert.throws(TypeError, () => fn.call(null), "null");
assert.throws(TypeError, () => fn.call(true), "true");
assert.throws(TypeError, () => fn.call(""), "empty string");
assert.throws(TypeError, () => fn.call(Symbol()), "symbol");
assert.throws(TypeError, () => fn.call(1), "1");
assert.throws(TypeError, () => fn.call({}), "plain object");
assert.throws(TypeError, () => fn.call(Intl.RelativeTimeFormat), "Intl.RelativeTimeFormat");
assert.throws(TypeError, () => fn.call(Intl.RelativeTimeFormat.prototype), "Intl.RelativeTimeFormat.prototype");
assert.sameValue(typeof format, "function");
assert.throws(TypeError, () => format.call(undefined), "undefined");
assert.throws(TypeError, () => format.call(null), "null");
assert.throws(TypeError, () => format.call(true), "true");
assert.throws(TypeError, () => format.call(""), "empty string");
assert.throws(TypeError, () => format.call(Symbol()), "symbol");
assert.throws(TypeError, () => format.call(1), "1");
assert.throws(TypeError, () => format.call({}), "plain object");
assert.throws(TypeError, () => format.call(Intl.RelativeTimeFormat), "Intl.RelativeTimeFormat");
assert.throws(TypeError, () => format.call(Intl.RelativeTimeFormat.prototype), "Intl.RelativeTimeFormat.prototype");

View File

@ -11,14 +11,16 @@ info: |
features: [Intl.RelativeTimeFormat]
---*/
const fn = Intl.RelativeTimeFormat.prototype.formatToParts;
const formatToParts = Intl.RelativeTimeFormat.prototype.formatToParts;
assert.throws(TypeError, () => fn.call(undefined), "undefined");
assert.throws(TypeError, () => fn.call(null), "null");
assert.throws(TypeError, () => fn.call(true), "true");
assert.throws(TypeError, () => fn.call(""), "empty string");
assert.throws(TypeError, () => fn.call(Symbol()), "symbol");
assert.throws(TypeError, () => fn.call(1), "1");
assert.throws(TypeError, () => fn.call({}), "plain object");
assert.throws(TypeError, () => fn.call(Intl.RelativeTimeFormat), "Intl.RelativeTimeFormat");
assert.throws(TypeError, () => fn.call(Intl.RelativeTimeFormat.prototype), "Intl.RelativeTimeFormat.prototype");
assert.sameValue(typeof formatToParts, "function");
assert.throws(TypeError, () => formatToParts.call(undefined), "undefined");
assert.throws(TypeError, () => formatToParts.call(null), "null");
assert.throws(TypeError, () => formatToParts.call(true), "true");
assert.throws(TypeError, () => formatToParts.call(""), "empty string");
assert.throws(TypeError, () => formatToParts.call(Symbol()), "symbol");
assert.throws(TypeError, () => formatToParts.call(1), "1");
assert.throws(TypeError, () => formatToParts.call({}), "plain object");
assert.throws(TypeError, () => formatToParts.call(Intl.RelativeTimeFormat), "Intl.RelativeTimeFormat");
assert.throws(TypeError, () => formatToParts.call(Intl.RelativeTimeFormat.prototype), "Intl.RelativeTimeFormat.prototype");

View File

@ -11,14 +11,16 @@ info: |
features: [Intl.RelativeTimeFormat]
---*/
const fn = Intl.RelativeTimeFormat.prototype.resolvedOptions;
const resolvedOptions = Intl.RelativeTimeFormat.prototype.resolvedOptions;
assert.throws(TypeError, () => fn.call(undefined), "undefined");
assert.throws(TypeError, () => fn.call(null), "null");
assert.throws(TypeError, () => fn.call(true), "true");
assert.throws(TypeError, () => fn.call(""), "empty string");
assert.throws(TypeError, () => fn.call(Symbol()), "symbol");
assert.throws(TypeError, () => fn.call(1), "1");
assert.throws(TypeError, () => fn.call({}), "plain object");
assert.throws(TypeError, () => fn.call(Intl.RelativeTimeFormat), "Intl.RelativeTimeFormat");
assert.throws(TypeError, () => fn.call(Intl.RelativeTimeFormat.prototype), "Intl.RelativeTimeFormat.prototype");
assert.sameValue(typeof resolvedOptions, "function");
assert.throws(TypeError, () => resolvedOptions.call(undefined), "undefined");
assert.throws(TypeError, () => resolvedOptions.call(null), "null");
assert.throws(TypeError, () => resolvedOptions.call(true), "true");
assert.throws(TypeError, () => resolvedOptions.call(""), "empty string");
assert.throws(TypeError, () => resolvedOptions.call(Symbol()), "symbol");
assert.throws(TypeError, () => resolvedOptions.call(1), "1");
assert.throws(TypeError, () => resolvedOptions.call({}), "plain object");
assert.throws(TypeError, () => resolvedOptions.call(Intl.RelativeTimeFormat), "Intl.RelativeTimeFormat");
assert.throws(TypeError, () => resolvedOptions.call(Intl.RelativeTimeFormat.prototype), "Intl.RelativeTimeFormat.prototype");

View File

@ -10,7 +10,10 @@ info: |
features: [Intl.Segmenter]
---*/
const fn = Intl.Segmenter.supportedLocalesOf;
const supportedLocalesOf = Intl.Segmenter.supportedLocalesOf;
assert.sameValue(typeof supportedLocalesOf, "function");
const thisValues = [
undefined,
null,
@ -24,6 +27,6 @@ const thisValues = [
];
for (const thisValue of thisValues) {
const result = fn.call(thisValue);
const result = supportedLocalesOf.call(thisValue);
assert.sameValue(Array.isArray(result), true);
}

View File

@ -11,14 +11,16 @@ info: |
features: [Intl.Segmenter]
---*/
const fn = Intl.Segmenter.prototype.resolvedOptions;
const resolvedOptions = Intl.Segmenter.prototype.resolvedOptions;
assert.throws(TypeError, () => fn.call(undefined), "undefined");
assert.throws(TypeError, () => fn.call(null), "null");
assert.throws(TypeError, () => fn.call(true), "true");
assert.throws(TypeError, () => fn.call(""), "empty string");
assert.throws(TypeError, () => fn.call(Symbol()), "symbol");
assert.throws(TypeError, () => fn.call(1), "1");
assert.throws(TypeError, () => fn.call({}), "plain object");
assert.throws(TypeError, () => fn.call(Intl.Segmenter), "Intl.Segmenter");
assert.throws(TypeError, () => fn.call(Intl.Segmenter.prototype), "Intl.Segmenter.prototype");
assert.sameValue(typeof resolvedOptions, "function");
assert.throws(TypeError, () => resolvedOptions.call(undefined), "undefined");
assert.throws(TypeError, () => resolvedOptions.call(null), "null");
assert.throws(TypeError, () => resolvedOptions.call(true), "true");
assert.throws(TypeError, () => resolvedOptions.call(""), "empty string");
assert.throws(TypeError, () => resolvedOptions.call(Symbol()), "symbol");
assert.throws(TypeError, () => resolvedOptions.call(1), "1");
assert.throws(TypeError, () => resolvedOptions.call({}), "plain object");
assert.throws(TypeError, () => resolvedOptions.call(Intl.Segmenter), "Intl.Segmenter");
assert.throws(TypeError, () => resolvedOptions.call(Intl.Segmenter.prototype), "Intl.Segmenter.prototype");

View File

@ -11,14 +11,16 @@ info: |
features: [Intl.Segmenter]
---*/
const fn = Intl.Segmenter.prototype.segment;
const segment = Intl.Segmenter.prototype.segment;
assert.throws(TypeError, () => fn.call(undefined), "undefined");
assert.throws(TypeError, () => fn.call(null), "null");
assert.throws(TypeError, () => fn.call(true), "true");
assert.throws(TypeError, () => fn.call(""), "empty string");
assert.throws(TypeError, () => fn.call(Symbol()), "symbol");
assert.throws(TypeError, () => fn.call(1), "1");
assert.throws(TypeError, () => fn.call({}), "plain object");
assert.throws(TypeError, () => fn.call(Intl.Segmenter), "Intl.Segmenter");
assert.throws(TypeError, () => fn.call(Intl.Segmenter.prototype), "Intl.Segmenter.prototype");
assert.sameValue(typeof segment, "function");
assert.throws(TypeError, () => segment.call(undefined), "undefined");
assert.throws(TypeError, () => segment.call(null), "null");
assert.throws(TypeError, () => segment.call(true), "true");
assert.throws(TypeError, () => segment.call(""), "empty string");
assert.throws(TypeError, () => segment.call(Symbol()), "symbol");
assert.throws(TypeError, () => segment.call(1), "1");
assert.throws(TypeError, () => segment.call({}), "plain object");
assert.throws(TypeError, () => segment.call(Intl.Segmenter), "Intl.Segmenter");
assert.throws(TypeError, () => segment.call(Intl.Segmenter.prototype), "Intl.Segmenter.prototype");