diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/basic.js b/test/built-ins/Temporal/PlainDate/prototype/toString/basic.js new file mode 100644 index 0000000000..f1f70dc373 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/basic.js @@ -0,0 +1,17 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.protoype.tostring +description: basic tests +features: [Temporal] +---*/ + +const date1 = new Temporal.PlainDate(1976, 11, 18); +assert.sameValue(date1.toString(), "1976-11-18"); + +const date2 = new Temporal.PlainDate(1914, 2, 23); +assert.sameValue(date2.toString(), "1914-02-23"); + +const date3 = new Temporal.PlainDate(1996, 2, 29); +assert.sameValue(date3.toString(), "1996-02-29"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-always.js b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-always.js new file mode 100644 index 0000000000..53bcac40b7 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-always.js @@ -0,0 +1,22 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.protoype.tostring +description: always value for calendarName option +features: [Temporal] +---*/ + +const calendar = { + toString() { return "custom"; } +}; +const date1 = new Temporal.PlainDate(2000, 5, 2); +const date2 = new Temporal.PlainDate(2000, 5, 2, calendar); + +[ + [date1, "2000-05-02[u-ca=iso8601]"], + [date2, "2000-05-02[u-ca=custom]"], +].forEach(([date, expected]) => { + const result = date.toString({ calendarName: "always" }); + assert.sameValue(result, expected, "expected " + expected); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-auto.js b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-auto.js new file mode 100644 index 0000000000..08ad287d52 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-auto.js @@ -0,0 +1,22 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.protoype.tostring +description: auto value for calendarName option +features: [Temporal] +---*/ + +const calendar = { + toString() { return "custom"; } +}; +const date1 = new Temporal.PlainDate(2000, 5, 2); +const date2 = new Temporal.PlainDate(2000, 5, 2, calendar); + +[ + [date1, "2000-05-02"], + [date2, "2000-05-02[u-ca=custom]"], +].forEach(([date, expected]) => { + const result = date.toString({ calendarName: "auto" }); + assert.sameValue(result, expected, "expected " + expected); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-never.js b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-never.js new file mode 100644 index 0000000000..a937872d1b --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-never.js @@ -0,0 +1,22 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.protoype.tostring +description: never value for calendarName option +features: [Temporal] +---*/ + +const calendar = { + toString() { return "custom"; } +}; +const date1 = new Temporal.PlainDate(2000, 5, 2); +const date2 = new Temporal.PlainDate(2000, 5, 2, calendar); + +[ + [date1, "2000-05-02"], + [date2, "2000-05-02"], +].forEach(([date, expected]) => { + const result = date.toString({ calendarName: "never" }); + assert.sameValue(result, expected, "expected " + expected); +});