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 unknown annotation without critical flag
See tc39/proposal-temporal#2397 Adds tests for ISO strings with unrecognized annotations, (i.e., neither time zone nor calendar), in various combinations with recognized annotations.
- Loading branch information
Showing
63 changed files
with
1,860 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-unknown-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,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.dateadd | ||
description: Various forms of unknown annotation | ||
features: [Temporal] | ||
includes: [temporalHelpers.js] | ||
---*/ | ||
|
||
const tests = [ | ||
["2000-05-02[foo=bar]", "without time"], | ||
["2000-05-02T15:23[foo=bar]", "alone"], | ||
["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], | ||
["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], | ||
["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], | ||
["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], | ||
]; | ||
|
||
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, | ||
`unknown annotation (${description})` | ||
); | ||
}); |
30 changes: 30 additions & 0 deletions
30
test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-unknown-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,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: Various forms of unknown annotation | ||
features: [Temporal] | ||
includes: [temporalHelpers.js] | ||
---*/ | ||
|
||
const tests = [ | ||
["2000-05-02[foo=bar]", "without time"], | ||
["2000-05-02T15:23[foo=bar]", "alone"], | ||
["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], | ||
["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], | ||
["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], | ||
["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], | ||
]; | ||
|
||
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, | ||
`unknown annotation (${description})` | ||
); | ||
}); |
29 changes: 29 additions & 0 deletions
29
test/built-ins/Temporal/Calendar/prototype/day/argument-string-unknown-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,29 @@ | ||
// 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 unknown annotation | ||
features: [Temporal] | ||
---*/ | ||
|
||
const tests = [ | ||
["2000-05-02[foo=bar]", "without time"], | ||
["2000-05-02T15:23[foo=bar]", "alone"], | ||
["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], | ||
["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], | ||
["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], | ||
["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], | ||
]; | ||
|
||
const instance = new Temporal.Calendar("iso8601"); | ||
|
||
tests.forEach(([arg, description]) => { | ||
const result = instance.day(arg); | ||
|
||
assert.sameValue( | ||
result, | ||
2, | ||
`unknown annotation (${description})` | ||
); | ||
}); |
29 changes: 29 additions & 0 deletions
29
test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-unknown-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,29 @@ | ||
// 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 unknown annotation | ||
features: [Temporal] | ||
---*/ | ||
|
||
const tests = [ | ||
["2000-05-02[foo=bar]", "without time"], | ||
["2000-05-02T15:23[foo=bar]", "alone"], | ||
["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], | ||
["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], | ||
["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], | ||
["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], | ||
]; | ||
|
||
const instance = new Temporal.Calendar("iso8601"); | ||
|
||
tests.forEach(([arg, description]) => { | ||
const result = instance.dayOfWeek(arg); | ||
|
||
assert.sameValue( | ||
result, | ||
2, | ||
`unknown annotation (${description})` | ||
); | ||
}); |
29 changes: 29 additions & 0 deletions
29
test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-unknown-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,29 @@ | ||
// 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 unknown annotation | ||
features: [Temporal] | ||
---*/ | ||
|
||
const tests = [ | ||
["2000-05-02[foo=bar]", "without time"], | ||
["2000-05-02T15:23[foo=bar]", "alone"], | ||
["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], | ||
["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], | ||
["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], | ||
["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], | ||
]; | ||
|
||
const instance = new Temporal.Calendar("iso8601"); | ||
|
||
tests.forEach(([arg, description]) => { | ||
const result = instance.dayOfYear(arg); | ||
|
||
assert.sameValue( | ||
result, | ||
123, | ||
`unknown annotation (${description})` | ||
); | ||
}); |
29 changes: 29 additions & 0 deletions
29
test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-unknown-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,29 @@ | ||
// 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 unknown annotation | ||
features: [Temporal] | ||
---*/ | ||
|
||
const tests = [ | ||
["2000-05-02[foo=bar]", "without time"], | ||
["2000-05-02T15:23[foo=bar]", "alone"], | ||
["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], | ||
["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], | ||
["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], | ||
["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], | ||
]; | ||
|
||
const instance = new Temporal.Calendar("iso8601"); | ||
|
||
tests.forEach(([arg, description]) => { | ||
const result = instance.daysInMonth(arg); | ||
|
||
assert.sameValue( | ||
result, | ||
31, | ||
`unknown annotation (${description})` | ||
); | ||
}); |
29 changes: 29 additions & 0 deletions
29
test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-unknown-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,29 @@ | ||
// 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 unknown annotation | ||
features: [Temporal] | ||
---*/ | ||
|
||
const tests = [ | ||
["2000-05-02[foo=bar]", "without time"], | ||
["2000-05-02T15:23[foo=bar]", "alone"], | ||
["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], | ||
["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], | ||
["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], | ||
["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], | ||
]; | ||
|
||
const instance = new Temporal.Calendar("iso8601"); | ||
|
||
tests.forEach(([arg, description]) => { | ||
const result = instance.daysInWeek(arg); | ||
|
||
assert.sameValue( | ||
result, | ||
7, | ||
`unknown annotation (${description})` | ||
); | ||
}); |
29 changes: 29 additions & 0 deletions
29
test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-unknown-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,29 @@ | ||
// 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 unknown annotation | ||
features: [Temporal] | ||
---*/ | ||
|
||
const tests = [ | ||
["2000-05-02[foo=bar]", "without time"], | ||
["2000-05-02T15:23[foo=bar]", "alone"], | ||
["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], | ||
["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], | ||
["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], | ||
["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], | ||
]; | ||
|
||
const instance = new Temporal.Calendar("iso8601"); | ||
|
||
tests.forEach(([arg, description]) => { | ||
const result = instance.daysInYear(arg); | ||
|
||
assert.sameValue( | ||
result, | ||
366, | ||
`unknown annotation (${description})` | ||
); | ||
}); |
29 changes: 29 additions & 0 deletions
29
test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-unknown-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,29 @@ | ||
// 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 unknown annotation | ||
features: [Temporal] | ||
---*/ | ||
|
||
const tests = [ | ||
["2000-05-02[foo=bar]", "without time"], | ||
["2000-05-02T15:23[foo=bar]", "alone"], | ||
["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], | ||
["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], | ||
["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], | ||
["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], | ||
]; | ||
|
||
const instance = new Temporal.Calendar("iso8601"); | ||
|
||
tests.forEach(([arg, description]) => { | ||
const result = instance.inLeapYear(arg); | ||
|
||
assert.sameValue( | ||
result, | ||
true, | ||
`unknown annotation (${description})` | ||
); | ||
}); |
29 changes: 29 additions & 0 deletions
29
test/built-ins/Temporal/Calendar/prototype/month/argument-string-unknown-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,29 @@ | ||
// 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 unknown annotation | ||
features: [Temporal] | ||
---*/ | ||
|
||
const tests = [ | ||
["2000-05-02[foo=bar]", "without time"], | ||
["2000-05-02T15:23[foo=bar]", "alone"], | ||
["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], | ||
["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], | ||
["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], | ||
["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], | ||
]; | ||
|
||
const instance = new Temporal.Calendar("iso8601"); | ||
|
||
tests.forEach(([arg, description]) => { | ||
const result = instance.month(arg); | ||
|
||
assert.sameValue( | ||
result, | ||
5, | ||
`unknown annotation (${description})` | ||
); | ||
}); |
29 changes: 29 additions & 0 deletions
29
test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-unknown-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,29 @@ | ||
// 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 unknown annotation | ||
features: [Temporal] | ||
---*/ | ||
|
||
const tests = [ | ||
["2000-05-02[foo=bar]", "without time"], | ||
["2000-05-02T15:23[foo=bar]", "alone"], | ||
["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], | ||
["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], | ||
["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], | ||
["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], | ||
]; | ||
|
||
const instance = new Temporal.Calendar("iso8601"); | ||
|
||
tests.forEach(([arg, description]) => { | ||
const result = instance.monthCode(arg); | ||
|
||
assert.sameValue( | ||
result, | ||
"M05", | ||
`unknown annotation (${description})` | ||
); | ||
}); |
29 changes: 29 additions & 0 deletions
29
.../built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-unknown-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,29 @@ | ||
// 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 unknown annotation | ||
features: [Temporal] | ||
---*/ | ||
|
||
const tests = [ | ||
["2000-05-02[foo=bar]", "without time"], | ||
["2000-05-02T15:23[foo=bar]", "alone"], | ||
["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], | ||
["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], | ||
["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], | ||
["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], | ||
]; | ||
|
||
const instance = new Temporal.Calendar("iso8601"); | ||
|
||
tests.forEach(([arg, description]) => { | ||
const result = instance.monthsInYear(arg); | ||
|
||
assert.sameValue( | ||
result, | ||
12, | ||
`unknown annotation (${description})` | ||
); | ||
}); |
29 changes: 29 additions & 0 deletions
29
test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-unknown-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,29 @@ | ||
// 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: Various forms of unknown annotation | ||
features: [Temporal] | ||
---*/ | ||
|
||
const tests = [ | ||
["2000-05-02[foo=bar]", "without time"], | ||
["2000-05-02T15:23[foo=bar]", "alone"], | ||
["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], | ||
["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], | ||
["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], | ||
["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], | ||
]; | ||
|
||
const instance = new Temporal.Calendar("iso8601"); | ||
|
||
tests.forEach(([arg, description]) => { | ||
const result = instance.weekOfYear(arg); | ||
|
||
assert.sameValue( | ||
result, | ||
18, | ||
`unknown annotation (${description})` | ||
); | ||
}); |
Oops, something went wrong.