-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Temporal: Add tests for calendar annotation with critical flag
See tc39/proposal-temporal#2397 Adds tests for ISO strings with calendar annotations, with and without the critical flag, and also a check that the second calendar annotation is disregarded, as per the IETF draft.
- Loading branch information
Showing
63 changed files
with
1,963 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-calendar-annotation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.calendar.prototype.dateadd | ||
description: Various forms of calendar annotation; critical flag has no effect | ||
features: [Temporal] | ||
includes: [temporalHelpers.js] | ||
---*/ | ||
|
||
const tests = [ | ||
["2000-05-02[u-ca=iso8601]", "without time or time zone"], | ||
["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], | ||
["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], | ||
["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], | ||
["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], | ||
["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], | ||
["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], | ||
["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], | ||
]; | ||
|
||
const instance = new Temporal.Calendar("iso8601"); | ||
|
||
tests.forEach(([arg, description]) => { | ||
const result = instance.dateAdd(arg, new Temporal.Duration()); | ||
|
||
TemporalHelpers.assertPlainDate( | ||
result, | ||
2000, 5, "M05", 2, | ||
`calendar annotation (${description})` | ||
); | ||
}); |
32 changes: 32 additions & 0 deletions
32
test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-calendar-annotation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.calendar.prototype.dateuntil | ||
description: Various forms of calendar annotation; critical flag has no effect | ||
features: [Temporal] | ||
includes: [temporalHelpers.js] | ||
---*/ | ||
|
||
const tests = [ | ||
["2000-05-02[u-ca=iso8601]", "without time or time zone"], | ||
["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], | ||
["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], | ||
["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], | ||
["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], | ||
["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], | ||
["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], | ||
["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], | ||
]; | ||
|
||
const instance = new Temporal.Calendar("iso8601"); | ||
|
||
tests.forEach(([arg, description]) => { | ||
const result = instance.dateUntil(arg, arg); | ||
|
||
TemporalHelpers.assertDuration( | ||
result, | ||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
`calendar annotation (${description})` | ||
); | ||
}); |
31 changes: 31 additions & 0 deletions
31
test/built-ins/Temporal/Calendar/prototype/day/argument-string-calendar-annotation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.calendar.prototype.day | ||
description: Various forms of calendar annotation; critical flag has no effect | ||
features: [Temporal] | ||
---*/ | ||
|
||
const tests = [ | ||
["2000-05-02[u-ca=iso8601]", "without time or time zone"], | ||
["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], | ||
["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], | ||
["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], | ||
["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], | ||
["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], | ||
["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], | ||
["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], | ||
]; | ||
|
||
const instance = new Temporal.Calendar("iso8601"); | ||
|
||
tests.forEach(([arg, description]) => { | ||
const result = instance.day(arg); | ||
|
||
assert.sameValue( | ||
result, | ||
2, | ||
`calendar annotation (${description})` | ||
); | ||
}); |
31 changes: 31 additions & 0 deletions
31
test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-calendar-annotation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.calendar.prototype.dayofweek | ||
description: Various forms of calendar annotation; critical flag has no effect | ||
features: [Temporal] | ||
---*/ | ||
|
||
const tests = [ | ||
["2000-05-02[u-ca=iso8601]", "without time or time zone"], | ||
["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], | ||
["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], | ||
["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], | ||
["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], | ||
["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], | ||
["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], | ||
["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], | ||
]; | ||
|
||
const instance = new Temporal.Calendar("iso8601"); | ||
|
||
tests.forEach(([arg, description]) => { | ||
const result = instance.dayOfWeek(arg); | ||
|
||
assert.sameValue( | ||
result, | ||
2, | ||
`calendar annotation (${description})` | ||
); | ||
}); |
31 changes: 31 additions & 0 deletions
31
test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-calendar-annotation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.calendar.prototype.dayofyear | ||
description: Various forms of calendar annotation; critical flag has no effect | ||
features: [Temporal] | ||
---*/ | ||
|
||
const tests = [ | ||
["2000-05-02[u-ca=iso8601]", "without time or time zone"], | ||
["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], | ||
["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], | ||
["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], | ||
["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], | ||
["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], | ||
["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], | ||
["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], | ||
]; | ||
|
||
const instance = new Temporal.Calendar("iso8601"); | ||
|
||
tests.forEach(([arg, description]) => { | ||
const result = instance.dayOfYear(arg); | ||
|
||
assert.sameValue( | ||
result, | ||
123, | ||
`calendar annotation (${description})` | ||
); | ||
}); |
31 changes: 31 additions & 0 deletions
31
.../built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-calendar-annotation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.calendar.prototype.daysinmonth | ||
description: Various forms of calendar annotation; critical flag has no effect | ||
features: [Temporal] | ||
---*/ | ||
|
||
const tests = [ | ||
["2000-05-02[u-ca=iso8601]", "without time or time zone"], | ||
["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], | ||
["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], | ||
["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], | ||
["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], | ||
["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], | ||
["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], | ||
["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], | ||
]; | ||
|
||
const instance = new Temporal.Calendar("iso8601"); | ||
|
||
tests.forEach(([arg, description]) => { | ||
const result = instance.daysInMonth(arg); | ||
|
||
assert.sameValue( | ||
result, | ||
31, | ||
`calendar annotation (${description})` | ||
); | ||
}); |
31 changes: 31 additions & 0 deletions
31
test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-calendar-annotation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.calendar.prototype.daysinweek | ||
description: Various forms of calendar annotation; critical flag has no effect | ||
features: [Temporal] | ||
---*/ | ||
|
||
const tests = [ | ||
["2000-05-02[u-ca=iso8601]", "without time or time zone"], | ||
["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], | ||
["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], | ||
["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], | ||
["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], | ||
["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], | ||
["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], | ||
["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], | ||
]; | ||
|
||
const instance = new Temporal.Calendar("iso8601"); | ||
|
||
tests.forEach(([arg, description]) => { | ||
const result = instance.daysInWeek(arg); | ||
|
||
assert.sameValue( | ||
result, | ||
7, | ||
`calendar annotation (${description})` | ||
); | ||
}); |
31 changes: 31 additions & 0 deletions
31
test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-calendar-annotation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.calendar.prototype.daysinyear | ||
description: Various forms of calendar annotation; critical flag has no effect | ||
features: [Temporal] | ||
---*/ | ||
|
||
const tests = [ | ||
["2000-05-02[u-ca=iso8601]", "without time or time zone"], | ||
["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], | ||
["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], | ||
["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], | ||
["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], | ||
["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], | ||
["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], | ||
["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], | ||
]; | ||
|
||
const instance = new Temporal.Calendar("iso8601"); | ||
|
||
tests.forEach(([arg, description]) => { | ||
const result = instance.daysInYear(arg); | ||
|
||
assert.sameValue( | ||
result, | ||
366, | ||
`calendar annotation (${description})` | ||
); | ||
}); |
31 changes: 31 additions & 0 deletions
31
test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-calendar-annotation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.calendar.prototype.inleapyear | ||
description: Various forms of calendar annotation; critical flag has no effect | ||
features: [Temporal] | ||
---*/ | ||
|
||
const tests = [ | ||
["2000-05-02[u-ca=iso8601]", "without time or time zone"], | ||
["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], | ||
["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], | ||
["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], | ||
["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], | ||
["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], | ||
["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], | ||
["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], | ||
]; | ||
|
||
const instance = new Temporal.Calendar("iso8601"); | ||
|
||
tests.forEach(([arg, description]) => { | ||
const result = instance.inLeapYear(arg); | ||
|
||
assert.sameValue( | ||
result, | ||
true, | ||
`calendar annotation (${description})` | ||
); | ||
}); |
31 changes: 31 additions & 0 deletions
31
test/built-ins/Temporal/Calendar/prototype/month/argument-string-calendar-annotation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.calendar.prototype.month | ||
description: Various forms of calendar annotation; critical flag has no effect | ||
features: [Temporal] | ||
---*/ | ||
|
||
const tests = [ | ||
["2000-05-02[u-ca=iso8601]", "without time or time zone"], | ||
["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], | ||
["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], | ||
["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], | ||
["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], | ||
["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], | ||
["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], | ||
["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], | ||
]; | ||
|
||
const instance = new Temporal.Calendar("iso8601"); | ||
|
||
tests.forEach(([arg, description]) => { | ||
const result = instance.month(arg); | ||
|
||
assert.sameValue( | ||
result, | ||
5, | ||
`calendar annotation (${description})` | ||
); | ||
}); |
31 changes: 31 additions & 0 deletions
31
test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-calendar-annotation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.calendar.prototype.monthcode | ||
description: Various forms of calendar annotation; critical flag has no effect | ||
features: [Temporal] | ||
---*/ | ||
|
||
const tests = [ | ||
["2000-05-02[u-ca=iso8601]", "without time or time zone"], | ||
["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], | ||
["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], | ||
["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], | ||
["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], | ||
["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], | ||
["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], | ||
["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], | ||
]; | ||
|
||
const instance = new Temporal.Calendar("iso8601"); | ||
|
||
tests.forEach(([arg, description]) => { | ||
const result = instance.monthCode(arg); | ||
|
||
assert.sameValue( | ||
result, | ||
"M05", | ||
`calendar annotation (${description})` | ||
); | ||
}); |
31 changes: 31 additions & 0 deletions
31
...built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-calendar-annotation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.calendar.prototype.monthsinyear | ||
description: Various forms of calendar annotation; critical flag has no effect | ||
features: [Temporal] | ||
---*/ | ||
|
||
const tests = [ | ||
["2000-05-02[u-ca=iso8601]", "without time or time zone"], | ||
["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], | ||
["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], | ||
["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], | ||
["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], | ||
["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], | ||
["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], | ||
["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], | ||
]; | ||
|
||
const instance = new Temporal.Calendar("iso8601"); | ||
|
||
tests.forEach(([arg, description]) => { | ||
const result = instance.monthsInYear(arg); | ||
|
||
assert.sameValue( | ||
result, | ||
12, | ||
`calendar annotation (${description})` | ||
); | ||
}); |
Oops, something went wrong.