-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Temporal: Copy options object in Plain{Date,MonthDay,YearMonth}.{from…
…,p.with}
- Loading branch information
Showing
16 changed files
with
225 additions
and
64 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
test/built-ins/Temporal/PlainDate/from/observable-get-overflow-argument-primitive.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,34 @@ | ||
// 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: overflow property is extracted with string argument. | ||
includes: [compareArray.js, temporalHelpers.js] | ||
features: [Temporal] | ||
---*/ | ||
|
||
const expected = [ | ||
"ownKeys options", | ||
"getOwnPropertyDescriptor options.overflow", | ||
"get options.overflow", | ||
"get options.overflow.toString", | ||
"call options.overflow.toString", | ||
]; | ||
|
||
let actual = []; | ||
const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options"); | ||
|
||
const result = Temporal.PlainDate.from("2021-05-17", options); | ||
assert.compareArray(actual, expected, "Successful call"); | ||
TemporalHelpers.assertPlainDate(result, 2021, 5, "M05", 17); | ||
|
||
actual.splice(0); // empty it for the next check | ||
const failureExpected = [ | ||
"ownKeys options", | ||
"getOwnPropertyDescriptor options.overflow", | ||
"get options.overflow", | ||
]; | ||
|
||
assert.throws(TypeError, () => Temporal.PlainDate.from(7, options)); | ||
assert.compareArray(actual, failureExpected, "Failing call"); |
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
33 changes: 0 additions & 33 deletions
33
test/built-ins/Temporal/PlainDate/from/observable-get-overflow-argument-string.js
This file was deleted.
Oops, something went wrong.
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
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
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
36 changes: 36 additions & 0 deletions
36
test/built-ins/Temporal/PlainMonthDay/from/observable-get-overflow-argument-primitive.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,36 @@ | ||
// Copyright (C) 2023 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.plainmonthday.from | ||
description: overflow property is extracted with string argument. | ||
info: | | ||
1. Perform ? ToTemporalOverflow(_options_). | ||
includes: [compareArray.js, temporalHelpers.js] | ||
features: [Temporal] | ||
---*/ | ||
|
||
const expected = [ | ||
"ownKeys options", | ||
"getOwnPropertyDescriptor options.overflow", | ||
"get options.overflow", | ||
"get options.overflow.toString", | ||
"call options.overflow.toString", | ||
]; | ||
|
||
let actual = []; | ||
const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options"); | ||
|
||
const result = Temporal.PlainMonthDay.from("05-17", options); | ||
assert.compareArray(actual, expected, "Successful call"); | ||
TemporalHelpers.assertPlainMonthDay(result, "M05", 17); | ||
|
||
actual.splice(0); // empty it for the next check | ||
const failureExpected = [ | ||
"ownKeys options", | ||
"getOwnPropertyDescriptor options.overflow", | ||
"get options.overflow", | ||
]; | ||
|
||
assert.throws(TypeError, () => Temporal.PlainMonthDay.from(7, options)); | ||
assert.compareArray(actual, failureExpected, "Failing call"); |
21 changes: 21 additions & 0 deletions
21
.../built-ins/Temporal/PlainMonthDay/from/observable-get-overflow-argument-string-invalid.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) 2023 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.plainmonthday.from | ||
description: overflow property is extracted with ISO-invalid string argument. | ||
includes: [compareArray.js, temporalHelpers.js] | ||
features: [Temporal] | ||
---*/ | ||
|
||
const expected = [ | ||
"ownKeys options", | ||
"getOwnPropertyDescriptor options.overflow", | ||
"get options.overflow", | ||
]; | ||
|
||
let actual = []; | ||
const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options"); | ||
|
||
assert.throws(RangeError, () => Temporal.PlainMonthDay.from("13-34", options)); | ||
assert.compareArray(actual, expected); |
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
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
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
34 changes: 34 additions & 0 deletions
34
test/built-ins/Temporal/PlainYearMonth/from/observable-get-overflow-argument-primitive.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,34 @@ | ||
// Copyright (C) 2023 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.plainyearmonth.from | ||
description: overflow property is extracted with string argument. | ||
includes: [compareArray.js, temporalHelpers.js] | ||
features: [Temporal] | ||
---*/ | ||
|
||
const expected = [ | ||
"ownKeys options", | ||
"getOwnPropertyDescriptor options.overflow", | ||
"get options.overflow", | ||
"get options.overflow.toString", | ||
"call options.overflow.toString", | ||
]; | ||
|
||
let actual = []; | ||
const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options"); | ||
|
||
const result = Temporal.PlainYearMonth.from("2021-05", options); | ||
assert.compareArray(actual, expected, "Successful call"); | ||
TemporalHelpers.assertPlainYearMonth(result, 2021, 5, "M05"); | ||
|
||
actual.splice(0); // empty it for the next check | ||
const failureExpected = [ | ||
"ownKeys options", | ||
"getOwnPropertyDescriptor options.overflow", | ||
"get options.overflow", | ||
]; | ||
|
||
assert.throws(TypeError, () => Temporal.PlainYearMonth.from(7, options)); | ||
assert.compareArray(actual, failureExpected, "Failing call"); |
21 changes: 21 additions & 0 deletions
21
...built-ins/Temporal/PlainYearMonth/from/observable-get-overflow-argument-string-invalid.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) 2023 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.plainyearmonth.from | ||
description: overflow property is extracted with ISO-invalid string argument. | ||
includes: [compareArray.js, temporalHelpers.js] | ||
features: [Temporal] | ||
---*/ | ||
|
||
const expected = [ | ||
"ownKeys options", | ||
"getOwnPropertyDescriptor options.overflow", | ||
"get options.overflow", | ||
]; | ||
|
||
let actual = []; | ||
const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options"); | ||
|
||
assert.throws(RangeError, () => Temporal.PlainYearMonth.from("2020-13", options)); | ||
assert.compareArray(actual, expected); |
Oops, something went wrong.