mirror of https://github.com/tc39/test262.git
Add tests for PlainDate#toString().
This commit is contained in:
parent
08a9fc2b97
commit
0855621088
|
@ -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");
|
|
@ -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);
|
||||
});
|
|
@ -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);
|
||||
});
|
|
@ -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);
|
||||
});
|
Loading…
Reference in New Issue