diff options
Diffstat (limited to 'js/src/tests/test262/intl402/DateTimeFormat/constructor-options-dateStyle-valid.js')
-rw-r--r-- | js/src/tests/test262/intl402/DateTimeFormat/constructor-options-dateStyle-valid.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/DateTimeFormat/constructor-options-dateStyle-valid.js b/js/src/tests/test262/intl402/DateTimeFormat/constructor-options-dateStyle-valid.js new file mode 100644 index 0000000000..0f6dc77f22 --- /dev/null +++ b/js/src/tests/test262/intl402/DateTimeFormat/constructor-options-dateStyle-valid.js @@ -0,0 +1,39 @@ +// Copyright 2019 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-createdatetimeformat +description: > + Checks handling of the options argument to the DateTimeFormat constructor. +info: | + CreateDateTimeFormat ( dateTimeFormat, locales, options, required, defaults ) + + ... + 39. Let dateStyle be ? GetOption(options, "dateStyle", "string", « "full", "long", "medium", "short" », undefined). + 40. If dateStyle is not undefined, set dateTimeFormat.[[DateStyle]] to dateStyle. +features: [Intl.DateTimeFormat-datetimestyle] +---*/ + + +const validOptions = [ + [undefined, undefined], + ["full", "full"], + ["long", "long"], + ["medium", "medium"], + ["short", "short"], + [{ toString() { return "full"; } }, "full"], + [{ valueOf() { return "long"; }, toString: undefined }, "long"], +]; +for (const [dateStyle, expected] of validOptions) { + const dtf = new Intl.DateTimeFormat("en", { dateStyle }); + const options = dtf.resolvedOptions(); + assert.sameValue(options.dateStyle, expected); + const propdesc = Object.getOwnPropertyDescriptor(options, "dateStyle"); + if (expected === undefined) { + assert.sameValue(propdesc, undefined); + } else { + assert.sameValue(propdesc.value, expected); + } +} + +reportCompare(0, 0); |