-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
322 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
polyfill/test/Calendar/prototype/dateAdd/argument-plaindatetime.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,24 @@ | ||
// 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: Fast path for converting Temporal.PlainDateTime to Temporal.PlainDate by reading internal slots | ||
info: | | ||
sec-temporal.calendar.prototype.dateadd step 4: | ||
4. Set _date_ to ? ToTemporalDate(_date_). | ||
sec-temporal-totemporaldate step 2.b: | ||
b. If _item_ has an [[InitializedTemporalDateTime]] internal slot, then | ||
i. Return ! CreateTemporalDate(_item_.[[ISOYear]], _item_.[[ISOMonth]], _item_.[[ISODay]], _item_.[[Calendar]]). | ||
includes: [compareArray.js, temporalHelpers.js] | ||
---*/ | ||
|
||
TemporalHelpers.checkPlainDateTimeConversionFastPath((datetime) => { | ||
const calendar = new Temporal.Calendar("iso8601"); | ||
const duration = new Temporal.Duration(0, 1); | ||
const result = calendar.dateAdd(datetime, duration); | ||
assert.sameValue(result.year, 2000, "year result"); | ||
assert.sameValue(result.month, 6, "month result"); | ||
assert.sameValue(result.day, 2, "day result"); | ||
assert.sameValue(result.hour, undefined, "instance of PlainDate returned, not PlainDateTime"); | ||
}); |
29 changes: 29 additions & 0 deletions
29
polyfill/test/Calendar/prototype/dateUntil/argument-plaindatetime.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) 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: Fast path for converting Temporal.PlainDateTime to Temporal.PlainDate by reading internal slots | ||
info: | | ||
sec-temporal.calendar.prototype.dateuntil steps 4–5: | ||
4. Set _one_ to ? ToTemporalDate(_one_). | ||
5. Set _two_ to ? ToTemporalDate(_two_). | ||
sec-temporal-totemporaldate step 2.b: | ||
b. If _item_ has an [[InitializedTemporalDateTime]] internal slot, then | ||
i. Return ! CreateTemporalDate(_item_.[[ISOYear]], _item_.[[ISOMonth]], _item_.[[ISODay]], _item_.[[Calendar]]). | ||
includes: [compareArray.js, temporalHelpers.js] | ||
---*/ | ||
|
||
const date = new Temporal.PlainDate(2000, 5, 2); | ||
|
||
TemporalHelpers.checkPlainDateTimeConversionFastPath((datetime) => { | ||
const calendar = new Temporal.Calendar("iso8601"); | ||
const result = calendar.dateUntil(datetime, date); | ||
assert.sameValue(result.total({ unit: "nanoseconds" }), 0, "time part dropped"); | ||
}); | ||
|
||
TemporalHelpers.checkPlainDateTimeConversionFastPath((datetime) => { | ||
const calendar = new Temporal.Calendar("iso8601"); | ||
const result = calendar.dateUntil(date, datetime); | ||
assert.sameValue(result.total({ unit: "nanoseconds" }), 0, "time part dropped"); | ||
}); |
27 changes: 27 additions & 0 deletions
27
polyfill/test/PlainDate/constructor/compare/argument-plaindatetime.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.plaindate.compare | ||
description: Fast path for converting Temporal.PlainDateTime to Temporal.PlainDate by reading internal slots | ||
info: | | ||
sec-temporal.plaindate.compare steps 1–2: | ||
1. Set _one_ to ? ToTemporalDate(_one_). | ||
2. Set _two_ to ? ToTemporalDate(_two_). | ||
sec-temporal-totemporaldate step 2.b: | ||
b. If _item_ has an [[InitializedTemporalDateTime]] internal slot, then | ||
i. Return ! CreateTemporalDate(_item_.[[ISOYear]], _item_.[[ISOMonth]], _item_.[[ISODay]], _item_.[[Calendar]]). | ||
includes: [compareArray.js, temporalHelpers.js] | ||
---*/ | ||
|
||
const date = new Temporal.PlainDate(2000, 5, 2); | ||
|
||
TemporalHelpers.checkPlainDateTimeConversionFastPath((datetime) => { | ||
const result = Temporal.PlainDate.compare(datetime, date); | ||
assert.sameValue(result, 0, "comparison result"); | ||
}); | ||
|
||
TemporalHelpers.checkPlainDateTimeConversionFastPath((datetime) => { | ||
const result = Temporal.PlainDate.compare(date, datetime); | ||
assert.sameValue(result, 0, "comparison result"); | ||
}); |
22 changes: 22 additions & 0 deletions
22
polyfill/test/PlainDate/constructor/from/argument-plaindatetime.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,22 @@ | ||
// 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: Fast path for converting Temporal.PlainDateTime to Temporal.PlainDate by reading internal slots | ||
info: | | ||
sec-temporal.plaindate.from step 3: | ||
3. Return ? ToTemporalDate(_item_, _options_). | ||
sec-temporal-totemporaldate step 2.b: | ||
b. If _item_ has an [[InitializedTemporalDateTime]] internal slot, then | ||
i. Return ! CreateTemporalDate(_item_.[[ISOYear]], _item_.[[ISOMonth]], _item_.[[ISODay]], _item_.[[Calendar]]). | ||
includes: [compareArray.js, temporalHelpers.js] | ||
---*/ | ||
|
||
TemporalHelpers.checkPlainDateTimeConversionFastPath((datetime, calendar) => { | ||
const result = Temporal.PlainDate.from(datetime); | ||
assert.sameValue(result.year, 2000, "year result"); | ||
assert.sameValue(result.month, 5, "month result"); | ||
assert.sameValue(result.day, 2, "day result"); | ||
assert.sameValue(result.calendar, calendar, "calendar result"); | ||
}); |
19 changes: 19 additions & 0 deletions
19
polyfill/test/PlainDate/prototype/equals/argument-plaindatetime.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,19 @@ | ||
// 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: Fast path for converting Temporal.PlainDateTime to Temporal.PlainDate by reading internal slots | ||
info: | | ||
sec-temporal.plaindate.prototype.equals step 3: | ||
3. Set _other_ to ? ToTemporalDate(_other_). | ||
sec-temporal-totemporaldate step 2.b: | ||
b. If _item_ has an [[InitializedTemporalDateTime]] internal slot, then | ||
i. Return ! CreateTemporalDate(_item_.[[ISOYear]], _item_.[[ISOMonth]], _item_.[[ISODay]], _item_.[[Calendar]]). | ||
includes: [compareArray.js, temporalHelpers.js] | ||
---*/ | ||
|
||
TemporalHelpers.checkPlainDateTimeConversionFastPath((datetime) => { | ||
const date = new Temporal.PlainDate(2000, 5, 2); | ||
assert(date.equals(datetime)); | ||
}); |
20 changes: 20 additions & 0 deletions
20
polyfill/test/PlainDate/prototype/since/argument-plaindatetime.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.since | ||
description: Fast path for converting Temporal.PlainDateTime to Temporal.PlainDate by reading internal slots | ||
info: | | ||
sec-temporal.plaindate.prototype.since step 3: | ||
3. Set _other_ to ? ToTemporalDate(_other_). | ||
sec-temporal-totemporaldate step 2.b: | ||
b. If _item_ has an [[InitializedTemporalDateTime]] internal slot, then | ||
i. Return ! CreateTemporalDate(_item_.[[ISOYear]], _item_.[[ISOMonth]], _item_.[[ISODay]], _item_.[[Calendar]]). | ||
includes: [compareArray.js, temporalHelpers.js] | ||
---*/ | ||
|
||
TemporalHelpers.checkPlainDateTimeConversionFastPath((datetime) => { | ||
const date = new Temporal.PlainDate(2000, 5, 2); | ||
const result = date.since(datetime); | ||
assert.sameValue(result.total({ unit: "nanoseconds" }), 0, "time part dropped"); | ||
}); |
20 changes: 20 additions & 0 deletions
20
polyfill/test/PlainDate/prototype/until/argument-plaindatetime.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.until | ||
description: Fast path for converting Temporal.PlainDateTime to Temporal.PlainDate by reading internal slots | ||
info: | | ||
sec-temporal.plaindate.prototype.until step 3: | ||
3. Set _other_ to ? ToTemporalDate(_other_). | ||
sec-temporal-totemporaldate step 2.b: | ||
b. If _item_ has an [[InitializedTemporalDateTime]] internal slot, then | ||
i. Return ! CreateTemporalDate(_item_.[[ISOYear]], _item_.[[ISOMonth]], _item_.[[ISODay]], _item_.[[Calendar]]). | ||
includes: [compareArray.js, temporalHelpers.js] | ||
---*/ | ||
|
||
TemporalHelpers.checkPlainDateTimeConversionFastPath((datetime) => { | ||
const date = new Temporal.PlainDate(2000, 5, 2); | ||
const result = date.until(datetime); | ||
assert.sameValue(result.total({ unit: "nanoseconds" }), 0, "time part dropped"); | ||
}); |
28 changes: 28 additions & 0 deletions
28
polyfill/test/PlainDateTime/prototype/withPlainDate/argument-plaindatetime.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,28 @@ | ||
// 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.plaindatetime.withplaindate | ||
description: Fast path for converting Temporal.PlainDateTime to Temporal.PlainDate by reading internal slots | ||
info: | | ||
sec-temporal.plaindatetime.prototype.withplaindate step 3: | ||
3. Let _plainDate_ be ? ToTemporalDate(_plainDateLike_). | ||
sec-temporal-totemporaldate step 2.b: | ||
b. If _item_ has an [[InitializedTemporalDateTime]] internal slot, then | ||
i. Return ! CreateTemporalDate(_item_.[[ISOYear]], _item_.[[ISOMonth]], _item_.[[ISODay]], _item_.[[Calendar]]). | ||
includes: [compareArray.js, temporalHelpers.js] | ||
---*/ | ||
|
||
TemporalHelpers.checkPlainDateTimeConversionFastPath((datetime) => { | ||
const receiver = new Temporal.PlainDateTime(2001, 9, 9, 6, 54, 32, 123, 456, 789); | ||
const result = receiver.withPlainDate(datetime); | ||
assert.sameValue(result.year, 2000, "year result"); | ||
assert.sameValue(result.month, 5, "month result"); | ||
assert.sameValue(result.day, 2, "day result"); | ||
assert.sameValue(result.hour, 6, "hour result"); | ||
assert.sameValue(result.minute, 54, "minute result"); | ||
assert.sameValue(result.second, 32, "second result"); | ||
assert.sameValue(result.millisecond, 123, "millisecond result"); | ||
assert.sameValue(result.microsecond, 456, "microsecond result"); | ||
assert.sameValue(result.nanosecond, 789, "nanosecond result"); | ||
}); |
28 changes: 28 additions & 0 deletions
28
polyfill/test/PlainTime/prototype/toPlainDateTime/argument-plaindatetime.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,28 @@ | ||
// 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.plaintime.toplaindatetime | ||
description: Fast path for converting Temporal.PlainDateTime to Temporal.PlainDate by reading internal slots | ||
info: | | ||
sec-temporal.plaintime.prototype.toplaindatetime step 3: | ||
3. Set _temporalDate_ to ? ToTemporalDate(_temporalDate_). | ||
sec-temporal-totemporaldate step 2.b: | ||
b. If _item_ has an [[InitializedTemporalDateTime]] internal slot, then | ||
i. Return ! CreateTemporalDate(_item_.[[ISOYear]], _item_.[[ISOMonth]], _item_.[[ISODay]], _item_.[[Calendar]]). | ||
includes: [compareArray.js, temporalHelpers.js] | ||
---*/ | ||
|
||
TemporalHelpers.checkPlainDateTimeConversionFastPath((datetime) => { | ||
const time = new Temporal.PlainTime(6, 54, 32, 123, 456, 789); | ||
const result = time.toPlainDateTime(datetime); | ||
assert.sameValue(result.year, 2000, "year result"); | ||
assert.sameValue(result.month, 5, "month result"); | ||
assert.sameValue(result.day, 2, "day result"); | ||
assert.sameValue(result.hour, 6, "hour result"); | ||
assert.sameValue(result.minute, 54, "minute result"); | ||
assert.sameValue(result.second, 32, "second result"); | ||
assert.sameValue(result.millisecond, 123, "millisecond result"); | ||
assert.sameValue(result.microsecond, 456, "microsecond result"); | ||
assert.sameValue(result.nanosecond, 789, "nanosecond result"); | ||
}); |
28 changes: 28 additions & 0 deletions
28
polyfill/test/PlainTime/prototype/toZonedDateTime/argument-plaindatetime.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,28 @@ | ||
// 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.plaintime.tozoneddatetime | ||
description: Fast path for converting Temporal.PlainDateTime to Temporal.PlainDate by reading internal slots | ||
info: | | ||
sec-temporal.plaintime.prototype.tozoneddatetime step 5: | ||
5. Let _temporalDate_ be ? ToTemporalDate(_temporalDateLike_). | ||
sec-temporal-totemporaldate step 2.b: | ||
b. If _item_ has an [[InitializedTemporalDateTime]] internal slot, then | ||
i. Return ! CreateTemporalDate(_item_.[[ISOYear]], _item_.[[ISOMonth]], _item_.[[ISODay]], _item_.[[Calendar]]). | ||
includes: [compareArray.js, temporalHelpers.js] | ||
---*/ | ||
|
||
TemporalHelpers.checkPlainDateTimeConversionFastPath((datetime) => { | ||
const time = new Temporal.PlainTime(6, 54, 32, 123, 456, 789); | ||
const result = time.toZonedDateTime({ plainDate: datetime, timeZone: "UTC" }); | ||
assert.sameValue(result.year, 2000, "year result"); | ||
assert.sameValue(result.month, 5, "month result"); | ||
assert.sameValue(result.day, 2, "day result"); | ||
assert.sameValue(result.hour, 6, "hour result"); | ||
assert.sameValue(result.minute, 54, "minute result"); | ||
assert.sameValue(result.second, 32, "second result"); | ||
assert.sameValue(result.millisecond, 123, "millisecond result"); | ||
assert.sameValue(result.microsecond, 456, "microsecond result"); | ||
assert.sameValue(result.nanosecond, 789, "nanosecond result"); | ||
}); |
28 changes: 28 additions & 0 deletions
28
polyfill/test/ZonedDateTime/prototype/withPlainDate/argument-plaindatetime.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,28 @@ | ||
// 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.zoneddatetime.withplaindate | ||
description: Fast path for converting Temporal.PlainDateTime to Temporal.PlainDate by reading internal slots | ||
info: | | ||
sec-temporal.zoneddatetime.prototype.withplaindate step 3: | ||
3. Let _plainDate_ be ? ToTemporalDate(_plainDateLike_). | ||
sec-temporal-totemporaldate step 2.b: | ||
b. If _item_ has an [[InitializedTemporalDateTime]] internal slot, then | ||
i. Return ! CreateTemporalDate(_item_.[[ISOYear]], _item_.[[ISOMonth]], _item_.[[ISODay]], _item_.[[Calendar]]). | ||
includes: [compareArray.js, temporalHelpers.js] | ||
---*/ | ||
|
||
TemporalHelpers.checkPlainDateTimeConversionFastPath((datetime) => { | ||
const receiver = new Temporal.ZonedDateTime(1_000_000_000_123_456_789n, "UTC"); | ||
const result = receiver.withPlainDate(datetime); | ||
assert.sameValue(result.year, 2000, "year result"); | ||
assert.sameValue(result.month, 5, "month result"); | ||
assert.sameValue(result.day, 2, "day result"); | ||
assert.sameValue(result.hour, 1, "hour result"); | ||
assert.sameValue(result.minute, 46, "minute result"); | ||
assert.sameValue(result.second, 40, "second result"); | ||
assert.sameValue(result.millisecond, 123, "millisecond result"); | ||
assert.sameValue(result.microsecond, 456, "microsecond result"); | ||
assert.sameValue(result.nanosecond, 789, "nanosecond result"); | ||
}); |
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