forked from tc39/test262
-
Notifications
You must be signed in to change notification settings - Fork 0
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 multiple time zone annotations
See tc39/proposal-temporal#2397 Adds tests for ISO strings with more than one time zone annotation. These are not syntactically correct according to the grammar and should be rejected.
- Loading branch information
Showing
63 changed files
with
1,599 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-multiple-time-zone.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,25 @@ | ||
// 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: More than one time zone annotation is not syntactical | ||
features: [Temporal] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"1970-01-01[UTC][UTC]", | ||
"1970-01-01T00:00[UTC][UTC]", | ||
"1970-01-01T00:00[!UTC][UTC]", | ||
"1970-01-01T00:00[UTC][!UTC]", | ||
"1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", | ||
"1970-01-01T00:00[UTC][foo=bar][UTC]", | ||
]; | ||
const instance = new Temporal.Calendar("iso8601"); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.dateAdd(arg, new Temporal.Duration()), | ||
`reject more than one time zone annotation: ${arg}` | ||
); | ||
}); |
30 changes: 30 additions & 0 deletions
30
test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-multiple-time-zone.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,30 @@ | ||
// 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: More than one time zone annotation is not syntactical | ||
features: [Temporal] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"1970-01-01[UTC][UTC]", | ||
"1970-01-01T00:00[UTC][UTC]", | ||
"1970-01-01T00:00[!UTC][UTC]", | ||
"1970-01-01T00:00[UTC][!UTC]", | ||
"1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", | ||
"1970-01-01T00:00[UTC][foo=bar][UTC]", | ||
]; | ||
const instance = new Temporal.Calendar("iso8601"); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), | ||
`reject more than one time zone annotation: ${arg} (first argument)` | ||
); | ||
assert.throws( | ||
RangeError, | ||
() => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), | ||
`reject more than one time zone annotation: ${arg} (second argument)` | ||
); | ||
}); |
25 changes: 25 additions & 0 deletions
25
test/built-ins/Temporal/Calendar/prototype/day/argument-string-multiple-time-zone.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,25 @@ | ||
// 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: More than one time zone annotation is not syntactical | ||
features: [Temporal] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"1970-01-01[UTC][UTC]", | ||
"1970-01-01T00:00[UTC][UTC]", | ||
"1970-01-01T00:00[!UTC][UTC]", | ||
"1970-01-01T00:00[UTC][!UTC]", | ||
"1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", | ||
"1970-01-01T00:00[UTC][foo=bar][UTC]", | ||
]; | ||
const instance = new Temporal.Calendar("iso8601"); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.day(arg), | ||
`reject more than one time zone annotation: ${arg}` | ||
); | ||
}); |
25 changes: 25 additions & 0 deletions
25
test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-multiple-time-zone.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,25 @@ | ||
// 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: More than one time zone annotation is not syntactical | ||
features: [Temporal] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"1970-01-01[UTC][UTC]", | ||
"1970-01-01T00:00[UTC][UTC]", | ||
"1970-01-01T00:00[!UTC][UTC]", | ||
"1970-01-01T00:00[UTC][!UTC]", | ||
"1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", | ||
"1970-01-01T00:00[UTC][foo=bar][UTC]", | ||
]; | ||
const instance = new Temporal.Calendar("iso8601"); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.dayOfWeek(arg), | ||
`reject more than one time zone annotation: ${arg}` | ||
); | ||
}); |
25 changes: 25 additions & 0 deletions
25
test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-multiple-time-zone.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,25 @@ | ||
// 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: More than one time zone annotation is not syntactical | ||
features: [Temporal] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"1970-01-01[UTC][UTC]", | ||
"1970-01-01T00:00[UTC][UTC]", | ||
"1970-01-01T00:00[!UTC][UTC]", | ||
"1970-01-01T00:00[UTC][!UTC]", | ||
"1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", | ||
"1970-01-01T00:00[UTC][foo=bar][UTC]", | ||
]; | ||
const instance = new Temporal.Calendar("iso8601"); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.dayOfYear(arg), | ||
`reject more than one time zone annotation: ${arg}` | ||
); | ||
}); |
25 changes: 25 additions & 0 deletions
25
test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-multiple-time-zone.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,25 @@ | ||
// 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: More than one time zone annotation is not syntactical | ||
features: [Temporal] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"1970-01-01[UTC][UTC]", | ||
"1970-01-01T00:00[UTC][UTC]", | ||
"1970-01-01T00:00[!UTC][UTC]", | ||
"1970-01-01T00:00[UTC][!UTC]", | ||
"1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", | ||
"1970-01-01T00:00[UTC][foo=bar][UTC]", | ||
]; | ||
const instance = new Temporal.Calendar("iso8601"); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.daysInMonth(arg), | ||
`reject more than one time zone annotation: ${arg}` | ||
); | ||
}); |
25 changes: 25 additions & 0 deletions
25
test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-multiple-time-zone.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,25 @@ | ||
// 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: More than one time zone annotation is not syntactical | ||
features: [Temporal] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"1970-01-01[UTC][UTC]", | ||
"1970-01-01T00:00[UTC][UTC]", | ||
"1970-01-01T00:00[!UTC][UTC]", | ||
"1970-01-01T00:00[UTC][!UTC]", | ||
"1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", | ||
"1970-01-01T00:00[UTC][foo=bar][UTC]", | ||
]; | ||
const instance = new Temporal.Calendar("iso8601"); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.daysInWeek(arg), | ||
`reject more than one time zone annotation: ${arg}` | ||
); | ||
}); |
25 changes: 25 additions & 0 deletions
25
test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-multiple-time-zone.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,25 @@ | ||
// 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: More than one time zone annotation is not syntactical | ||
features: [Temporal] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"1970-01-01[UTC][UTC]", | ||
"1970-01-01T00:00[UTC][UTC]", | ||
"1970-01-01T00:00[!UTC][UTC]", | ||
"1970-01-01T00:00[UTC][!UTC]", | ||
"1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", | ||
"1970-01-01T00:00[UTC][foo=bar][UTC]", | ||
]; | ||
const instance = new Temporal.Calendar("iso8601"); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.daysInYear(arg), | ||
`reject more than one time zone annotation: ${arg}` | ||
); | ||
}); |
25 changes: 25 additions & 0 deletions
25
test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-multiple-time-zone.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,25 @@ | ||
// 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: More than one time zone annotation is not syntactical | ||
features: [Temporal] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"1970-01-01[UTC][UTC]", | ||
"1970-01-01T00:00[UTC][UTC]", | ||
"1970-01-01T00:00[!UTC][UTC]", | ||
"1970-01-01T00:00[UTC][!UTC]", | ||
"1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", | ||
"1970-01-01T00:00[UTC][foo=bar][UTC]", | ||
]; | ||
const instance = new Temporal.Calendar("iso8601"); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.inLeapYear(arg), | ||
`reject more than one time zone annotation: ${arg}` | ||
); | ||
}); |
25 changes: 25 additions & 0 deletions
25
test/built-ins/Temporal/Calendar/prototype/month/argument-string-multiple-time-zone.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,25 @@ | ||
// 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: More than one time zone annotation is not syntactical | ||
features: [Temporal] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"1970-01-01[UTC][UTC]", | ||
"1970-01-01T00:00[UTC][UTC]", | ||
"1970-01-01T00:00[!UTC][UTC]", | ||
"1970-01-01T00:00[UTC][!UTC]", | ||
"1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", | ||
"1970-01-01T00:00[UTC][foo=bar][UTC]", | ||
]; | ||
const instance = new Temporal.Calendar("iso8601"); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.month(arg), | ||
`reject more than one time zone annotation: ${arg}` | ||
); | ||
}); |
25 changes: 25 additions & 0 deletions
25
test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-multiple-time-zone.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,25 @@ | ||
// 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: More than one time zone annotation is not syntactical | ||
features: [Temporal] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"1970-01-01[UTC][UTC]", | ||
"1970-01-01T00:00[UTC][UTC]", | ||
"1970-01-01T00:00[!UTC][UTC]", | ||
"1970-01-01T00:00[UTC][!UTC]", | ||
"1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", | ||
"1970-01-01T00:00[UTC][foo=bar][UTC]", | ||
]; | ||
const instance = new Temporal.Calendar("iso8601"); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.monthCode(arg), | ||
`reject more than one time zone annotation: ${arg}` | ||
); | ||
}); |
25 changes: 25 additions & 0 deletions
25
.../built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-multiple-time-zone.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,25 @@ | ||
// 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: More than one time zone annotation is not syntactical | ||
features: [Temporal] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"1970-01-01[UTC][UTC]", | ||
"1970-01-01T00:00[UTC][UTC]", | ||
"1970-01-01T00:00[!UTC][UTC]", | ||
"1970-01-01T00:00[UTC][!UTC]", | ||
"1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", | ||
"1970-01-01T00:00[UTC][foo=bar][UTC]", | ||
]; | ||
const instance = new Temporal.Calendar("iso8601"); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.monthsInYear(arg), | ||
`reject more than one time zone annotation: ${arg}` | ||
); | ||
}); |
25 changes: 25 additions & 0 deletions
25
test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-multiple-time-zone.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,25 @@ | ||
// 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.weekofyear | ||
description: More than one time zone annotation is not syntactical | ||
features: [Temporal] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"1970-01-01[UTC][UTC]", | ||
"1970-01-01T00:00[UTC][UTC]", | ||
"1970-01-01T00:00[!UTC][UTC]", | ||
"1970-01-01T00:00[UTC][!UTC]", | ||
"1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", | ||
"1970-01-01T00:00[UTC][foo=bar][UTC]", | ||
]; | ||
const instance = new Temporal.Calendar("iso8601"); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.weekOfYear(arg), | ||
`reject more than one time zone annotation: ${arg}` | ||
); | ||
}); |
25 changes: 25 additions & 0 deletions
25
test/built-ins/Temporal/Calendar/prototype/year/argument-string-multiple-time-zone.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,25 @@ | ||
// 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.year | ||
description: More than one time zone annotation is not syntactical | ||
features: [Temporal] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"1970-01-01[UTC][UTC]", | ||
"1970-01-01T00:00[UTC][UTC]", | ||
"1970-01-01T00:00[!UTC][UTC]", | ||
"1970-01-01T00:00[UTC][!UTC]", | ||
"1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", | ||
"1970-01-01T00:00[UTC][foo=bar][UTC]", | ||
]; | ||
const instance = new Temporal.Calendar("iso8601"); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.year(arg), | ||
`reject more than one time zone annotation: ${arg}` | ||
); | ||
}); |
Oops, something went wrong.