From 89ab2fd92b9d1df4c43980b7d06d35aaa4ff95f9 Mon Sep 17 00:00:00 2001 From: Romulo Cintra Date: Wed, 29 Jun 2022 18:29:04 +0200 Subject: [PATCH 1/8] increase coverage Intl.DurationFormat --- .../prototype/format/branding.js | 22 ++++++++++++++++ .../format/invalid-arguments-throws.js | 25 +++++++++++++++++++ .../DurationFormat/prototype/format/length.js | 6 ++--- .../prototype/format/not-a-constructor.js | 21 ++++++++++++++++ .../prototype/format/throw-invoked-as-func.js | 9 ++++--- .../prototype/formatToParts/branding.js | 22 ++++++++++++++++ .../formatToParts/invalid-arguments-throws.js | 25 +++++++++++++++++++ .../formatToParts/not-a-constructor.js | 21 ++++++++++++++++ .../formatToParts/throw-invoked-as-func.js | 9 ++++--- 9 files changed, 149 insertions(+), 11 deletions(-) create mode 100644 test/intl402/DurationFormat/prototype/format/branding.js create mode 100644 test/intl402/DurationFormat/prototype/format/invalid-arguments-throws.js create mode 100644 test/intl402/DurationFormat/prototype/format/not-a-constructor.js create mode 100644 test/intl402/DurationFormat/prototype/formatToParts/branding.js create mode 100644 test/intl402/DurationFormat/prototype/formatToParts/invalid-arguments-throws.js create mode 100644 test/intl402/DurationFormat/prototype/formatToParts/not-a-constructor.js diff --git a/test/intl402/DurationFormat/prototype/format/branding.js b/test/intl402/DurationFormat/prototype/format/branding.js new file mode 100644 index 00000000000..9f671276981 --- /dev/null +++ b/test/intl402/DurationFormat/prototype/format/branding.js @@ -0,0 +1,22 @@ +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat.prototype.format +description: Verifies the branding check for the "format" function of the DurationFormat prototype object. +features: [Intl.DurationFormat] +---*/ + +const format = Intl.DurationFormat.prototype.format; + +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.DurationFormat), "Intl.DurationFormat"); +assert.throws(TypeError, () => format.call(Intl.DurationFormat.prototype), "Intl.DurationFormat.prototype"); diff --git a/test/intl402/DurationFormat/prototype/format/invalid-arguments-throws.js b/test/intl402/DurationFormat/prototype/format/invalid-arguments-throws.js new file mode 100644 index 00000000000..9e49d3ab545 --- /dev/null +++ b/test/intl402/DurationFormat/prototype/format/invalid-arguments-throws.js @@ -0,0 +1,25 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat.prototype.format +description: > + "format" basic tests for invalid arguments that should throw TypeError exception. +info: | + Intl.DurationFormat.prototype.format(duration) + (...) + 3. Let record be ? ToDurationRecord(duration) +---*/ + +const df = new Intl.DurationFormat(); + +assert.throws(TypeError, () => { df.format(undefined) }, "undefined" ); +assert.throws(TypeError, () => { df.format(null) }, "null"); +assert.throws(TypeError, () => { df.format(true) }, "true"); +assert.throws(TypeError, () => { df.format(-12) }, "-12"); +assert.throws(TypeError, () => { df.format(-12n) }, "-12n"); +assert.throws(TypeError, () => { df.format(1) }, "1"); +assert.throws(TypeError, () => { df.format(2n) }, "2n"); +assert.throws(TypeError, () => { df.format({}) }, "plain object"); +assert.throws(TypeError, () => { df.format(Symbol())}, "symbol"); +assert.throws(TypeError, () => { df.format("bad string")}, "bad string"); diff --git a/test/intl402/DurationFormat/prototype/format/length.js b/test/intl402/DurationFormat/prototype/format/length.js index 14d71405739..c4f005f608d 100644 --- a/test/intl402/DurationFormat/prototype/format/length.js +++ b/test/intl402/DurationFormat/prototype/format/length.js @@ -2,9 +2,9 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-intl.datetimeformat.prototype.format +esid: sec-intl.DurationFormat.prototype.format description: > - Intl.DateTimeFormat.prototype.format.length is 1. + Intl.DurationFormat.prototype.format.length is 1. info: | Intl.DurationFormat.prototype.format ( duration ) @@ -25,7 +25,7 @@ features: [Intl.DurationFormat] includes: [propertyHelper.js] ---*/ -assert.sameValue(Intl.DateTimeFormat.prototype.format.length, 1); +assert.sameValue(Intl.DurationFormat.prototype.format.length, 1); verifyProperty(Intl.DurationFormat.prototype.format, "length", { value: 1, diff --git a/test/intl402/DurationFormat/prototype/format/not-a-constructor.js b/test/intl402/DurationFormat/prototype/format/not-a-constructor.js new file mode 100644 index 00000000000..b5c848c9d60 --- /dev/null +++ b/test/intl402/DurationFormat/prototype/format/not-a-constructor.js @@ -0,0 +1,21 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat.prototype.format +description: > + Intl.DurationFormat.prototype.format does not implement [[Construct]], is not new-able +info: | + Built-in function objects that are not identified as constructors do not implement the + [[Construct]] internal method unless otherwise specified in the description of a particular + function. +includes: [isConstructor.js] +features: [Reflect.construct, Intl.DurationFormat] +---*/ + +assert.throws(TypeError, () => { + new Intl.DurationFormat.prototype.format(); +}, "Calling as constructor"); + +assert.sameValue(isConstructor(Intl.DurationFormat.prototype.format), false, + "isConstructor(Intl.DurationFormat.prototype.format)"); diff --git a/test/intl402/DurationFormat/prototype/format/throw-invoked-as-func.js b/test/intl402/DurationFormat/prototype/format/throw-invoked-as-func.js index fa075a1f41e..5b9eb18f794 100644 --- a/test/intl402/DurationFormat/prototype/format/throw-invoked-as-func.js +++ b/test/intl402/DurationFormat/prototype/format/throw-invoked-as-func.js @@ -14,8 +14,9 @@ features: [Intl.DurationFormat] const df = new Intl.DurationFormat(); // Perform ? RequireInternalSlot(df, [[InitializedDurationFormat]]). -let f = df['format']; - -assert.sameValue(typeof f, 'function'); -assert.throws(TypeError, () => { f('PT12.3456S') }); +let f = df["format"]; +assert.sameValue(typeof f, "function"); +assert.throws(TypeError, () => { + f({ hours: 1, minutes: 46, seconds: 40 }); +}); diff --git a/test/intl402/DurationFormat/prototype/formatToParts/branding.js b/test/intl402/DurationFormat/prototype/formatToParts/branding.js new file mode 100644 index 00000000000..f4283d1fbec --- /dev/null +++ b/test/intl402/DurationFormat/prototype/formatToParts/branding.js @@ -0,0 +1,22 @@ +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat.prototype.formatToParts +description: Verifies the branding check for the "formatToParts" function of the DurationFormat prototype object. +features: [Intl.DurationFormat] +---*/ + +const formatToParts = Intl.DurationFormat.prototype.formatToParts; + +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.DurationFormat), "Intl.DurationFormat"); +assert.throws(TypeError, () => formatToParts.call(Intl.DurationFormat.prototype), "Intl.DurationFormat.prototype"); diff --git a/test/intl402/DurationFormat/prototype/formatToParts/invalid-arguments-throws.js b/test/intl402/DurationFormat/prototype/formatToParts/invalid-arguments-throws.js new file mode 100644 index 00000000000..fb781381038 --- /dev/null +++ b/test/intl402/DurationFormat/prototype/formatToParts/invalid-arguments-throws.js @@ -0,0 +1,25 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat.prototype.formatToParts +description: > + "formatToParts" basic tests for invalid arguments that should throw TypeError exception. +info: | + Intl.DurationFormat.prototype.formatToParts(duration) + (...) + 3. Let record be ? ToDurationRecord(duration) +---*/ + +const df = new Intl.DurationFormat(); + +assert.throws(TypeError, () => { df.formatToParts(undefined) }, "undefined" ); +assert.throws(TypeError, () => { df.formatToParts(null) }, "null"); +assert.throws(TypeError, () => { df.formatToParts(true) }, "true"); +assert.throws(TypeError, () => { df.formatToParts(-12) }, "-12"); +assert.throws(TypeError, () => { df.formatToParts(-12n) }, "-12n"); +assert.throws(TypeError, () => { df.formatToParts(1) }, "1"); +assert.throws(TypeError, () => { df.formatToParts(2n) }, "2n"); +assert.throws(TypeError, () => { df.formatToParts({}) }, "plain object"); +assert.throws(TypeError, () => { df.formatToParts(Symbol())}, "symbol"); +assert.throws(TypeError, () => { df.formatToParts("bad string")}, "bad string"); diff --git a/test/intl402/DurationFormat/prototype/formatToParts/not-a-constructor.js b/test/intl402/DurationFormat/prototype/formatToParts/not-a-constructor.js new file mode 100644 index 00000000000..f97cd4c0a62 --- /dev/null +++ b/test/intl402/DurationFormat/prototype/formatToParts/not-a-constructor.js @@ -0,0 +1,21 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat.prototype.format +description: > + Intl.DurationFormat.prototype.format does not implement [[Construct]], is not new-able +info: | + Built-in function objects that are not identified as constructors do not implement the + [[Construct]] internal method unless otherwise specified in the description of a particular + function. +includes: [isConstructor.js] +features: [Reflect.construct, Intl.DurationFormat] +---*/ + +assert.throws(TypeError, () => { + new Intl.DurationFormat.prototype.formatToParts(); +}, "Calling as constructor"); + +assert.sameValue(isConstructor(Intl.DurationFormat.prototype.formatToParts), false, + "isConstructor(Intl.DurationFormat.prototype.formatToParts)"); diff --git a/test/intl402/DurationFormat/prototype/formatToParts/throw-invoked-as-func.js b/test/intl402/DurationFormat/prototype/formatToParts/throw-invoked-as-func.js index 66af26956c3..84b07e6e7c0 100644 --- a/test/intl402/DurationFormat/prototype/formatToParts/throw-invoked-as-func.js +++ b/test/intl402/DurationFormat/prototype/formatToParts/throw-invoked-as-func.js @@ -14,8 +14,9 @@ features: [Intl.DurationFormat] const df = new Intl.DurationFormat(); // Perform ? RequireInternalSlot(df, [[InitializedDurationFormat]]). -let f = df['formatToParts']; - -assert.sameValue(typeof f, 'function'); -assert.throws(TypeError, () => { f('PT12.3456S') }); +let f = df["formatToParts"]; +assert.sameValue(typeof f, "function"); +assert.throws(TypeError, () => { + f({ hours: 1, minutes: 46, seconds: 40 }); +}); From 22bc8a12f613ba73357436dd3c15663c5cea11b1 Mon Sep 17 00:00:00 2001 From: Romulo Cintra Date: Thu, 30 Jun 2022 08:54:21 +0200 Subject: [PATCH 2/8] Update test/intl402/DurationFormat/prototype/format/length.js Co-authored-by: Ms2ger --- test/intl402/DurationFormat/prototype/format/length.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/intl402/DurationFormat/prototype/format/length.js b/test/intl402/DurationFormat/prototype/format/length.js index c4f005f608d..87e92204254 100644 --- a/test/intl402/DurationFormat/prototype/format/length.js +++ b/test/intl402/DurationFormat/prototype/format/length.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-intl.DurationFormat.prototype.format +esid: sec-Intl.DurationFormat.prototype.format description: > Intl.DurationFormat.prototype.format.length is 1. info: | From 8ff3ba6b5059f0ae8f85d899a3ca5e4426e401fb Mon Sep 17 00:00:00 2001 From: Romulo Cintra Date: Thu, 30 Jun 2022 08:54:51 +0200 Subject: [PATCH 3/8] Update test/intl402/DurationFormat/prototype/format/length.js Co-authored-by: Ms2ger --- test/intl402/DurationFormat/prototype/format/length.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/intl402/DurationFormat/prototype/format/length.js b/test/intl402/DurationFormat/prototype/format/length.js index 87e92204254..9d9a16fc7fb 100644 --- a/test/intl402/DurationFormat/prototype/format/length.js +++ b/test/intl402/DurationFormat/prototype/format/length.js @@ -25,8 +25,6 @@ features: [Intl.DurationFormat] includes: [propertyHelper.js] ---*/ -assert.sameValue(Intl.DurationFormat.prototype.format.length, 1); - verifyProperty(Intl.DurationFormat.prototype.format, "length", { value: 1, writable: false, From a5e5530c063554ae7201077d04803d06fbe57bb7 Mon Sep 17 00:00:00 2001 From: Romulo Cintra Date: Thu, 30 Jun 2022 08:55:11 +0200 Subject: [PATCH 4/8] Update test/intl402/DurationFormat/prototype/format/throw-invoked-as-func.js Co-authored-by: Ms2ger --- .../DurationFormat/prototype/format/throw-invoked-as-func.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/intl402/DurationFormat/prototype/format/throw-invoked-as-func.js b/test/intl402/DurationFormat/prototype/format/throw-invoked-as-func.js index 5b9eb18f794..6599e107141 100644 --- a/test/intl402/DurationFormat/prototype/format/throw-invoked-as-func.js +++ b/test/intl402/DurationFormat/prototype/format/throw-invoked-as-func.js @@ -13,7 +13,6 @@ features: [Intl.DurationFormat] const df = new Intl.DurationFormat(); -// Perform ? RequireInternalSlot(df, [[InitializedDurationFormat]]). let f = df["format"]; assert.sameValue(typeof f, "function"); From eb1429f95d74054756894c35aa335c045f403b91 Mon Sep 17 00:00:00 2001 From: Romulo Cintra Date: Thu, 30 Jun 2022 08:55:28 +0200 Subject: [PATCH 5/8] Update test/intl402/DurationFormat/prototype/formatToParts/not-a-constructor.js Co-authored-by: Ms2ger --- .../DurationFormat/prototype/formatToParts/not-a-constructor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/intl402/DurationFormat/prototype/formatToParts/not-a-constructor.js b/test/intl402/DurationFormat/prototype/formatToParts/not-a-constructor.js index f97cd4c0a62..a477b339c18 100644 --- a/test/intl402/DurationFormat/prototype/formatToParts/not-a-constructor.js +++ b/test/intl402/DurationFormat/prototype/formatToParts/not-a-constructor.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-Intl.DurationFormat.prototype.format +esid: sec-Intl.DurationFormat.prototype.formatToParts description: > Intl.DurationFormat.prototype.format does not implement [[Construct]], is not new-able info: | From c34a8f66b9126b46ab37c19eb5531c5e829aa4a8 Mon Sep 17 00:00:00 2001 From: Romulo Cintra Date: Thu, 30 Jun 2022 08:55:37 +0200 Subject: [PATCH 6/8] Update test/intl402/DurationFormat/prototype/formatToParts/not-a-constructor.js Co-authored-by: Ms2ger --- .../DurationFormat/prototype/formatToParts/not-a-constructor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/intl402/DurationFormat/prototype/formatToParts/not-a-constructor.js b/test/intl402/DurationFormat/prototype/formatToParts/not-a-constructor.js index a477b339c18..f6535313f60 100644 --- a/test/intl402/DurationFormat/prototype/formatToParts/not-a-constructor.js +++ b/test/intl402/DurationFormat/prototype/formatToParts/not-a-constructor.js @@ -4,7 +4,7 @@ /*--- esid: sec-Intl.DurationFormat.prototype.formatToParts description: > - Intl.DurationFormat.prototype.format does not implement [[Construct]], is not new-able + Intl.DurationFormat.prototype.formatToParts does not implement [[Construct]], is not new-able info: | Built-in function objects that are not identified as constructors do not implement the [[Construct]] internal method unless otherwise specified in the description of a particular From 0025aabf782c2746460567c877de415c2946e5db Mon Sep 17 00:00:00 2001 From: Romulo Cintra Date: Thu, 30 Jun 2022 11:50:00 +0200 Subject: [PATCH 7/8] address reviews --- test/intl402/DurationFormat/prototype/format/branding.js | 2 +- .../DurationFormat/prototype/format/invalid-arguments-throws.js | 2 ++ test/intl402/DurationFormat/prototype/formatToParts/branding.js | 2 +- .../prototype/formatToParts/invalid-arguments-throws.js | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/test/intl402/DurationFormat/prototype/format/branding.js b/test/intl402/DurationFormat/prototype/format/branding.js index 9f671276981..6c32c369217 100644 --- a/test/intl402/DurationFormat/prototype/format/branding.js +++ b/test/intl402/DurationFormat/prototype/format/branding.js @@ -11,7 +11,7 @@ const format = Intl.DurationFormat.prototype.format; assert.sameValue(typeof format, "function"); -assert.throws(TypeError, () => format.call(undefined), "undefined"); +assert.throws(TypeError, () => format.call(undefined, { years : 2 }), "undefined"); assert.throws(TypeError, () => format.call(null), "null"); assert.throws(TypeError, () => format.call(true), "true"); assert.throws(TypeError, () => format.call(""), "empty string"); diff --git a/test/intl402/DurationFormat/prototype/format/invalid-arguments-throws.js b/test/intl402/DurationFormat/prototype/format/invalid-arguments-throws.js index 9e49d3ab545..abb124357d6 100644 --- a/test/intl402/DurationFormat/prototype/format/invalid-arguments-throws.js +++ b/test/intl402/DurationFormat/prototype/format/invalid-arguments-throws.js @@ -21,5 +21,7 @@ assert.throws(TypeError, () => { df.format(-12n) }, "-12n"); assert.throws(TypeError, () => { df.format(1) }, "1"); assert.throws(TypeError, () => { df.format(2n) }, "2n"); assert.throws(TypeError, () => { df.format({}) }, "plain object"); +assert.throws(TypeError, () => { df.format({ year: 1 }) }, "unsuported property"); +assert.throws(TypeError, () => { df.format({ years: undefined }) }, "supported property set undefined"); assert.throws(TypeError, () => { df.format(Symbol())}, "symbol"); assert.throws(TypeError, () => { df.format("bad string")}, "bad string"); diff --git a/test/intl402/DurationFormat/prototype/formatToParts/branding.js b/test/intl402/DurationFormat/prototype/formatToParts/branding.js index f4283d1fbec..3c926506e83 100644 --- a/test/intl402/DurationFormat/prototype/formatToParts/branding.js +++ b/test/intl402/DurationFormat/prototype/formatToParts/branding.js @@ -11,7 +11,7 @@ const formatToParts = Intl.DurationFormat.prototype.formatToParts; assert.sameValue(typeof formatToParts, "function"); -assert.throws(TypeError, () => formatToParts.call(undefined), "undefined"); +assert.throws(TypeError, () => formatToParts.call(undefined, { years : 2 }), "undefined"); assert.throws(TypeError, () => formatToParts.call(null), "null"); assert.throws(TypeError, () => formatToParts.call(true), "true"); assert.throws(TypeError, () => formatToParts.call(""), "empty string"); diff --git a/test/intl402/DurationFormat/prototype/formatToParts/invalid-arguments-throws.js b/test/intl402/DurationFormat/prototype/formatToParts/invalid-arguments-throws.js index fb781381038..69c4356cf42 100644 --- a/test/intl402/DurationFormat/prototype/formatToParts/invalid-arguments-throws.js +++ b/test/intl402/DurationFormat/prototype/formatToParts/invalid-arguments-throws.js @@ -21,5 +21,7 @@ assert.throws(TypeError, () => { df.formatToParts(-12n) }, "-12n"); assert.throws(TypeError, () => { df.formatToParts(1) }, "1"); assert.throws(TypeError, () => { df.formatToParts(2n) }, "2n"); assert.throws(TypeError, () => { df.formatToParts({}) }, "plain object"); +assert.throws(TypeError, () => { df.formatToParts({ year: 1 }) }, "unsuported property"); +assert.throws(TypeError, () => { df.formatToParts({ years: undefined }) }, "supported property set undefined"); assert.throws(TypeError, () => { df.formatToParts(Symbol())}, "symbol"); assert.throws(TypeError, () => { df.formatToParts("bad string")}, "bad string"); From b1404df44112ecf176d1390583576b2fb7c1c056 Mon Sep 17 00:00:00 2001 From: Romulo Cintra Date: Thu, 30 Jun 2022 13:05:14 +0200 Subject: [PATCH 8/8] Update branding tests --- .../DurationFormat/prototype/format/branding.js | 16 ++++++++-------- .../prototype/formatToParts/branding.js | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/test/intl402/DurationFormat/prototype/format/branding.js b/test/intl402/DurationFormat/prototype/format/branding.js index 6c32c369217..282d3fb14aa 100644 --- a/test/intl402/DurationFormat/prototype/format/branding.js +++ b/test/intl402/DurationFormat/prototype/format/branding.js @@ -12,11 +12,11 @@ const format = Intl.DurationFormat.prototype.format; assert.sameValue(typeof format, "function"); assert.throws(TypeError, () => format.call(undefined, { years : 2 }), "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.DurationFormat), "Intl.DurationFormat"); -assert.throws(TypeError, () => format.call(Intl.DurationFormat.prototype), "Intl.DurationFormat.prototype"); +assert.throws(TypeError, () => format.call(null, { years : 2 }), "null"); +assert.throws(TypeError, () => format.call(true, { years : 2 }), "true"); +assert.throws(TypeError, () => format.call("", { years : 2 }), "empty string"); +assert.throws(TypeError, () => format.call(Symbol(), { years : 2 }), "symbol"); +assert.throws(TypeError, () => format.call(1, { years : 2 }), "1"); +assert.throws(TypeError, () => format.call({}, { years : 2 }), "plain object"); +assert.throws(TypeError, () => format.call(Intl.DurationFormat, { years : 2 } ), "Intl.DurationFormat"); +assert.throws(TypeError, () => format.call(Intl.DurationFormat.prototype, { years : 2 }), "Intl.DurationFormat.prototype"); diff --git a/test/intl402/DurationFormat/prototype/formatToParts/branding.js b/test/intl402/DurationFormat/prototype/formatToParts/branding.js index 3c926506e83..e75c4481122 100644 --- a/test/intl402/DurationFormat/prototype/formatToParts/branding.js +++ b/test/intl402/DurationFormat/prototype/formatToParts/branding.js @@ -12,11 +12,11 @@ const formatToParts = Intl.DurationFormat.prototype.formatToParts; assert.sameValue(typeof formatToParts, "function"); assert.throws(TypeError, () => formatToParts.call(undefined, { years : 2 }), "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.DurationFormat), "Intl.DurationFormat"); -assert.throws(TypeError, () => formatToParts.call(Intl.DurationFormat.prototype), "Intl.DurationFormat.prototype"); +assert.throws(TypeError, () => formatToParts.call(null, { years : 2 }), "null"); +assert.throws(TypeError, () => formatToParts.call(true, { years : 2 }), "true"); +assert.throws(TypeError, () => formatToParts.call("", { years : 2 }), "empty string"); +assert.throws(TypeError, () => formatToParts.call(Symbol(), { years : 2 }), "symbol"); +assert.throws(TypeError, () => formatToParts.call(1, { years : 2 }), "1"); +assert.throws(TypeError, () => formatToParts.call({}, { years : 2 }), "plain object"); +assert.throws(TypeError, () => formatToParts.call(Intl.DurationFormat, { years : 2 } ), "Intl.DurationFormat"); +assert.throws(TypeError, () => formatToParts.call(Intl.DurationFormat.prototype, { years : 2 }), "Intl.DurationFormat.prototype");