mirror of
https://github.com/tc39/test262.git
synced 2025-04-08 19:35:28 +02:00
Temporal: Tests that dateStyle affects toLocaleString output
For each Temporal type, add a test (which should not be sensitive to the exact locale format) that ensures dateStyle affects the output, for a Gregorian and non-Gregorian calendar. See https://github.com/tc39/proposal-temporal/issues/2058
This commit is contained in:
parent
a074d97c5b
commit
63933d1da5
28
test/intl402/Temporal/Instant/prototype/toLocaleString/dateStyle.js
vendored
Normal file
28
test/intl402/Temporal/Instant/prototype/toLocaleString/dateStyle.js
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.instant.prototype.tolocalestring
|
||||
description: Basic tests that dateStyle option affects output
|
||||
locale: [en-u-ca-gregory, en-u-ca-islamic]
|
||||
features: [Temporal, Intl.DateTimeFormat-datetimestyle]
|
||||
---*/
|
||||
|
||||
const instant = new Temporal.Instant(1711475200_000_000_000n);
|
||||
|
||||
assert(
|
||||
instant.toLocaleString("en-u-ca-gregory", { dateStyle: "long" }).includes("March"),
|
||||
"dateStyle: long writes month of March out in full"
|
||||
);
|
||||
assert(
|
||||
!instant.toLocaleString("en-u-ca-gregory", { dateStyle: "short" }).includes("March"),
|
||||
"dateStyle: short does not write month of March out in full"
|
||||
);
|
||||
assert(
|
||||
instant.toLocaleString("en-u-ca-islamic", { dateStyle: "long" }).includes("Ramadan"),
|
||||
"dateStyle: long writes month of Ramadan out in full"
|
||||
);
|
||||
assert(
|
||||
!instant.toLocaleString("en-u-ca-islamic", { dateStyle: "short" }).includes("Ramadan"),
|
||||
"dateStyle: short does not write month of Ramadan out in full"
|
||||
);
|
31
test/intl402/Temporal/PlainDate/prototype/toLocaleString/dateStyle.js
vendored
Normal file
31
test/intl402/Temporal/PlainDate/prototype/toLocaleString/dateStyle.js
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindate.prototype.tolocalestring
|
||||
description: Basic tests that dateStyle option affects output
|
||||
locale: [en-u-ca-gregory, en-u-ca-islamic]
|
||||
features: [Temporal, Intl.DateTimeFormat-datetimestyle]
|
||||
---*/
|
||||
|
||||
const dateGregorian = new Temporal.PlainDate(2024, 3, 26, "gregory");
|
||||
|
||||
assert(
|
||||
dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "long" }).includes("March"),
|
||||
"dateStyle: long writes month of March out in full"
|
||||
);
|
||||
assert(
|
||||
!dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "short" }).includes("March"),
|
||||
"dateStyle: short does not write month of March out in full"
|
||||
);
|
||||
|
||||
const dateIslamic = new Temporal.PlainDate(2024, 3, 26, "islamic");
|
||||
|
||||
assert(
|
||||
dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "long" }).includes("Ramadan"),
|
||||
"dateStyle: long writes month of Ramadan out in full"
|
||||
);
|
||||
assert(
|
||||
!dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "short" }).includes("Ramadan"),
|
||||
"dateStyle: short does not write month of Ramadan out in full"
|
||||
);
|
31
test/intl402/Temporal/PlainDateTime/prototype/toLocaleString/dateStyle.js
vendored
Normal file
31
test/intl402/Temporal/PlainDateTime/prototype/toLocaleString/dateStyle.js
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindatetime.prototype.tolocalestring
|
||||
description: Basic tests that dateStyle option affects output
|
||||
locale: [en-u-ca-gregory, en-u-ca-islamic]
|
||||
features: [Temporal, Intl.DateTimeFormat-datetimestyle]
|
||||
---*/
|
||||
|
||||
const dateGregorian = new Temporal.PlainDateTime(2024, 3, 26, 10, 30, 0, 0, 0, 0, "gregory");
|
||||
|
||||
assert(
|
||||
dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "long" }).includes("March"),
|
||||
"dateStyle: long writes month of March out in full"
|
||||
);
|
||||
assert(
|
||||
!dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "short" }).includes("March"),
|
||||
"dateStyle: short does not write month of March out in full"
|
||||
);
|
||||
|
||||
const dateIslamic = new Temporal.PlainDateTime(2024, 3, 26, 10, 30, 0, 0, 0, 0, "islamic");
|
||||
|
||||
assert(
|
||||
dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "long" }).includes("Ramadan"),
|
||||
"dateStyle: long writes month of Ramadan out in full"
|
||||
);
|
||||
assert(
|
||||
!dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "short" }).includes("Ramadan"),
|
||||
"dateStyle: short does not write month of Ramadan out in full"
|
||||
);
|
31
test/intl402/Temporal/PlainMonthDay/prototype/toLocaleString/dateStyle.js
vendored
Normal file
31
test/intl402/Temporal/PlainMonthDay/prototype/toLocaleString/dateStyle.js
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plainmonthday.prototype.tolocalestring
|
||||
description: Basic tests that dateStyle option affects output
|
||||
locale: [en-u-ca-gregory, en-u-ca-islamic]
|
||||
features: [Temporal, Intl.DateTimeFormat-datetimestyle]
|
||||
---*/
|
||||
|
||||
const dateGregorian = Temporal.PlainMonthDay.from({ monthCode: "M03", day: 26, calendar: "gregory" });
|
||||
|
||||
assert(
|
||||
dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "long" }).includes("March"),
|
||||
"dateStyle: long writes month of March out in full"
|
||||
);
|
||||
assert(
|
||||
!dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "short" }).includes("March"),
|
||||
"dateStyle: short does not write month of March out in full"
|
||||
);
|
||||
|
||||
const dateIslamic = Temporal.PlainMonthDay.from({ monthCode: "M09", day: 16, calendar: "islamic" });
|
||||
|
||||
assert(
|
||||
dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "long" }).includes("Ramadan"),
|
||||
"dateStyle: long writes month of Ramadan out in full"
|
||||
);
|
||||
assert(
|
||||
!dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "short" }).includes("Ramadan"),
|
||||
"dateStyle: short does not write month of Ramadan out in full"
|
||||
);
|
31
test/intl402/Temporal/PlainYearMonth/prototype/toLocaleString/dateStyle.js
vendored
Normal file
31
test/intl402/Temporal/PlainYearMonth/prototype/toLocaleString/dateStyle.js
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plainyearmonth.prototype.tolocalestring
|
||||
description: Basic tests that dateStyle option affects output
|
||||
locale: [en-u-ca-gregory, en-u-ca-islamic]
|
||||
features: [Temporal, Intl.DateTimeFormat-datetimestyle]
|
||||
---*/
|
||||
|
||||
const dateGregorian = Temporal.PlainYearMonth.from({ year: 2024, monthCode: "M03", calendar: "gregory" });
|
||||
|
||||
assert(
|
||||
dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "long" }).includes("March"),
|
||||
"dateStyle: long writes month of March out in full"
|
||||
);
|
||||
assert(
|
||||
!dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "short" }).includes("March"),
|
||||
"dateStyle: short does not write month of March out in full"
|
||||
);
|
||||
|
||||
const dateIslamic = Temporal.PlainYearMonth.from({ year: 1445, monthCode: "M09", calendar: "islamic" });
|
||||
|
||||
assert(
|
||||
dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "long" }).includes("Ramadan"),
|
||||
"dateStyle: long writes month of Ramadan out in full"
|
||||
);
|
||||
assert(
|
||||
!dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "short" }).includes("Ramadan"),
|
||||
"dateStyle: short does not write month of Ramadan out in full"
|
||||
);
|
31
test/intl402/Temporal/ZonedDateTime/prototype/toLocaleString/dateStyle.js
vendored
Normal file
31
test/intl402/Temporal/ZonedDateTime/prototype/toLocaleString/dateStyle.js
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindate.prototype.tolocalestring
|
||||
description: Basic tests that dateStyle option affects output
|
||||
locale: [en-u-ca-gregory, en-u-ca-islamic]
|
||||
features: [Temporal, Intl.DateTimeFormat-datetimestyle]
|
||||
---*/
|
||||
|
||||
const dateGregorian = new Temporal.ZonedDateTime(1711475200_000_000_000n, "UTC", "gregory");
|
||||
|
||||
assert(
|
||||
dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "long" }).includes("March"),
|
||||
"dateStyle: long writes month of March out in full"
|
||||
);
|
||||
assert(
|
||||
!dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "short" }).includes("March"),
|
||||
"dateStyle: short does not write month of March out in full"
|
||||
);
|
||||
|
||||
const dateIslamic = new Temporal.ZonedDateTime(1711475200_000_000_000n, "UTC", "islamic");
|
||||
|
||||
assert(
|
||||
dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "long" }).includes("Ramadan"),
|
||||
"dateStyle: long writes month of Ramadan out in full"
|
||||
);
|
||||
assert(
|
||||
!dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "short" }).includes("Ramadan"),
|
||||
"dateStyle: short does not write month of Ramadan out in full"
|
||||
);
|
Loading…
x
Reference in New Issue
Block a user