From 3b09d0e2b51b45468d4739b2a00191520cfd2d45 Mon Sep 17 00:00:00 2001 From: Rick Waldron <waldron.rick@gmail.com> Date: Fri, 30 Nov 2018 11:47:57 -0500 Subject: [PATCH] Eliminate false positives: Intl.* --- .../constructor/newtarget-undefined.js | 2 ++ .../constructor/options-invalid.js | 5 ++++- .../ListFormat/prototype/format/branding.js | 22 ++++++++++--------- .../prototype/formatToParts/branding.js | 21 +++++++++--------- .../prototype/resolvedOptions/branding.js | 21 +++++++++--------- .../Locale/prototype/maximize/branding.js | 7 ++++-- .../Locale/prototype/minimize/branding.js | 7 ++++-- .../Locale/prototype/toString/branding.js | 7 ++++-- .../supportedLocalesOf/branding.js | 7 ++++-- .../prototype/format/branding.js | 22 ++++++++++--------- .../prototype/formatToParts/branding.js | 22 ++++++++++--------- .../prototype/resolvedOptions/branding.js | 22 ++++++++++--------- .../supportedLocalesOf/branding.js | 7 ++++-- .../prototype/resolvedOptions/branding.js | 22 ++++++++++--------- .../Segmenter/prototype/segment/branding.js | 22 ++++++++++--------- 15 files changed, 125 insertions(+), 91 deletions(-) diff --git a/test/intl402/ListFormat/constructor/constructor/newtarget-undefined.js b/test/intl402/ListFormat/constructor/constructor/newtarget-undefined.js index 635ea414c6..8edb28f203 100644 --- a/test/intl402/ListFormat/constructor/constructor/newtarget-undefined.js +++ b/test/intl402/ListFormat/constructor/constructor/newtarget-undefined.js @@ -12,6 +12,8 @@ info: | features: [Intl.ListFormat] ---*/ +assert.sameValue(typeof Intl.ListFormat, "function"); + assert.throws(TypeError, function() { Intl.ListFormat(); }); diff --git a/test/intl402/ListFormat/constructor/constructor/options-invalid.js b/test/intl402/ListFormat/constructor/constructor/options-invalid.js index 7f1dfd085c..1933e50b09 100644 --- a/test/intl402/ListFormat/constructor/constructor/options-invalid.js +++ b/test/intl402/ListFormat/constructor/constructor/options-invalid.js @@ -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); +}); diff --git a/test/intl402/ListFormat/prototype/format/branding.js b/test/intl402/ListFormat/prototype/format/branding.js index d232474165..23e8aa670b 100644 --- a/test/intl402/ListFormat/prototype/format/branding.js +++ b/test/intl402/ListFormat/prototype/format/branding.js @@ -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"); diff --git a/test/intl402/ListFormat/prototype/formatToParts/branding.js b/test/intl402/ListFormat/prototype/formatToParts/branding.js index 0ed866288d..4d1af02eb7 100644 --- a/test/intl402/ListFormat/prototype/formatToParts/branding.js +++ b/test/intl402/ListFormat/prototype/formatToParts/branding.js @@ -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"); diff --git a/test/intl402/ListFormat/prototype/resolvedOptions/branding.js b/test/intl402/ListFormat/prototype/resolvedOptions/branding.js index fbf3616c10..852ba562d0 100644 --- a/test/intl402/ListFormat/prototype/resolvedOptions/branding.js +++ b/test/intl402/ListFormat/prototype/resolvedOptions/branding.js @@ -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"); diff --git a/test/intl402/Locale/prototype/maximize/branding.js b/test/intl402/Locale/prototype/maximize/branding.js index 83c6e28c31..2605eb0864 100644 --- a/test/intl402/Locale/prototype/maximize/branding.js +++ b/test/intl402/Locale/prototype/maximize/branding.js @@ -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)); } diff --git a/test/intl402/Locale/prototype/minimize/branding.js b/test/intl402/Locale/prototype/minimize/branding.js index 41f42e692a..97dd903485 100644 --- a/test/intl402/Locale/prototype/minimize/branding.js +++ b/test/intl402/Locale/prototype/minimize/branding.js @@ -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)); } diff --git a/test/intl402/Locale/prototype/toString/branding.js b/test/intl402/Locale/prototype/toString/branding.js index 25d85a5758..2eb14d3dab 100644 --- a/test/intl402/Locale/prototype/toString/branding.js +++ b/test/intl402/Locale/prototype/toString/branding.js @@ -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)); } diff --git a/test/intl402/RelativeTimeFormat/constructor/supportedLocalesOf/branding.js b/test/intl402/RelativeTimeFormat/constructor/supportedLocalesOf/branding.js index 5b6384bd06..1e6a76cb51 100644 --- a/test/intl402/RelativeTimeFormat/constructor/supportedLocalesOf/branding.js +++ b/test/intl402/RelativeTimeFormat/constructor/supportedLocalesOf/branding.js @@ -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); } diff --git a/test/intl402/RelativeTimeFormat/prototype/format/branding.js b/test/intl402/RelativeTimeFormat/prototype/format/branding.js index 8dddd83b90..d8f4a75e4c 100644 --- a/test/intl402/RelativeTimeFormat/prototype/format/branding.js +++ b/test/intl402/RelativeTimeFormat/prototype/format/branding.js @@ -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"); diff --git a/test/intl402/RelativeTimeFormat/prototype/formatToParts/branding.js b/test/intl402/RelativeTimeFormat/prototype/formatToParts/branding.js index d654275554..d15513afbe 100644 --- a/test/intl402/RelativeTimeFormat/prototype/formatToParts/branding.js +++ b/test/intl402/RelativeTimeFormat/prototype/formatToParts/branding.js @@ -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"); diff --git a/test/intl402/RelativeTimeFormat/prototype/resolvedOptions/branding.js b/test/intl402/RelativeTimeFormat/prototype/resolvedOptions/branding.js index fd547383a5..dd90301b27 100644 --- a/test/intl402/RelativeTimeFormat/prototype/resolvedOptions/branding.js +++ b/test/intl402/RelativeTimeFormat/prototype/resolvedOptions/branding.js @@ -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"); diff --git a/test/intl402/Segmenter/constructor/supportedLocalesOf/branding.js b/test/intl402/Segmenter/constructor/supportedLocalesOf/branding.js index 462398b601..742dab1f31 100644 --- a/test/intl402/Segmenter/constructor/supportedLocalesOf/branding.js +++ b/test/intl402/Segmenter/constructor/supportedLocalesOf/branding.js @@ -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); } diff --git a/test/intl402/Segmenter/prototype/resolvedOptions/branding.js b/test/intl402/Segmenter/prototype/resolvedOptions/branding.js index 24d5a7bad6..b596e8e121 100644 --- a/test/intl402/Segmenter/prototype/resolvedOptions/branding.js +++ b/test/intl402/Segmenter/prototype/resolvedOptions/branding.js @@ -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"); diff --git a/test/intl402/Segmenter/prototype/segment/branding.js b/test/intl402/Segmenter/prototype/segment/branding.js index d344285d92..29f40d23e6 100644 --- a/test/intl402/Segmenter/prototype/segment/branding.js +++ b/test/intl402/Segmenter/prototype/segment/branding.js @@ -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"); -- GitLab