-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test rejection of "Z" UTC designators in Plain strings
Tests for the normative changes made to Temporal in tc39/proposal-temporal#1874
- Loading branch information
Showing
49 changed files
with
1,030 additions
and
2 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-with-utc-designator.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,21 @@ | ||
// 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.calendar.prototype.dateadd | ||
description: RangeError thrown if a string with UTC designator is used as a PlainDate | ||
features: [Temporal, arrow-function] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"2019-10-01T09:00:00Z", | ||
"2019-10-01T09:00:00Z[UTC]", | ||
]; | ||
const instance = new Temporal.Calendar("iso8601"); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.dateAdd(arg), | ||
"String with UTC designator should not be valid as a PlainDate" | ||
); | ||
}); |
27 changes: 27 additions & 0 deletions
27
test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-with-utc-designator.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,27 @@ | ||
// 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.calendar.prototype.dateuntil | ||
description: RangeError thrown if a string with UTC designator is used as a PlainDate | ||
features: [Temporal, arrow-function] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"2019-10-01T09:00:00Z", | ||
"2019-10-01T09:00:00Z[UTC]", | ||
]; | ||
const instance = new Temporal.Calendar("iso8601"); | ||
const plainDate = new Temporal.PlainDate(2000, 5, 2); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.dateUntil(arg, plainDate), | ||
"String with UTC designator should not be valid as a PlainDate (first argument)" | ||
); | ||
assert.throws( | ||
RangeError, | ||
() => instance.dateUntil(plainDate, arg), | ||
"String with UTC designator should not be valid as a PlainDate (second argument)" | ||
); | ||
}); |
21 changes: 21 additions & 0 deletions
21
test/built-ins/Temporal/Calendar/prototype/day/argument-string-with-utc-designator.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,21 @@ | ||
// 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.calendar.prototype.day | ||
description: RangeError thrown if a string with UTC designator is used as a PlainDate | ||
features: [Temporal, arrow-function] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"2019-10-01T09:00:00Z", | ||
"2019-10-01T09:00:00Z[UTC]", | ||
]; | ||
const instance = new Temporal.Calendar("iso8601"); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.day(arg), | ||
"String with UTC designator should not be valid as a PlainDate" | ||
); | ||
}); |
21 changes: 21 additions & 0 deletions
21
test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-with-utc-designator.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,21 @@ | ||
// 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.calendar.prototype.dayofweek | ||
description: RangeError thrown if a string with UTC designator is used as a PlainDate | ||
features: [Temporal, arrow-function] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"2019-10-01T09:00:00Z", | ||
"2019-10-01T09:00:00Z[UTC]", | ||
]; | ||
const instance = new Temporal.Calendar("iso8601"); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.dayOfWeek(arg), | ||
"String with UTC designator should not be valid as a PlainDate" | ||
); | ||
}); |
21 changes: 21 additions & 0 deletions
21
test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-with-utc-designator.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,21 @@ | ||
// 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.calendar.prototype.dayofyear | ||
description: RangeError thrown if a string with UTC designator is used as a PlainDate | ||
features: [Temporal, arrow-function] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"2019-10-01T09:00:00Z", | ||
"2019-10-01T09:00:00Z[UTC]", | ||
]; | ||
const instance = new Temporal.Calendar("iso8601"); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.dayOfYear(arg), | ||
"String with UTC designator should not be valid as a PlainDate" | ||
); | ||
}); |
21 changes: 21 additions & 0 deletions
21
.../built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-with-utc-designator.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,21 @@ | ||
// 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.calendar.prototype.daysinmonth | ||
description: RangeError thrown if a string with UTC designator is used as a PlainDate | ||
features: [Temporal, arrow-function] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"2019-10-01T09:00:00Z", | ||
"2019-10-01T09:00:00Z[UTC]", | ||
]; | ||
const instance = new Temporal.Calendar("iso8601"); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.daysInMonth(arg), | ||
"String with UTC designator should not be valid as a PlainDate" | ||
); | ||
}); |
21 changes: 21 additions & 0 deletions
21
test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-with-utc-designator.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,21 @@ | ||
// 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.calendar.prototype.daysinweek | ||
description: RangeError thrown if a string with UTC designator is used as a PlainDate | ||
features: [Temporal, arrow-function] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"2019-10-01T09:00:00Z", | ||
"2019-10-01T09:00:00Z[UTC]", | ||
]; | ||
const instance = new Temporal.Calendar("iso8601"); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.daysInWeek(arg), | ||
"String with UTC designator should not be valid as a PlainDate" | ||
); | ||
}); |
21 changes: 21 additions & 0 deletions
21
test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-with-utc-designator.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,21 @@ | ||
// 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.calendar.prototype.daysinyear | ||
description: RangeError thrown if a string with UTC designator is used as a PlainDate | ||
features: [Temporal, arrow-function] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"2019-10-01T09:00:00Z", | ||
"2019-10-01T09:00:00Z[UTC]", | ||
]; | ||
const instance = new Temporal.Calendar("iso8601"); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.daysInYear(arg), | ||
"String with UTC designator should not be valid as a PlainDate" | ||
); | ||
}); |
21 changes: 21 additions & 0 deletions
21
test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-with-utc-designator.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,21 @@ | ||
// 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.calendar.prototype.inleapyear | ||
description: RangeError thrown if a string with UTC designator is used as a PlainDate | ||
features: [Temporal, arrow-function] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"2019-10-01T09:00:00Z", | ||
"2019-10-01T09:00:00Z[UTC]", | ||
]; | ||
const instance = new Temporal.Calendar("iso8601"); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.inLeapYear(arg), | ||
"String with UTC designator should not be valid as a PlainDate" | ||
); | ||
}); |
21 changes: 21 additions & 0 deletions
21
test/built-ins/Temporal/Calendar/prototype/month/argument-string-with-utc-designator.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,21 @@ | ||
// 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.calendar.prototype.month | ||
description: RangeError thrown if a string with UTC designator is used as a PlainDate | ||
features: [Temporal, arrow-function] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"2019-10-01T09:00:00Z", | ||
"2019-10-01T09:00:00Z[UTC]", | ||
]; | ||
const instance = new Temporal.Calendar("iso8601"); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.month(arg), | ||
"String with UTC designator should not be valid as a PlainDate" | ||
); | ||
}); |
21 changes: 21 additions & 0 deletions
21
test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-with-utc-designator.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,21 @@ | ||
// 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.calendar.prototype.monthcode | ||
description: RangeError thrown if a string with UTC designator is used as a PlainDate | ||
features: [Temporal, arrow-function] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"2019-10-01T09:00:00Z", | ||
"2019-10-01T09:00:00Z[UTC]", | ||
]; | ||
const instance = new Temporal.Calendar("iso8601"); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.monthCode(arg), | ||
"String with UTC designator should not be valid as a PlainDate" | ||
); | ||
}); |
21 changes: 21 additions & 0 deletions
21
...built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-with-utc-designator.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,21 @@ | ||
// 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.calendar.prototype.monthsinyear | ||
description: RangeError thrown if a string with UTC designator is used as a PlainDate | ||
features: [Temporal, arrow-function] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"2019-10-01T09:00:00Z", | ||
"2019-10-01T09:00:00Z[UTC]", | ||
]; | ||
const instance = new Temporal.Calendar("iso8601"); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.monthsInYear(arg), | ||
"String with UTC designator should not be valid as a PlainDate" | ||
); | ||
}); |
21 changes: 21 additions & 0 deletions
21
test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-with-utc-designator.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,21 @@ | ||
// 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.calendar.prototype.weekofyear | ||
description: RangeError thrown if a string with UTC designator is used as a PlainDate | ||
features: [Temporal, arrow-function] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"2019-10-01T09:00:00Z", | ||
"2019-10-01T09:00:00Z[UTC]", | ||
]; | ||
const instance = new Temporal.Calendar("iso8601"); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.weekOfYear(arg), | ||
"String with UTC designator should not be valid as a PlainDate" | ||
); | ||
}); |
21 changes: 21 additions & 0 deletions
21
test/built-ins/Temporal/Calendar/prototype/year/argument-string-with-utc-designator.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,21 @@ | ||
// 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.calendar.prototype.year | ||
description: RangeError thrown if a string with UTC designator is used as a PlainDate | ||
features: [Temporal, arrow-function] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"2019-10-01T09:00:00Z", | ||
"2019-10-01T09:00:00Z[UTC]", | ||
]; | ||
const instance = new Temporal.Calendar("iso8601"); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.year(arg), | ||
"String with UTC designator should not be valid as a PlainDate" | ||
); | ||
}); |
26 changes: 26 additions & 0 deletions
26
test/built-ins/Temporal/PlainDate/compare/argument-string-with-utc-designator.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,26 @@ | ||
// 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.compare | ||
description: RangeError thrown if a string with UTC designator is used as a PlainDate | ||
features: [Temporal, arrow-function] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"2019-10-01T09:00:00Z", | ||
"2019-10-01T09:00:00Z[UTC]", | ||
]; | ||
const plainDate = new Temporal.PlainDate(2000, 5, 2); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => Temporal.PlainDate.compare(arg, plainDate), | ||
"String with UTC designator should not be valid as a PlainDate (first argument)" | ||
); | ||
assert.throws( | ||
RangeError, | ||
() => Temporal.PlainDate.compare(plainDate, arg), | ||
"String with UTC designator should not be valid as a PlainDate (second argument)" | ||
); | ||
}); |
20 changes: 20 additions & 0 deletions
20
test/built-ins/Temporal/PlainDate/from/argument-string-with-utc-designator.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,20 @@ | ||
// 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.from | ||
description: RangeError thrown if a string with UTC designator is used as a PlainDate | ||
features: [Temporal, arrow-function] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"2019-10-01T09:00:00Z", | ||
"2019-10-01T09:00:00Z[UTC]", | ||
]; | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => Temporal.PlainDate.from(arg), | ||
"String with UTC designator should not be valid as a PlainDate" | ||
); | ||
}); |
21 changes: 21 additions & 0 deletions
21
test/built-ins/Temporal/PlainDate/prototype/equals/argument-string-with-utc-designator.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,21 @@ | ||
// 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.prototype.equals | ||
description: RangeError thrown if a string with UTC designator is used as a PlainDate | ||
features: [Temporal, arrow-function] | ||
---*/ | ||
|
||
const invalidStrings = [ | ||
"2019-10-01T09:00:00Z", | ||
"2019-10-01T09:00:00Z[UTC]", | ||
]; | ||
const instance = new Temporal.PlainDate(2000, 5, 2); | ||
invalidStrings.forEach((arg) => { | ||
assert.throws( | ||
RangeError, | ||
() => instance.equals(arg), | ||
"String with UTC designator should not be valid as a PlainDate" | ||
); | ||
}); |
Oops, something went wrong.