From 8faacdbaeee4a5ae9c3605c5d020428510cad34e Mon Sep 17 00:00:00 2001 From: jugglinmike Date: Fri, 16 Jul 2021 09:45:02 -0400 Subject: [PATCH] Add tests: "Extend TimeZoneName Option" proposal (#3042) --- ...onstructor-options-timeZoneName-invalid.js | 28 +++++++++++++++++++ .../constructor-options-timeZoneName-valid.js | 28 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 test/intl402/DateTimeFormat/constructor-options-timeZoneName-invalid.js create mode 100644 test/intl402/DateTimeFormat/constructor-options-timeZoneName-valid.js diff --git a/test/intl402/DateTimeFormat/constructor-options-timeZoneName-invalid.js b/test/intl402/DateTimeFormat/constructor-options-timeZoneName-invalid.js new file mode 100644 index 0000000000..67bd8c604d --- /dev/null +++ b/test/intl402/DateTimeFormat/constructor-options-timeZoneName-invalid.js @@ -0,0 +1,28 @@ +// Copyright 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-initializedatetimeformat +description: + Invalid values for the `timeZoneName` option of the DateTimeFormat constructor +features: [Intl.DateTimeFormat-extend-timezonename] +---*/ + +assert.throws(RangeError, function () { + new Intl.DateTimeFormat('en', { timeZoneName: '' }); +}, 'empty string'); + +assert.throws(RangeError, function () { + new Intl.DateTimeFormat('en', { timeZoneName: 'short ' }); +}, '"short "'); + +assert.throws(RangeError, function () { + new Intl.DateTimeFormat('en', { timeZoneName: ' long' }); +}, '" long"'); + +assert.throws(RangeError, function () { + new Intl.DateTimeFormat('en', { timeZoneName: 'offset' }); +}, '"offset"'); + +assert.throws(RangeError, function () { + new Intl.DateTimeFormat('en', { timeZoneName: 'generic' }); +}, '"generic"'); diff --git a/test/intl402/DateTimeFormat/constructor-options-timeZoneName-valid.js b/test/intl402/DateTimeFormat/constructor-options-timeZoneName-valid.js new file mode 100644 index 0000000000..eb64b7407d --- /dev/null +++ b/test/intl402/DateTimeFormat/constructor-options-timeZoneName-valid.js @@ -0,0 +1,28 @@ +// Copyright 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-initializedatetimeformat +description: + Valid values for the `timeZoneName` option of the DateTimeFormat constructor +features: [Intl.DateTimeFormat-extend-timezonename] +---*/ + +var dtf; + +dtf = new Intl.DateTimeFormat('en', { timeZoneName: 'short' }); +assert.sameValue(dtf.resolvedOptions().timeZoneName, 'short'); + +dtf = new Intl.DateTimeFormat('en', { timeZoneName: 'long' }); +assert.sameValue(dtf.resolvedOptions().timeZoneName, 'long'); + +dtf = new Intl.DateTimeFormat('en', { timeZoneName: 'shortOffset' }); +assert.sameValue(dtf.resolvedOptions().timeZoneName, 'shortOffset'); + +dtf = new Intl.DateTimeFormat('en', { timeZoneName: 'longOffset' }); +assert.sameValue(dtf.resolvedOptions().timeZoneName, 'longOffset'); + +dtf = new Intl.DateTimeFormat('en', { timeZoneName: 'shortGeneric' }); +assert.sameValue(dtf.resolvedOptions().timeZoneName, 'shortGeneric'); + +dtf = new Intl.DateTimeFormat('en', { timeZoneName: 'longGeneric' }); +assert.sameValue(dtf.resolvedOptions().timeZoneName, 'longGeneric');