summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/invalid-arguments-throws.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/invalid-arguments-throws.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/invalid-arguments-throws.js')
-rw-r--r--js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/invalid-arguments-throws.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/invalid-arguments-throws.js b/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/invalid-arguments-throws.js
new file mode 100644
index 0000000000..7f3105086f
--- /dev/null
+++ b/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/invalid-arguments-throws.js
@@ -0,0 +1,40 @@
+// |reftest| skip -- Intl.DurationFormat is not supported
+// 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)
+features: [Intl.DurationFormat]
+---*/
+
+const df = new Intl.DurationFormat();
+const testOptions = [ "years", "months", "weeks", "days", "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds"];
+
+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({ year: 1 }) }, "unsuported property");
+assert.throws(TypeError, () => { df.formatToParts({ years: undefined }) }, "supported property set undefined");
+assert.throws(TypeError, () => { df.formatToParts(Symbol())}, "symbol");
+assert.throws(RangeError, () => { df.formatToParts("bad string")}, "bad string");
+
+testOptions.forEach( option => {
+ assert.throws(RangeError, () => { df.formatToParts({ [option]: 2.5 })}, " duration properties must be integers");
+});
+
+testOptions.forEach( option => {
+ assert.throws(RangeError, () => { df.formatToParts({ [option]: -Infinity })}, " duration properties must be integers");
+});
+
+reportCompare(0, 0);