diff options
Diffstat (limited to 'js/src/tests/test262/intl402/DurationFormat/prototype/format/invalid-arguments-throws.js')
-rw-r--r-- | js/src/tests/test262/intl402/DurationFormat/prototype/format/invalid-arguments-throws.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/invalid-arguments-throws.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/invalid-arguments-throws.js new file mode 100644 index 0000000000..ed9c268b63 --- /dev/null +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/invalid-arguments-throws.js @@ -0,0 +1,31 @@ +// |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.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) +features: [Intl.DurationFormat] +---*/ + +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({ year: 1 }) }, "unsuported property"); +assert.throws(TypeError, () => { df.format({ years: undefined }) }, "supported property set undefined"); +assert.throws(TypeError, () => { df.format(Symbol())}, "symbol"); +assert.throws(RangeError, () => { df.format("bad string")}, "bad string"); + +reportCompare(0, 0); |