From 78907d6393c1e445ca05c614d7bfda760418ac4d Mon Sep 17 00:00:00 2001 From: Frank Tang Date: Thu, 28 Oct 2021 01:31:26 -0700 Subject: [PATCH] Move toLocaleString testing to intl402 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move part of the test of toLocaleString which depends on 15 Amendments to the ECMAScript® 2021 Internationalization API Specification to intl402. Keep behavior specified in earlier chapters in built-ins --- .../toLocaleString/options-conflict.js | 39 ++---------------- .../toLocaleString/options-conflict.js | 28 +------------ .../toLocaleString/options-conflict.js | 37 +---------------- .../toLocaleString/options-conflict.js | 28 +------------ .../toLocaleString/options-conflict.js | 40 ++----------------- .../toLocaleString/options-conflict.js | 14 +++++++ .../toLocaleString/options-conflict.js | 13 ++++++ .../toLocaleString/options-conflict.js | 14 +++++++ .../toLocaleString/options-conflict.js | 13 ++++++ .../toLocaleString/options-conflict.js | 14 +++++++ 10 files changed, 80 insertions(+), 160 deletions(-) create mode 100644 test/intl402/Temporal/Instant/prototype/toLocaleString/options-conflict.js create mode 100644 test/intl402/Temporal/PlainDate/prototype/toLocaleString/options-conflict.js create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/toLocaleString/options-conflict.js create mode 100644 test/intl402/Temporal/PlainTime/prototype/toLocaleString/options-conflict.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/toLocaleString/options-conflict.js diff --git a/test/built-ins/Temporal/Instant/prototype/toLocaleString/options-conflict.js b/test/built-ins/Temporal/Instant/prototype/toLocaleString/options-conflict.js index 490d6c27df..3c163623fe 100644 --- a/test/built-ins/Temporal/Instant/prototype/toLocaleString/options-conflict.js +++ b/test/built-ins/Temporal/Instant/prototype/toLocaleString/options-conflict.js @@ -2,46 +2,13 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sup-temporal.instant.prototype.tolocalestring +esid: sec-temporal.instant.prototype.tolocalestring description: > - Conflicting properties of dateStyle must be rejected with a TypeError for the options argument -info: | - Using sec-temporal-getdatetimeformatpattern: - GetDateTimeFormatPattern ( dateStyle, timeStyle, matcher, opt, dataLocaleData, hc ) - - 1. If dateStyle is not undefined or timeStyle is not undefined, then - a. For each row in Table 7, except the header row, do - i. Let prop be the name given in the Property column of the row. - ii. Let p be opt.[[]]. - iii. If p is not undefined, then - 1. Throw a TypeError exception. -features: [BigInt, Temporal] + toLocaleString return a string. +features: [Temporal] ---*/ -// Table 14 - Supported fields + example value for each field -const conflictingOptions = [ - [ "weekday", "short" ], - [ "era", "short" ], - [ "year", "numeric" ], - [ "month", "numeric" ], - [ "day", "numeric" ], - [ "hour", "numeric" ], - [ "minute", "numeric" ], - [ "second", "numeric" ], - [ "dayPeriod", "short" ], - [ "fractionalSecondDigits", 3 ], -]; const instant = new Temporal.Instant(957270896_987_650_000n); assert.sameValue(typeof instant.toLocaleString("en", { dateStyle: "short" }), "string"); assert.sameValue(typeof instant.toLocaleString("en", { timeStyle: "short" }), "string"); - -for (const [ option, value ] of conflictingOptions) { - assert.throws(TypeError, function() { - instant.toLocaleString("en", { [option]: value, dateStyle: "short" }); - }, `instant.toLocaleString("en", { ${option}: "${value}", dateStyle: "short" }) throws TypeError`); - - assert.throws(TypeError, function() { - instant.toLocaleString("en", { [option]: value, timeStyle: "short" }); - }, `instant.toLocaleString("en", { ${option}: "${value}", timeStyle: "short" }) throws TypeError`); -} diff --git a/test/built-ins/Temporal/PlainDate/prototype/toLocaleString/options-conflict.js b/test/built-ins/Temporal/PlainDate/prototype/toLocaleString/options-conflict.js index 3deb4c2b24..9af2628116 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toLocaleString/options-conflict.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toLocaleString/options-conflict.js @@ -2,36 +2,12 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sup-temporal.plaindate.prototype.tolocalestring +esid: sec-temporal.plaindate.prototype.tolocalestring description: > - Conflicting properties of dateStyle must be rejected with a TypeError for the options argument -info: | - Using sec-temporal-getdatetimeformatpattern: - GetDateTimeFormatPattern ( dateStyle, timeStyle, matcher, opt, dataLocaleData, hc ) - - 1. If dateStyle is not undefined or timeStyle is not undefined, then - a. For each row in Table 7, except the header row, do - i. Let prop be the name given in the Property column of the row. - ii. Let p be opt.[[]]. - iii. If p is not undefined, then - 1. Throw a TypeError exception. + toLocaleString return a string. features: [Temporal] ---*/ -// Table 14 - Supported fields + example value for each field -const conflictingOptions = [ - [ "weekday", "short" ], - [ "era", "short" ], - [ "year", "numeric" ], - [ "month", "numeric" ], - [ "day", "numeric" ], -]; const date = new Temporal.PlainDate(2000, 5, 2); assert.sameValue(typeof date.toLocaleString("en", { dateStyle: "short" }), "string"); - -for (const [ option, value ] of conflictingOptions) { - assert.throws(TypeError, function() { - date.toLocaleString("en", { [option]: value, dateStyle: "short" }); - }, `date.toLocaleString("en", { ${option}: "${value}", dateStyle: "short" }) throws TypeError`); -} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toLocaleString/options-conflict.js b/test/built-ins/Temporal/PlainDateTime/prototype/toLocaleString/options-conflict.js index 13fefadde6..ff4cc0b7c3 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toLocaleString/options-conflict.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toLocaleString/options-conflict.js @@ -2,46 +2,13 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sup-temporal.plaindatetime.prototype.tolocalestring +esid: sec-temporal.plaindatetime.prototype.tolocalestring description: > - Conflicting properties of dateStyle must be rejected with a TypeError for the options argument -info: | - Using sec-temporal-getdatetimeformatpattern: - GetDateTimeFormatPattern ( dateStyle, timeStyle, matcher, opt, dataLocaleData, hc ) - - 1. If dateStyle is not undefined or timeStyle is not undefined, then - a. For each row in Table 7, except the header row, do - i. Let prop be the name given in the Property column of the row. - ii. Let p be opt.[[]]. - iii. If p is not undefined, then - 1. Throw a TypeError exception. + toLocaleString return a string. features: [Temporal] ---*/ -// Table 14 - Supported fields + example value for each field -const conflictingOptions = [ - [ "weekday", "short" ], - [ "era", "short" ], - [ "year", "numeric" ], - [ "month", "numeric" ], - [ "day", "numeric" ], - [ "hour", "numeric" ], - [ "minute", "numeric" ], - [ "second", "numeric" ], - [ "dayPeriod", "short" ], - [ "fractionalSecondDigits", 3 ], -]; const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); assert.sameValue(typeof datetime.toLocaleString("en", { dateStyle: "short" }), "string"); assert.sameValue(typeof datetime.toLocaleString("en", { timeStyle: "short" }), "string"); - -for (const [ option, value ] of conflictingOptions) { - assert.throws(TypeError, function() { - datetime.toLocaleString("en", { [option]: value, dateStyle: "short" }); - }, `datetime.toLocaleString("en", { ${option}: "${value}", dateStyle: "short" }) throws TypeError`); - - assert.throws(TypeError, function() { - datetime.toLocaleString("en", { [option]: value, timeStyle: "short" }); - }, `datetime.toLocaleString("en", { ${option}: "${value}", timeStyle: "short" }) throws TypeError`); -} diff --git a/test/built-ins/Temporal/PlainTime/prototype/toLocaleString/options-conflict.js b/test/built-ins/Temporal/PlainTime/prototype/toLocaleString/options-conflict.js index 3bc613c8f6..7d02ddc8e4 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/toLocaleString/options-conflict.js +++ b/test/built-ins/Temporal/PlainTime/prototype/toLocaleString/options-conflict.js @@ -2,36 +2,12 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sup-temporal.plaintime.prototype.tolocalestring +esid: sec-temporal.plaintime.prototype.tolocalestring description: > - Conflicting properties of dateStyle must be rejected with a TypeError for the options argument -info: | - Using sec-temporal-getdatetimeformatpattern: - GetDateTimeFormatPattern ( dateStyle, timeStyle, matcher, opt, dataLocaleData, hc ) - - 1. If dateStyle is not undefined or timeStyle is not undefined, then - a. For each row in Table 7, except the header row, do - i. Let prop be the name given in the Property column of the row. - ii. Let p be opt.[[]]. - iii. If p is not undefined, then - 1. Throw a TypeError exception. + toLocaleString return a string. features: [Temporal] ---*/ -// Table 14 - Supported fields + example value for each field -const conflictingOptions = [ - [ "hour", "numeric" ], - [ "minute", "numeric" ], - [ "second", "numeric" ], - [ "dayPeriod", "short" ], - [ "fractionalSecondDigits", 3 ], -]; const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); assert.sameValue(typeof time.toLocaleString("en", { timeStyle: "short" }), "string"); - -for (const [ option, value ] of conflictingOptions) { - assert.throws(TypeError, function() { - time.toLocaleString("en", { [option]: value, timeStyle: "short" }); - }, `time.toLocaleString("en", { ${option}: "${value}", timeStyle: "short" }) throws TypeError`); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toLocaleString/options-conflict.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toLocaleString/options-conflict.js index 5cc1162dc4..b040cd10b8 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toLocaleString/options-conflict.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toLocaleString/options-conflict.js @@ -2,47 +2,13 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sup-temporal.zoneddatetime.prototype.tolocalestring +esid: sec-temporal.zoneddatetime.prototype.tolocalestring description: > - Conflicting properties of dateStyle must be rejected with a TypeError for the options argument -info: | - Using sec-temporal-getdatetimeformatpattern: - GetDateTimeFormatPattern ( dateStyle, timeStyle, matcher, opt, dataLocaleData, hc ) - - 1. If dateStyle is not undefined or timeStyle is not undefined, then - a. For each row in Table 7, except the header row, do - i. Let prop be the name given in the Property column of the row. - ii. Let p be opt.[[]]. - iii. If p is not undefined, then - 1. Throw a TypeError exception. -features: [BigInt, Temporal] + toLocaleString return a string. +features: [Temporal] ---*/ -// Table 14 - Supported fields + example value for each field -const conflictingOptions = [ - [ "weekday", "short" ], - [ "era", "short" ], - [ "year", "numeric" ], - [ "month", "numeric" ], - [ "day", "numeric" ], - [ "hour", "numeric" ], - [ "minute", "numeric" ], - [ "second", "numeric" ], - [ "dayPeriod", "short" ], - [ "fractionalSecondDigits", 3 ], - [ "timeZoneName", "short" ], -]; const datetime = new Temporal.ZonedDateTime(957270896_987_650_000n, "UTC"); assert.sameValue(typeof datetime.toLocaleString("en", { dateStyle: "short" }), "string"); assert.sameValue(typeof datetime.toLocaleString("en", { timeStyle: "short" }), "string"); - -for (const [ option, value ] of conflictingOptions) { - assert.throws(TypeError, function() { - datetime.toLocaleString("en", { [option]: value, dateStyle: "short" }); - }, `datetime.toLocaleString("en", { ${option}: "${value}", dateStyle: "short" }) throws TypeError`); - - assert.throws(TypeError, function() { - datetime.toLocaleString("en", { [option]: value, timeStyle: "short" }); - }, `datetime.toLocaleString("en", { ${option}: "${value}", timeStyle: "short" }) throws TypeError`); -} diff --git a/test/intl402/Temporal/Instant/prototype/toLocaleString/options-conflict.js b/test/intl402/Temporal/Instant/prototype/toLocaleString/options-conflict.js new file mode 100644 index 0000000000..3c163623fe --- /dev/null +++ b/test/intl402/Temporal/Instant/prototype/toLocaleString/options-conflict.js @@ -0,0 +1,14 @@ +// Copyright (C) 2021 Kate Miháliková. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.instant.prototype.tolocalestring +description: > + toLocaleString return a string. +features: [Temporal] +---*/ + +const instant = new Temporal.Instant(957270896_987_650_000n); + +assert.sameValue(typeof instant.toLocaleString("en", { dateStyle: "short" }), "string"); +assert.sameValue(typeof instant.toLocaleString("en", { timeStyle: "short" }), "string"); diff --git a/test/intl402/Temporal/PlainDate/prototype/toLocaleString/options-conflict.js b/test/intl402/Temporal/PlainDate/prototype/toLocaleString/options-conflict.js new file mode 100644 index 0000000000..9af2628116 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/toLocaleString/options-conflict.js @@ -0,0 +1,13 @@ +// Copyright (C) 2021 Kate Miháliková. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.tolocalestring +description: > + toLocaleString return a string. +features: [Temporal] +---*/ + +const date = new Temporal.PlainDate(2000, 5, 2); + +assert.sameValue(typeof date.toLocaleString("en", { dateStyle: "short" }), "string"); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/toLocaleString/options-conflict.js b/test/intl402/Temporal/PlainDateTime/prototype/toLocaleString/options-conflict.js new file mode 100644 index 0000000000..ff4cc0b7c3 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/toLocaleString/options-conflict.js @@ -0,0 +1,14 @@ +// Copyright (C) 2021 Kate Miháliková. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.tolocalestring +description: > + toLocaleString return a string. +features: [Temporal] +---*/ + +const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); + +assert.sameValue(typeof datetime.toLocaleString("en", { dateStyle: "short" }), "string"); +assert.sameValue(typeof datetime.toLocaleString("en", { timeStyle: "short" }), "string"); diff --git a/test/intl402/Temporal/PlainTime/prototype/toLocaleString/options-conflict.js b/test/intl402/Temporal/PlainTime/prototype/toLocaleString/options-conflict.js new file mode 100644 index 0000000000..7d02ddc8e4 --- /dev/null +++ b/test/intl402/Temporal/PlainTime/prototype/toLocaleString/options-conflict.js @@ -0,0 +1,13 @@ +// Copyright (C) 2021 Kate Miháliková. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaintime.prototype.tolocalestring +description: > + toLocaleString return a string. +features: [Temporal] +---*/ + +const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); + +assert.sameValue(typeof time.toLocaleString("en", { timeStyle: "short" }), "string"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/toLocaleString/options-conflict.js b/test/intl402/Temporal/ZonedDateTime/prototype/toLocaleString/options-conflict.js new file mode 100644 index 0000000000..b040cd10b8 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/toLocaleString/options-conflict.js @@ -0,0 +1,14 @@ +// Copyright (C) 2021 Kate Miháliková. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.tolocalestring +description: > + toLocaleString return a string. +features: [Temporal] +---*/ + +const datetime = new Temporal.ZonedDateTime(957270896_987_650_000n, "UTC"); + +assert.sameValue(typeof datetime.toLocaleString("en", { dateStyle: "short" }), "string"); +assert.sameValue(typeof datetime.toLocaleString("en", { timeStyle: "short" }), "string");