Skip to content

Commit b254094

Browse files
catamorphismMs2ger
authored andcommitted
[Temporal] Remove test/staging/Temporal/v8/calendar-date-add.js
And move functionality into existing basic.js tests.
1 parent 1dc2112 commit b254094

File tree

4 files changed

+191
-87
lines changed

4 files changed

+191
-87
lines changed

harness/temporalHelpers.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,25 @@ var TemporalHelpers = {
261261
assert.sameValue(datetime.nanosecond, nanosecond, `${prefix}nanosecond result:`);
262262
},
263263

264+
/*
265+
* assertPlainDatesEqual(actual, expected[, description]):
266+
*
267+
* Shorthand for asserting that two Temporal.PlainDates are of the correct
268+
* type, equal according to their equals() methods, and additionally that
269+
* their calendar internal slots are the same value.
270+
*/
271+
assertPlainDatesEqual(actual, expected, description = "") {
272+
const prefix = description ? `${description}: ` : "";
273+
assert(expected instanceof Temporal.PlainDate, `${prefix}expected value should be a Temporal.PlainDate`);
274+
assert(actual instanceof Temporal.PlainDate, `${prefix}instanceof`);
275+
assert(actual.equals(expected), `${prefix}equals method`);
276+
assert.sameValue(
277+
actual.calendarId,
278+
expected.calendarId,
279+
`${prefix}calendar same value:`
280+
);
281+
},
282+
264283
/*
265284
* assertPlainDateTimesEqual(actual, expected[, description]):
266285
*

test/built-ins/Temporal/PlainDate/prototype/add/basic.js

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,89 @@ TemporalHelpers.assertPlainDate(Temporal.PlainDate.from('1976-12-08').add({ days
2727
1976, 11, "M11", 18);
2828
TemporalHelpers.assertPlainDate(Temporal.PlainDate.from('2019-02-28').add({ months: -1 }),
2929
2019, 1, "M01", 28);
30+
31+
let p1y = new Temporal.Duration(1);
32+
let p4y = new Temporal.Duration(4);
33+
let p5m = new Temporal.Duration(0, 5);
34+
let p1y2m = new Temporal.Duration(1, 2);
35+
let p1y4d = new Temporal.Duration(1, 0, 0, 4);
36+
let p1y2m4d = new Temporal.Duration(1, 2, 0, 4);
37+
let p10d = new Temporal.Duration(0, 0, 0, 10);
38+
let p1w = new Temporal.Duration(0, 0, 1);
39+
let p6w = new Temporal.Duration(0, 0, 6);
40+
let p2w3d = new Temporal.Duration(0, 0, 2, 3);
41+
let p1y2w = new Temporal.Duration(1, 0, 2);
42+
let p2m3w = new Temporal.Duration(0, 2, 3);
43+
44+
let testData = [
45+
[ '2020-02-29', p1y, '2021-02-28' ],
46+
[ '2020-02-29', p4y, '2024-02-29' ],
47+
[ '2021-07-16', p1y, '2022-07-16' ],
48+
[ '2021-07-16', p5m, '2021-12-16' ],
49+
[ '2021-08-16', p5m, '2022-01-16' ],
50+
[ '2021-10-31', p5m, '2022-03-31' ],
51+
[ '2021-09-30', p5m, '2022-02-28' ],
52+
[ '2019-09-30', p5m, '2020-02-29' ],
53+
[ '2019-10-01', p5m, '2020-03-01' ],
54+
[ '2021-07-16', p1y2m, '2022-09-16' ],
55+
[ '2021-11-30', p1y2m, '2023-01-30' ],
56+
[ '2021-12-31', p1y2m, '2023-02-28' ],
57+
[ '2022-12-31', p1y2m, '2024-02-29' ],
58+
[ '2021-07-16', p1y4d, '2022-07-20' ],
59+
[ '2021-02-27', p1y4d, '2022-03-03' ],
60+
[ '2023-02-27', p1y4d, '2024-03-02' ],
61+
[ '2021-12-30', p1y4d, '2023-01-03' ],
62+
[ '2021-07-30', p1y4d, '2022-08-03' ],
63+
[ '2021-06-30', p1y4d, '2022-07-04' ],
64+
[ '2021-07-16', p1y2m4d, '2022-09-20' ],
65+
[ '2021-02-27', p1y2m4d, '2022-05-01' ],
66+
[ '2021-02-26', p1y2m4d, '2022-04-30' ],
67+
[ '2023-02-26', p1y2m4d, '2024-04-30' ],
68+
[ '2021-12-30', p1y2m4d, '2023-03-04' ],
69+
[ '2021-07-30', p1y2m4d, '2022-10-04' ],
70+
[ '2021-06-30', p1y2m4d, '2022-09-03' ],
71+
[ '2021-07-16', p10d, '2021-07-26' ],
72+
[ '2021-07-26', p10d, '2021-08-05' ],
73+
[ '2021-12-26', p10d, '2022-01-05' ],
74+
[ '2020-02-26', p10d, '2020-03-07' ],
75+
[ '2021-02-26', p10d, '2021-03-08' ],
76+
[ '2020-02-19', p10d, '2020-02-29' ],
77+
[ '2021-02-19', p10d, '2021-03-01' ],
78+
[ '2021-02-19', p1w, '2021-02-26' ],
79+
[ '2021-02-27', p1w, '2021-03-06' ],
80+
[ '2020-02-27', p1w, '2020-03-05' ],
81+
[ '2021-12-24', p1w, '2021-12-31' ],
82+
[ '2021-12-27', p1w, '2022-01-03' ],
83+
[ '2021-01-27', p1w, '2021-02-03' ],
84+
[ '2021-06-27', p1w, '2021-07-04' ],
85+
[ '2021-07-27', p1w, '2021-08-03' ],
86+
[ '2021-02-19', p6w, '2021-04-02' ],
87+
[ '2021-02-27', p6w, '2021-04-10' ],
88+
[ '2020-02-27', p6w, '2020-04-09' ],
89+
[ '2021-12-24', p6w, '2022-02-04' ],
90+
[ '2021-12-27', p6w, '2022-02-07' ],
91+
[ '2021-01-27', p6w, '2021-03-10' ],
92+
[ '2021-06-27', p6w, '2021-08-08' ],
93+
[ '2021-07-27', p6w, '2021-09-07' ],
94+
[ '2020-02-29', p2w3d, '2020-03-17' ],
95+
[ '2020-02-28', p2w3d, '2020-03-16' ],
96+
[ '2021-02-28', p2w3d, '2021-03-17' ],
97+
[ '2020-12-28', p2w3d, '2021-01-14' ],
98+
[ '2020-02-29', p1y2w, '2021-03-14' ],
99+
[ '2020-02-28', p1y2w, '2021-03-14' ],
100+
[ '2021-02-28', p1y2w, '2022-03-14' ],
101+
[ '2020-12-28', p1y2w, '2022-01-11' ],
102+
[ '2020-02-29', p2m3w, '2020-05-20' ],
103+
[ '2020-02-28', p2m3w, '2020-05-19' ],
104+
[ '2021-02-28', p2m3w, '2021-05-19' ],
105+
[ '2020-12-28', p2m3w, '2021-03-21' ],
106+
[ '2019-12-28', p2m3w, '2020-03-20' ],
107+
[ '2019-10-28', p2m3w, '2020-01-18' ],
108+
[ '2019-10-31', p2m3w, '2020-01-21' ],
109+
];
110+
111+
for (let [dateString, duration, resultString] of testData) {
112+
const date = Temporal.PlainDate.from(dateString);
113+
const result = Temporal.PlainDate.from(resultString);
114+
TemporalHelpers.assertPlainDatesEqual(date.add(duration), result);
115+
}

test/built-ins/Temporal/PlainDate/prototype/subtract/basic.js

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,89 @@ TemporalHelpers.assertPlainDate(Temporal.PlainDate.from('2019-10-29').subtract({
2727
2019, 11, "M11", 18);
2828
TemporalHelpers.assertPlainDate(Temporal.PlainDate.from('2019-01-28').subtract({ months: -1 }),
2929
2019, 2, "M02", 28);
30+
31+
let p1y = new Temporal.Duration(1);
32+
let p4y = new Temporal.Duration(4);
33+
let p5m = new Temporal.Duration(0, 5);
34+
let p1y2m = new Temporal.Duration(1, 2);
35+
let p1y4d = new Temporal.Duration(1, 0, 0, 4);
36+
let p1y2m4d = new Temporal.Duration(1, 2, 0, 4);
37+
let p10d = new Temporal.Duration(0, 0, 0, 10);
38+
let p1w = new Temporal.Duration(0, 0, 1);
39+
let p6w = new Temporal.Duration(0, 0, 6);
40+
let p2w3d = new Temporal.Duration(0, 0, 2, 3);
41+
let p1y2w = new Temporal.Duration(1, 0, 2);
42+
let p2m3w = new Temporal.Duration(0, 2, 3);
43+
44+
let testData = [
45+
[ '2020-02-29', p1y, '2021-02-28' ],
46+
[ '2020-02-29', p4y, '2024-02-29' ],
47+
[ '2021-07-16', p1y, '2022-07-16' ],
48+
[ '2021-07-16', p5m, '2021-12-16' ],
49+
[ '2021-08-16', p5m, '2022-01-16' ],
50+
[ '2021-10-31', p5m, '2022-03-31' ],
51+
[ '2021-09-30', p5m, '2022-02-28' ],
52+
[ '2019-09-30', p5m, '2020-02-29' ],
53+
[ '2019-10-01', p5m, '2020-03-01' ],
54+
[ '2021-07-16', p1y2m, '2022-09-16' ],
55+
[ '2021-11-30', p1y2m, '2023-01-30' ],
56+
[ '2021-12-31', p1y2m, '2023-02-28' ],
57+
[ '2022-12-31', p1y2m, '2024-02-29' ],
58+
[ '2021-07-16', p1y4d, '2022-07-20' ],
59+
[ '2021-02-27', p1y4d, '2022-03-03' ],
60+
[ '2023-02-27', p1y4d, '2024-03-02' ],
61+
[ '2021-12-30', p1y4d, '2023-01-03' ],
62+
[ '2021-07-30', p1y4d, '2022-08-03' ],
63+
[ '2021-06-30', p1y4d, '2022-07-04' ],
64+
[ '2021-07-16', p1y2m4d, '2022-09-20' ],
65+
[ '2021-02-27', p1y2m4d, '2022-05-01' ],
66+
[ '2021-02-26', p1y2m4d, '2022-04-30' ],
67+
[ '2023-02-26', p1y2m4d, '2024-04-30' ],
68+
[ '2021-12-30', p1y2m4d, '2023-03-04' ],
69+
[ '2021-07-30', p1y2m4d, '2022-10-04' ],
70+
[ '2021-06-30', p1y2m4d, '2022-09-03' ],
71+
[ '2021-07-16', p10d, '2021-07-26' ],
72+
[ '2021-07-26', p10d, '2021-08-05' ],
73+
[ '2021-12-26', p10d, '2022-01-05' ],
74+
[ '2020-02-26', p10d, '2020-03-07' ],
75+
[ '2021-02-26', p10d, '2021-03-08' ],
76+
[ '2020-02-19', p10d, '2020-02-29' ],
77+
[ '2021-02-19', p10d, '2021-03-01' ],
78+
[ '2021-02-19', p1w, '2021-02-26' ],
79+
[ '2021-02-27', p1w, '2021-03-06' ],
80+
[ '2020-02-27', p1w, '2020-03-05' ],
81+
[ '2021-12-24', p1w, '2021-12-31' ],
82+
[ '2021-12-27', p1w, '2022-01-03' ],
83+
[ '2021-01-27', p1w, '2021-02-03' ],
84+
[ '2021-06-27', p1w, '2021-07-04' ],
85+
[ '2021-07-27', p1w, '2021-08-03' ],
86+
[ '2021-02-19', p6w, '2021-04-02' ],
87+
[ '2021-02-27', p6w, '2021-04-10' ],
88+
[ '2020-02-27', p6w, '2020-04-09' ],
89+
[ '2021-12-24', p6w, '2022-02-04' ],
90+
[ '2021-12-27', p6w, '2022-02-07' ],
91+
[ '2021-01-27', p6w, '2021-03-10' ],
92+
[ '2021-06-27', p6w, '2021-08-08' ],
93+
[ '2021-07-27', p6w, '2021-09-07' ],
94+
[ '2020-02-29', p2w3d, '2020-03-17' ],
95+
[ '2020-02-28', p2w3d, '2020-03-16' ],
96+
[ '2021-02-28', p2w3d, '2021-03-17' ],
97+
[ '2020-12-28', p2w3d, '2021-01-14' ],
98+
[ '2020-02-29', p1y2w, '2021-03-14' ],
99+
[ '2020-02-28', p1y2w, '2021-03-14' ],
100+
[ '2021-02-28', p1y2w, '2022-03-14' ],
101+
[ '2020-12-28', p1y2w, '2022-01-11' ],
102+
[ '2020-02-29', p2m3w, '2020-05-20' ],
103+
[ '2020-02-28', p2m3w, '2020-05-19' ],
104+
[ '2021-02-28', p2m3w, '2021-05-19' ],
105+
[ '2020-12-28', p2m3w, '2021-03-21' ],
106+
[ '2019-12-28', p2m3w, '2020-03-20' ],
107+
[ '2019-10-28', p2m3w, '2020-01-18' ],
108+
[ '2019-10-31', p2m3w, '2020-01-21' ],
109+
];
110+
111+
for (let [dateString, duration, resultString] of testData) {
112+
const date = Temporal.PlainDate.from(dateString);
113+
const result = Temporal.PlainDate.from(resultString);
114+
TemporalHelpers.assertPlainDatesEqual(date.subtract(duration.negated()), result);
115+
}

test/staging/Temporal/v8/calendar-date-add.js

Lines changed: 0 additions & 87 deletions
This file was deleted.

0 commit comments

Comments
 (0)