Skip to content

Commit

Permalink
Add calendar strings to instant string tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditi-1400 authored and ptomato committed Aug 25, 2022
1 parent 747bed2 commit 8dcc0e1
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/built-ins/Temporal/Instant/compare/instant-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,15 @@ assert.sameValue(Temporal.Instant.compare(epoch, str), 0, "date-time + Z + IANA
str = "1970-01-01T00:00+01:00[Etc/Ignored]";
assert.sameValue(Temporal.Instant.compare(str, hourBefore), 0, "date-time + offset + IANA annotation ignores the IANA annotation (first argument)");
assert.sameValue(Temporal.Instant.compare(hourBefore, str), 0, "date-time + offset + IANA annotation ignores the IANA annotation (second argument)");

str = "1970-01-01T00:00Z[u-ca=hebrew]";
assert.sameValue(Temporal.Instant.compare(str, epoch), 0, "date-time + Z + Calendar ignores the Calendar (first argument)");
assert.sameValue(Temporal.Instant.compare(epoch, str), 0, "date-time + Z + Calendar ignores the Calendar (second argument)");

str = "1970-01-01T00:00+01:00[u-ca=hebrew]";
assert.sameValue(Temporal.Instant.compare(str, hourBefore), 0, "date-time + offset + Calendar ignores the Calendar (first argument)");
assert.sameValue(Temporal.Instant.compare(hourBefore, str), 0, "date-time + offset + Calendar ignores the Calendar (second argument)");

str = "1970-01-01T00:00+01:00[Etc/Ignored][u-ca=hebrew]";
assert.sameValue(Temporal.Instant.compare(str, hourBefore), 0, "date-time + offset + IANA annotation + Calendar ignores the IANA annotation and the Calendar (first argument)");
assert.sameValue(Temporal.Instant.compare(hourBefore, str), 0, "date-time + offset + IANA annotation + Calendar ignores the IANA annotation and the Calendar (second argument)");
12 changes: 12 additions & 0 deletions test/built-ins/Temporal/Instant/from/instant-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,15 @@ assert.sameValue(result3.epochNanoseconds, 0n, "date-time + Z + IANA annotation
str = "1970-01-01T00:00+01:00[Etc/Ignored]";
const result4 = Temporal.Instant.from(str);
assert.sameValue(result4.epochNanoseconds, -3600_000_000_000n, "date-time + offset + IANA annotation ignores the IANA annotation");

str = "1970-01-01T00:00Z[u-ca=hebrew]";
const result6 = Temporal.Instant.from(str);
assert.sameValue(result6.epochNanoseconds, 0n, "date-time + Z + Calendar ignores the Calendar");

str = "1970-01-01T00:00+01:00[u-ca=hebrew]";
const result7 = Temporal.Instant.from(str);
assert.sameValue(result7.epochNanoseconds, -3600_000_000_000n, "date-time + offset + Calendar ignores the Calendar");

str = "1970-01-01T00:00+01:00[Etc/Ignored][u-ca=hebrew]";
const result8 = Temporal.Instant.from(str);
assert.sameValue(result8.epochNanoseconds, -3600_000_000_000n, "date-time + offset + IANA annotation + Calendar ignores the Calendar and IANA annotation");
12 changes: 12 additions & 0 deletions test/built-ins/Temporal/Instant/prototype/equals/instant-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,15 @@ assert.sameValue(result3, true, "date-time + Z + IANA annotation ignores the IAN
str = "1970-01-01T00:00+01:00[Etc/Ignored]";
const result4 = instance.equals(str);
assert.sameValue(result4, false, "date-time + offset + IANA annotation ignores the IANA annotation");

str = "1970-01-01T00:00Z[u-ca=hebrew]";
const result6 = instance.equals(str);
assert.sameValue(result6, true, "date-time + Z + Calendar ignores the Calendar");

str = "1970-01-01T00:00+01:00[u-ca=hebrew]";
const result5 = instance.equals(str);
assert.sameValue(result5, false, "date-time + offset + Calendar ignores the Calendar");

str = "1970-01-01T00:00+01:00[Etc/Ignored][u-ca=hebrew]";
const result7 = instance.equals(str);
assert.sameValue(result7, false, "date-time + offset + IANA annotation + Calendar ignores the Calendar and IANA annotation");
12 changes: 12 additions & 0 deletions test/built-ins/Temporal/Instant/prototype/since/instant-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,15 @@ TemporalHelpers.assertDuration(result3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "date-time
str = "1970-01-01T00:00+01:00[Etc/Ignored]";
const result4 = instance.since(str);
TemporalHelpers.assertDuration(result4, 0, 0, 0, 0, 0, 0, 3600, 0, 0, 0, "date-time + offset + IANA annotation ignores the IANA annotation");

str = "1970-01-01T00:00Z[u-ca=hebrew]";
const result6 = instance.since(str);
TemporalHelpers.assertDuration(result6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "date-time + Z + Calendar ignores the Calendar");

str = "1970-01-01T00:00+01:00[u-ca=hebrew]";
const result5 = instance.since(str);
TemporalHelpers.assertDuration(result5, 0, 0, 0, 0, 0, 0, 3600, 0, 0, 0, "date-time + offset + Calendar ignores the Calendar");

str = "1970-01-01T00:00+01:00[Etc/Ignored][u-ca=hebrew]";
const result7 = instance.since(str);
TemporalHelpers.assertDuration(result7, 0, 0, 0, 0, 0, 0, 3600, 0, 0, 0, "date-time + offset + IANA annotation + Calendar ignores the Calendar and IANA annotation");
12 changes: 12 additions & 0 deletions test/built-ins/Temporal/Instant/prototype/until/instant-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,15 @@ TemporalHelpers.assertDuration(result3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "date-time
str = "1970-01-01T00:00+01:00[Etc/Ignored]";
const result4 = instance.until(str);
TemporalHelpers.assertDuration(result4, 0, 0, 0, 0, 0, 0, -3600, 0, 0, 0, "date-time + offset + IANA annotation ignores the IANA annotation");

str = "1970-01-01T00:00Z[u-ca=hebrew]";
const result6 = instance.until(str);
TemporalHelpers.assertDuration(result6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "date-time + Z + Calendar ignores the Calendar");

str = "1970-01-01T00:00+01:00[u-ca=hebrew]";
const result5 = instance.until(str);
TemporalHelpers.assertDuration(result5, 0, 0, 0, 0, 0, 0, -3600, 0, 0, 0, "date-time + offset + Calendar ignores the Calendar");

str = "1970-01-01T00:00+01:00[Etc/Ignored][u-ca=hebrew]";
const result7 = instance.until(str);
TemporalHelpers.assertDuration(result7, 0, 0, 0, 0, 0, 0, -3600, 0, 0, 0, "date-time + offset + IANA annotation + Calendar ignores the Calendar and IANA annotation");
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ const valids = [
"1970-01-01T00:00+01:00",
"1970-01-01T00:00Z[UTC]",
"1970-01-01T00:00+01:00[UTC]",
"1970-01-01T00:00Z[u-ca=hebrew]",
"1970-01-01T00:00+01:00[u-ca=hebrew]",
"1970-01-01T00:00+01:00[Etc/Ignored][u-ca=hebrew]",
];
for (const str of valids) {
const result = instance.getNextTransition(str);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ const valids = [
"1970-01-01T00:00+01:00",
"1970-01-01T00:00Z[UTC]",
"1970-01-01T00:00+01:00[UTC]",
"1970-01-01T00:00Z[u-ca=hebrew]",
"1970-01-01T00:00+01:00[u-ca=hebrew]",
"1970-01-01T00:00+01:00[Etc/Ignored][u-ca=hebrew]",
];
for (const str of valids) {
const result = instance.getOffsetNanosecondsFor(str);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ const valids = [
"1970-01-01T00:00+01:00",
"1970-01-01T00:00Z[UTC]",
"1970-01-01T00:00+01:00[UTC]",
"1970-01-01T00:00Z[u-ca=hebrew]",
"1970-01-01T00:00+01:00[u-ca=hebrew]",
"1970-01-01T00:00+01:00[Etc/Ignored][u-ca=hebrew]",
];
for (const str of valids) {
const result = instance.getOffsetStringFor(str);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,15 @@ TemporalHelpers.assertPlainDateTime(result3, 1970, 1, "M01", 1, 0, 0, 0, 0, 0, 0
str = "1970-01-01T00:00+01:00[Etc/Ignored]";
const result4 = instance.getPlainDateTimeFor(str);
TemporalHelpers.assertPlainDateTime(result4, 1969, 12, "M12", 31, 23, 0, 0, 0, 0, 0, "date-time + offset + IANA annotation ignores the IANA annotation");

str = "1970-01-01T00:00Z[u-ca=hebrew]";
const result6 = instance.getPlainDateTimeFor(str);
TemporalHelpers.assertPlainDateTime(result6, 1970, 1, "M01", 1, 0, 0, 0, 0, 0, 0, "date-time + Z + Calendar ignores the Calendar");

str = "1970-01-01T00:00+01:00[u-ca=hebrew]";
const result5 = instance.getPlainDateTimeFor(str);
TemporalHelpers.assertPlainDateTime(result5, 1969, 12, "M12", 31, 23, 0, 0, 0, 0, 0, "date-time + offset + Calendar ignores the Calendar");

str = "1970-01-01T00:00+01:00[Etc/Ignored][u-ca=hebrew]";
const result7 = instance.getPlainDateTimeFor(str);
TemporalHelpers.assertPlainDateTime(result7, 1969, 12, "M12", 31, 23, 0, 0, 0, 0, 0, "date-time + offset + IANA annotation + Calendar ignores the Calendar and IANA annotation");
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ const valids = [
"1970-01-01T00:00+01:00",
"1970-01-01T00:00Z[UTC]",
"1970-01-01T00:00+01:00[UTC]",
"1970-01-01T00:00Z[u-ca=hebrew]",
"1970-01-01T00:00+01:00[u-ca=hebrew]",
"1970-01-01T00:00+01:00[Etc/Ignored][u-ca=hebrew]",
];
for (const str of valids) {
const result = instance.getPreviousTransition(str);
Expand Down

0 comments on commit 8dcc0e1

Please sign in to comment.