From 6fa1bb89a36595238f7698e307914c66c69a4884 Mon Sep 17 00:00:00 2001 From: Aditi Date: Wed, 27 Jul 2022 21:06:38 +0530 Subject: [PATCH] Added tests for an empty or a function options object --- .../prototype/dateAdd/options-object.js | 23 +++++++++++++++++++ .../dateFromFields/options-object.js | 23 +++++++++++++++++++ .../prototype/dateUntil/options-object.js | 23 +++++++++++++++++++ .../monthDayFromFields/options-object.js | 23 +++++++++++++++++++ .../yearMonthFromFields/options-object.js | 23 +++++++++++++++++++ .../Duration/compare/options-object.js | 18 +++++++++++++++ .../Duration/prototype/add/options-object.js | 23 +++++++++++++++++++ .../prototype/subtract/options-object.js | 23 +++++++++++++++++++ .../prototype/toString/options-object.js | 22 ++++++++++++++++++ .../Instant/prototype/since/options-object.js | 23 +++++++++++++++++++ .../prototype/toString/options-object.js | 22 ++++++++++++++++++ .../Instant/prototype/until/options-object.js | 23 +++++++++++++++++++ .../Temporal/PlainDate/from/options-object.js | 19 +++++++++++++++ .../PlainDate/prototype/add/options-object.js | 23 +++++++++++++++++++ .../prototype/since/options-object.js | 23 +++++++++++++++++++ .../prototype/subtract/options-object.js | 23 +++++++++++++++++++ .../prototype/toString/options-object.js | 22 ++++++++++++++++++ .../prototype/until/options-object.js | 23 +++++++++++++++++++ .../prototype/with/options-object.js | 23 +++++++++++++++++++ .../PlainDateTime/from/options-object.js | 19 +++++++++++++++ .../prototype/toString/options-object.js | 22 ++++++++++++++++++ .../toZonedDateTime/options-object.js | 14 +++++------ .../PlainMonthDay/from/options-object.js | 19 +++++++++++++++ .../prototype/toString/options-object.js | 22 ++++++++++++++++++ .../prototype/with/options-object.js | 23 +++++++++++++++++++ .../Temporal/PlainTime/from/options-object.js | 19 +++++++++++++++ .../prototype/since/options-object.js | 23 +++++++++++++++++++ .../prototype/toString/options-object.js | 22 ++++++++++++++++++ .../prototype/until/options-object.js | 23 +++++++++++++++++++ .../prototype/with/options-object.js | 23 +++++++++++++++++++ .../PlainYearMonth/from/options-object.js | 19 +++++++++++++++ .../prototype/add/options-object.js | 23 +++++++++++++++++++ .../prototype/since/options-object.js | 23 +++++++++++++++++++ .../prototype/subtract/options-object.js | 23 +++++++++++++++++++ .../prototype/toString/options-object.js | 22 ++++++++++++++++++ .../prototype/until/options-object.js | 23 +++++++++++++++++++ .../prototype/with/options-object.js | 23 +++++++++++++++++++ .../prototype/getInstantFor/options-object.js | 22 ++++++++++++++++++ .../ZonedDateTime/from/options-object.js | 18 +++++++++++++++ .../prototype/add/options-object.js | 22 ++++++++++++++++++ .../prototype/since/options-object.js | 23 +++++++++++++++++++ .../prototype/subtract/options-object.js | 22 ++++++++++++++++++ .../prototype/toString/options-object.js | 22 ++++++++++++++++++ .../prototype/until/options-object.js | 23 +++++++++++++++++++ .../prototype/with/options-object.js | 22 ++++++++++++++++++ 45 files changed, 977 insertions(+), 7 deletions(-) create mode 100644 test/built-ins/Temporal/Calendar/prototype/dateAdd/options-object.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dateFromFields/options-object.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dateUntil/options-object.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/options-object.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/options-object.js create mode 100644 test/built-ins/Temporal/Duration/compare/options-object.js create mode 100644 test/built-ins/Temporal/Duration/prototype/add/options-object.js create mode 100644 test/built-ins/Temporal/Duration/prototype/subtract/options-object.js create mode 100644 test/built-ins/Temporal/Duration/prototype/toString/options-object.js create mode 100644 test/built-ins/Temporal/Instant/prototype/since/options-object.js create mode 100644 test/built-ins/Temporal/Instant/prototype/toString/options-object.js create mode 100644 test/built-ins/Temporal/Instant/prototype/until/options-object.js create mode 100644 test/built-ins/Temporal/PlainDate/from/options-object.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/add/options-object.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/since/options-object.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/subtract/options-object.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/toString/options-object.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/until/options-object.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/with/options-object.js create mode 100644 test/built-ins/Temporal/PlainDateTime/from/options-object.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toString/options-object.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/from/options-object.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/prototype/toString/options-object.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/prototype/with/options-object.js create mode 100644 test/built-ins/Temporal/PlainTime/from/options-object.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/since/options-object.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/toString/options-object.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/until/options-object.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/with/options-object.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/from/options-object.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/add/options-object.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/since/options-object.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/subtract/options-object.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/toString/options-object.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/until/options-object.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/with/options-object.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getInstantFor/options-object.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/from/options-object.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/add/options-object.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/since/options-object.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/subtract/options-object.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toString/options-object.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/until/options-object.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/with/options-object.js diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/options-object.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/options-object.js new file mode 100644 index 0000000000..3d18ef4cbc --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateAdd/options-object.js @@ -0,0 +1,23 @@ +// 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: Empty or a function object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.Calendar("iso8601"); + +const result1 = instance.dateAdd(new Temporal.PlainDate(1976, 11, 18), new Temporal.Duration(1), {}); +TemporalHelpers.assertPlainDate( + result1, 1977, 11, "M11", 18, + "options may be an empty plain object" +); + +const result2 = instance.dateAdd(new Temporal.PlainDate(1976, 11, 18), new Temporal.Duration(1), () => {}); +TemporalHelpers.assertPlainDate( + result2, 1977, 11, "M11", 18, + "options may be a function object" +); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/options-object.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/options-object.js new file mode 100644 index 0000000000..21fdb7242c --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/options-object.js @@ -0,0 +1,23 @@ +// 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.datefromfields +description: Empty or a function object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.Calendar("iso8601"); + +const result1 = instance.dateFromFields({ year: 1976, month: 11, day: 18 }, {}); +TemporalHelpers.assertPlainDate( + result1, 1976, 11, "M11", 18, + "options may be an empty plain object" +); + +const result2 = instance.dateFromFields({ year: 1976, month: 11, day: 18 }, () => {}); +TemporalHelpers.assertPlainDate( + result2, 1976, 11, "M11", 18, + "options may be a function object" +); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/options-object.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/options-object.js new file mode 100644 index 0000000000..d130e96b7c --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateUntil/options-object.js @@ -0,0 +1,23 @@ +// 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: Empty or a function object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.Calendar("iso8601"); + +const result1 = instance.dateUntil(new Temporal.PlainDate(1976, 11, 18), new Temporal.PlainDate(1984, 5, 31), {}); +TemporalHelpers.assertDuration( + result1, 0, 0, 0, 2751, 0, 0, 0, 0, 0, 0, + "options may be an empty plain object" +); + +const result2 = instance.dateUntil(new Temporal.PlainDate(1976, 11, 18), new Temporal.PlainDate(1984, 5, 31), () => {}); +TemporalHelpers.assertDuration( + result2, 0, 0, 0, 2751, 0, 0, 0, 0, 0, 0, + "options may be a function object" +); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/options-object.js b/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/options-object.js new file mode 100644 index 0000000000..c8fc1e1dd3 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/options-object.js @@ -0,0 +1,23 @@ +// 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.monthdayfromfields +description: Empty or a function object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.Calendar("iso8601"); + +const result1 = instance.monthDayFromFields({ monthCode: "M12", day: 15 }, {}); +TemporalHelpers.assertPlainMonthDay( + result1, "M12", 15, + "options may be an empty plain object" +); + +const result2 = instance.monthDayFromFields({ monthCode: "M12", day: 15 }, () => {}); +TemporalHelpers.assertPlainMonthDay( + result2, "M12", 15, + "options may be a function object" +); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/options-object.js b/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/options-object.js new file mode 100644 index 0000000000..3895a59b4c --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/options-object.js @@ -0,0 +1,23 @@ +// 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.yearmonthfromfields +description: Empty or a function object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.Calendar("iso8601"); + +const result1 = instance.yearMonthFromFields({ year: 2000, monthCode: "M05" }, {}); +TemporalHelpers.assertPlainYearMonth( + result1, 2000, 5, "M05", + "options may be an empty plain object" +); + +const result2 = instance.yearMonthFromFields({ year: 2000, monthCode: "M05" }, () => {}); +TemporalHelpers.assertPlainYearMonth( + result2, 2000, 5, "M05", + "options may be a function object" +); diff --git a/test/built-ins/Temporal/Duration/compare/options-object.js b/test/built-ins/Temporal/Duration/compare/options-object.js new file mode 100644 index 0000000000..a7e3510be3 --- /dev/null +++ b/test/built-ins/Temporal/Duration/compare/options-object.js @@ -0,0 +1,18 @@ +// 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.duration.prototype.compare +description: Empty object may be used as options +features: [Temporal] +---*/ + +assert.sameValue( + Temporal.Duration.compare({ hours: 1 }, { minutes: 60 }, {}), 0, + "options may be an empty plain object" +); + +assert.sameValue( + Temporal.Duration.compare({ hours: 1 }, { minutes:60 }, () => {}), 0, + "options may be an empty function object" +); diff --git a/test/built-ins/Temporal/Duration/prototype/add/options-object.js b/test/built-ins/Temporal/Duration/prototype/add/options-object.js new file mode 100644 index 0000000000..420d16ea49 --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/add/options-object.js @@ -0,0 +1,23 @@ +// 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.duration.prototype.add +description: Empty or a function object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.Duration(0, 0, 0, 0, 1); + +const result1 = instance.add({ hours: 1 }, {}); +TemporalHelpers.assertDuration( + result1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, + "options may be an empty plain object" +); + +const result2 = instance.add({ hours: 1 }, () => {}); +TemporalHelpers.assertDuration( + result2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, + "options may be a function object" +); diff --git a/test/built-ins/Temporal/Duration/prototype/subtract/options-object.js b/test/built-ins/Temporal/Duration/prototype/subtract/options-object.js new file mode 100644 index 0000000000..ff7c0e9abb --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/subtract/options-object.js @@ -0,0 +1,23 @@ +// 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.duration.prototype.subtract +description: Empty or a function object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.Duration(0, 0, 0, 0, 1); + +const result1 = instance.subtract({ hours: 1 }, {}); +TemporalHelpers.assertDuration( + result1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + "options may be an empty plain object" +); + +const result2 = instance.subtract({ hours: 1 }, () => {}); +TemporalHelpers.assertDuration( + result2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + "options may be a function object" +); diff --git a/test/built-ins/Temporal/Duration/prototype/toString/options-object.js b/test/built-ins/Temporal/Duration/prototype/toString/options-object.js new file mode 100644 index 0000000000..46f2564e32 --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/toString/options-object.js @@ -0,0 +1,22 @@ +// 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.duration.prototype.tostring +description: Empty or a function object may be used as options +features: [Temporal] +---*/ + +const instance = new Temporal.Duration(0, 0, 0, 0, 1); + +const result1 = instance.toString({}); +assert.sameValue( + result1, "PT1H", + "options may be an empty plain object" +); + +const result2 = instance.toString(() => {}); +assert.sameValue( + result2, "PT1H", + "options may be a function object" +); diff --git a/test/built-ins/Temporal/Instant/prototype/since/options-object.js b/test/built-ins/Temporal/Instant/prototype/since/options-object.js new file mode 100644 index 0000000000..885cd3ae93 --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/since/options-object.js @@ -0,0 +1,23 @@ +// 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.instant.prototype.since +description: Empty or a function object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.Instant(0n); + +const result1 = instance.since(new Temporal.Instant(3600_000_000_000n), {}); +TemporalHelpers.assertDuration( + result1, 0, 0, 0, 0, 0, 0, -3600, 0, 0, 0, + "options may be an empty plain object" +); + +const result2 = instance.since(new Temporal.Instant(3600_000_000_000n), () => {}); +TemporalHelpers.assertDuration( + result2, 0, 0, 0, 0, 0, 0, -3600, 0, 0, 0, + "options may be a function object" +); diff --git a/test/built-ins/Temporal/Instant/prototype/toString/options-object.js b/test/built-ins/Temporal/Instant/prototype/toString/options-object.js new file mode 100644 index 0000000000..db0ac4f1a7 --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/toString/options-object.js @@ -0,0 +1,22 @@ +// 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.instant.prototype.tostring +description: Empty or a function object may be used as options +features: [Temporal] +---*/ + +const instance = new Temporal.Instant(0n); + +const result1 = instance.toString({}); +assert.sameValue( + result1, "1970-01-01T00:00:00Z", + "options may be an empty plain object" +); + +const result2 = instance.toString(() => {}); +assert.sameValue( + result2, "1970-01-01T00:00:00Z", + "options may be a function object" +); diff --git a/test/built-ins/Temporal/Instant/prototype/until/options-object.js b/test/built-ins/Temporal/Instant/prototype/until/options-object.js new file mode 100644 index 0000000000..c6b1973486 --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/until/options-object.js @@ -0,0 +1,23 @@ +// 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.instant.prototype.until +description: Empty or a function object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.Instant(0n); + +const result1 = instance.until(new Temporal.Instant(3600_000_000_000n), {}); +TemporalHelpers.assertDuration( + result1, 0, 0, 0, 0, 0, 0, 3600, 0, 0, 0, + "options may be an empty plain object" +); + +const result2 = instance.until(new Temporal.Instant(3600_000_000_000n), () => {}); +TemporalHelpers.assertDuration( + result2, 0, 0, 0, 0, 0, 0, 3600, 0, 0, 0, + "options may be a function object" +); diff --git a/test/built-ins/Temporal/PlainDate/from/options-object.js b/test/built-ins/Temporal/PlainDate/from/options-object.js new file mode 100644 index 0000000000..fd4f2552f8 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/from/options-object.js @@ -0,0 +1,19 @@ +// 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.plaindate.prototype.from +description: Empty object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1976, month: 11, day: 18 }, {}), 1976, 11, "M11", 18, + "options may be an empty plain object" +); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({ year: 1976, month: 11, day: 18 }, () => {}), 1976, 11, "M11", 18, + "options may be an empty function object" +); diff --git a/test/built-ins/Temporal/PlainDate/prototype/add/options-object.js b/test/built-ins/Temporal/PlainDate/prototype/add/options-object.js new file mode 100644 index 0000000000..b5ed375c20 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/add/options-object.js @@ -0,0 +1,23 @@ +// 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.plaindate.prototype.add +description: Empty or a function object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainDate(2000, 5, 2); + +const result1 = instance.add({ months: 1 }, {}); +TemporalHelpers.assertPlainDate( + result1, 2000, 6, "M06", 2, + "options may be an empty plain object" +); + +const result2 = instance.add({ months: 1 }, () => {}); +TemporalHelpers.assertPlainDate( + result2, 2000, 6, "M06", 2, + "options may be a function object" +); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/options-object.js b/test/built-ins/Temporal/PlainDate/prototype/since/options-object.js new file mode 100644 index 0000000000..86c53af414 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/since/options-object.js @@ -0,0 +1,23 @@ +// 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.plaindate.prototype.since +description: Empty or a function object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainDate(2000, 5, 2); + +const result1 = instance.since(new Temporal.PlainDate(1976, 11, 18), {}); +TemporalHelpers.assertDuration( + result1, 0, 0, 0, 8566, 0, 0, 0, 0, 0, 0, + "options may be an empty plain object" +); + +const result2 = instance.since(new Temporal.PlainDate(1976, 11, 18), () => {}); +TemporalHelpers.assertDuration( + result2, 0, 0, 0, 8566, 0, 0, 0, 0, 0, 0, + "options may be a function object" +); diff --git a/test/built-ins/Temporal/PlainDate/prototype/subtract/options-object.js b/test/built-ins/Temporal/PlainDate/prototype/subtract/options-object.js new file mode 100644 index 0000000000..1fcb761f27 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/subtract/options-object.js @@ -0,0 +1,23 @@ +// 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.plaindate.prototype.subtract +description: Empty or a function object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainDate(2000, 5, 2); + +const result1 = instance.subtract({ months: 1 }, {}); +TemporalHelpers.assertPlainDate( + result1, 2000, 4, "M04", 2, + "options may be an empty plain object" +); + +const result2 = instance.subtract({ months: 1 }, () => {}); +TemporalHelpers.assertPlainDate( + result2, 2000, 4, "M04", 2, + "options may be a function object" +); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/options-object.js b/test/built-ins/Temporal/PlainDate/prototype/toString/options-object.js new file mode 100644 index 0000000000..f108f1b835 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/options-object.js @@ -0,0 +1,22 @@ +// 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.plaindate.prototype.tostring +description: Empty or a function object may be used as options +features: [Temporal] +---*/ + +const instance = new Temporal.PlainDate(2000, 5, 2); + +const result1 = instance.toString({}); +assert.sameValue( + result1, "2000-05-02", + "options may be an empty plain object" +); + +const result2 = instance.toString(() => {}); +assert.sameValue( + result2, "2000-05-02", + "options may be a function object" +); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/options-object.js b/test/built-ins/Temporal/PlainDate/prototype/until/options-object.js new file mode 100644 index 0000000000..ac410f871e --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/until/options-object.js @@ -0,0 +1,23 @@ +// 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.plaindate.prototype.until +description: Empty or a function object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainDate(2000, 5, 2); + +const result1 = instance.until(new Temporal.PlainDate(1976, 11, 18), {}); +TemporalHelpers.assertDuration( + result1, 0, 0, 0, -8566, 0, 0, 0, 0, 0, 0, + "options may be an empty plain object" +); + +const result2 = instance.until(new Temporal.PlainDate(1976, 11, 18), () => {}); +TemporalHelpers.assertDuration( + result2, 0, 0, 0, -8566, 0, 0, 0, 0, 0, 0, + "options may be a function object" +); diff --git a/test/built-ins/Temporal/PlainDate/prototype/with/options-object.js b/test/built-ins/Temporal/PlainDate/prototype/with/options-object.js new file mode 100644 index 0000000000..6013f1da75 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/with/options-object.js @@ -0,0 +1,23 @@ +// 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.plaindate.prototype.with +description: Empty or a function object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainDate(2000, 5, 2); + +const result1 = instance.with({ day: 5 }, {}); +TemporalHelpers.assertPlainDate( + result1, 2000, 5, "M05", 5, + "options may be an empty plain object" +); + +const result2 = instance.with({ day: 5 }, () => {}); +TemporalHelpers.assertPlainDate( + result2, 2000, 5, "M05", 5, + "options may be a function object" +); diff --git a/test/built-ins/Temporal/PlainDateTime/from/options-object.js b/test/built-ins/Temporal/PlainDateTime/from/options-object.js new file mode 100644 index 0000000000..14159e8ca2 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/from/options-object.js @@ -0,0 +1,19 @@ +// 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.plaindatetime.prototype.from +description: Empty object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1976, month: 11, day: 18 }, {}), 1976, 11, "M11", 18, 0, 0, 0, 0, 0, 0, + "options may be an empty plain object" +); + +TemporalHelpers.assertPlainDateTime( + Temporal.PlainDateTime.from({ year: 1976, month: 11, day: 18 }, () => {}), 1976, 11, "M11", 18, 0, 0, 0, 0, 0, 0, + "options may be an empty function object" +); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/options-object.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/options-object.js new file mode 100644 index 0000000000..a956341d2d --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/options-object.js @@ -0,0 +1,22 @@ +// 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.plaindatetime.prototype.tostring +description: Empty or a function object may be used as options +features: [Temporal] +---*/ + +const instance = new Temporal.PlainDateTime(2000, 5, 2); + +const result1 = instance.toString({}); +assert.sameValue( + result1, "2000-05-02T00:00:00", + "options may be an empty plain object" +); + +const result2 = instance.toString(() => {}); +assert.sameValue( + result2, "2000-05-02T00:00:00", + "options may be a function object" +); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/options-object.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/options-object.js index e7cd07013c..17bd709206 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/options-object.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/options-object.js @@ -2,21 +2,21 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-temporal.plaindate.prototype.tozoneddatetime -description: Empty object may be used as options +esid: sec-temporal.plaindatetime.prototype.tozoneddatetime +description: Empty or a function object may be used as options features: [Temporal] ---*/ -const dt = new Temporal.PlainDateTime(2019, 10, 29, 10, 46, 38, 271, 986, 102); +const instance = new Temporal.PlainDateTime(2000, 5, 2); +const result1 = instance.toZonedDateTime("UTC", {}); assert.sameValue( - dt.toZonedDateTime("UTC", {}).epochNanoseconds, - 1572345998271986102n, + result1.epochNanoseconds, 957225600000000000n, "options may be an empty plain object" ); +const result2 = instance.toZonedDateTime("UTC", () => {}); assert.sameValue( - dt.toZonedDateTime("UTC", () => {}).epochNanoseconds, - 1572345998271986102n, + result2.epochNanoseconds, 957225600000000000n, "options may be a function object" ); diff --git a/test/built-ins/Temporal/PlainMonthDay/from/options-object.js b/test/built-ins/Temporal/PlainMonthDay/from/options-object.js new file mode 100644 index 0000000000..eb2c978bdf --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/from/options-object.js @@ -0,0 +1,19 @@ +// 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.plainmonthday.prototype.from +description: Empty object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +TemporalHelpers.assertPlainMonthDay( + Temporal.PlainMonthDay.from({ monthCode: "M12", day: 15 }, {}), "M12", 15, + "options may be an empty plain object" +); + +TemporalHelpers.assertPlainMonthDay( + Temporal.PlainMonthDay.from({ monthCode: "M12", day: 15 }, () => {}), "M12", 15, + "options may be an empty function object" +); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/options-object.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/options-object.js new file mode 100644 index 0000000000..e41b027025 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/options-object.js @@ -0,0 +1,22 @@ +// 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.plainmonthday.prototype.tostring +description: Empty or a function object may be used as options +features: [Temporal] +---*/ + +const instance = new Temporal.PlainMonthDay(5, 2); + +const result1 = instance.toString({}); +assert.sameValue( + result1, "05-02", + "options may be an empty plain object" +); + +const result2 = instance.toString(() => {}); +assert.sameValue( + result2, "05-02", + "options may be a function object" +); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/with/options-object.js b/test/built-ins/Temporal/PlainMonthDay/prototype/with/options-object.js new file mode 100644 index 0000000000..8242de1da9 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/with/options-object.js @@ -0,0 +1,23 @@ +// 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.plainmonthday.prototype.with +description: Empty or a function object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainMonthDay(5, 2); + +const result1 = instance.with({ day: 5 }, {}); +TemporalHelpers.assertPlainMonthDay( + result1, "M05", 5, + "options may be an empty plain object" +); + +const result2 = instance.with({ day: 5 }, () => {}); +TemporalHelpers.assertPlainMonthDay( + result2, "M05", 5, + "options may be a function object" +); diff --git a/test/built-ins/Temporal/PlainTime/from/options-object.js b/test/built-ins/Temporal/PlainTime/from/options-object.js new file mode 100644 index 0000000000..4a8d0cf2d7 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/from/options-object.js @@ -0,0 +1,19 @@ +// 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.plaintime.prototype.from +description: Empty object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +TemporalHelpers.assertPlainTime( + Temporal.PlainTime.from({ hour: 12, minute: 34 }, {}), 12, 34, 0, 0, 0, 0, + "options may be an empty plain object" +); + +TemporalHelpers.assertPlainTime( + Temporal.PlainTime.from({ hour: 12, minute: 34 }, () => {}), 12, 34, 0, 0, 0, 0, + "options may be an empty function object" +); diff --git a/test/built-ins/Temporal/PlainTime/prototype/since/options-object.js b/test/built-ins/Temporal/PlainTime/prototype/since/options-object.js new file mode 100644 index 0000000000..65afecb769 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/since/options-object.js @@ -0,0 +1,23 @@ +// 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.plaintime.prototype.since +description: Empty or a function object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainTime(); + +const result1 = instance.since(new Temporal.PlainTime(12, 34, 56), {}); +TemporalHelpers.assertDuration( + result1, 0, 0, 0, 0, -12, -34, -56, 0, 0, 0, + "options may be an empty plain object" +); + +const result2 = instance.since(new Temporal.PlainTime(12, 34, 56), () => {}); +TemporalHelpers.assertDuration( + result2, 0, 0, 0, 0, -12, -34, -56, 0, 0, 0, + "options may be a function object" +); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toString/options-object.js b/test/built-ins/Temporal/PlainTime/prototype/toString/options-object.js new file mode 100644 index 0000000000..a4fa9af7af --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/toString/options-object.js @@ -0,0 +1,22 @@ +// 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.plaintime.prototype.tostring +description: Empty or a function object may be used as options +features: [Temporal] +---*/ + +const instance = new Temporal.PlainTime(); + +const result1 = instance.toString({}); +assert.sameValue( + result1, "00:00:00", + "options may be an empty plain object" +); + +const result2 = instance.toString(() => {}); +assert.sameValue( + result2, "00:00:00", + "options may be a function object" +); diff --git a/test/built-ins/Temporal/PlainTime/prototype/until/options-object.js b/test/built-ins/Temporal/PlainTime/prototype/until/options-object.js new file mode 100644 index 0000000000..cec1c2f8e9 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/until/options-object.js @@ -0,0 +1,23 @@ +// 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.plaintime.prototype.until +description: Empty or a function object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainTime(); + +const result1 = instance.until(new Temporal.PlainTime(12, 34, 56), {}); +TemporalHelpers.assertDuration( + result1, 0, 0, 0, 0, 12, 34, 56, 0, 0, 0, + "options may be an empty plain object" +); + +const result2 = instance.until(new Temporal.PlainTime(12, 34, 56), () => {}); +TemporalHelpers.assertDuration( + result2, 0, 0, 0, 0, 12, 34, 56, 0, 0, 0, + "options may be a function object" +); diff --git a/test/built-ins/Temporal/PlainTime/prototype/with/options-object.js b/test/built-ins/Temporal/PlainTime/prototype/with/options-object.js new file mode 100644 index 0000000000..6703bd1bbe --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/with/options-object.js @@ -0,0 +1,23 @@ +// 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.plaintime.prototype.with +description: Empty or a function object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainTime(); + +const result1 = instance.with({ minute: 45 }, {}); +TemporalHelpers.assertPlainTime( + result1, 0, 45, 0, 0, 0, 0, + "options may be an empty plain object" +); + +const result2 = instance.with({ minute: 45 }, () => {}); +TemporalHelpers.assertPlainTime( + result2, 0, 45, 0, 0, 0, 0, + "options may be a function object" +); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/options-object.js b/test/built-ins/Temporal/PlainYearMonth/from/options-object.js new file mode 100644 index 0000000000..0d33571488 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/from/options-object.js @@ -0,0 +1,19 @@ +// 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.plainyearmonth.prototype.from +description: Empty object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +TemporalHelpers.assertPlainYearMonth( + Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M01" }, {}), 2021, 1, "M01", + "options may be an empty plain object" +); + +TemporalHelpers.assertPlainYearMonth( + Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M01" }, () => {}), 2021, 1, "M01", + "options may be an empty function object" +); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/options-object.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/options-object.js new file mode 100644 index 0000000000..36ae0e6d71 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/add/options-object.js @@ -0,0 +1,23 @@ +// 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.plainyearmonth.prototype.add +description: Empty or a function object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainYearMonth(2019, 10); + +const result1 = instance.add({ months: 1 }, {}); +TemporalHelpers.assertPlainYearMonth( + result1, 2019, 11, "M11", + "options may be an empty plain object" +); + +const result2 = instance.add({ months: 1 }, () => {}); +TemporalHelpers.assertPlainYearMonth( + result2, 2019, 11, "M11", + "options may be a function object" +); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/options-object.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/options-object.js new file mode 100644 index 0000000000..0734123480 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/options-object.js @@ -0,0 +1,23 @@ +// 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.plainyearmonth.prototype.since +description: Empty or a function object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainYearMonth(2019, 10); + +const result1 = instance.since(new Temporal.PlainYearMonth(1976, 11), {}); +TemporalHelpers.assertDuration( + result1, 42, 11, 0, 0, 0, 0, 0, 0, 0, 0, + "options may be an empty plain object" +); + +const result2 = instance.since(new Temporal.PlainYearMonth(1976, 11), () => {}); +TemporalHelpers.assertDuration( + result2, 42, 11, 0, 0, 0, 0, 0, 0, 0, 0, + "options may be a function object" +); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/options-object.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/options-object.js new file mode 100644 index 0000000000..4d5114c9d2 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/options-object.js @@ -0,0 +1,23 @@ +// 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.plainyearmonth.prototype.subtract +description: Empty or a function object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainYearMonth(2019, 10); + +const result1 = instance.subtract({ months: 1 }, {}); +TemporalHelpers.assertPlainYearMonth( + result1, 2019, 9, "M09", + "options may be an empty plain object" +); + +const result2 = instance.subtract({ months: 1 }, () => {}); +TemporalHelpers.assertPlainYearMonth( + result2, 2019, 9, "M09", + "options may be a function object" +); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/options-object.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/options-object.js new file mode 100644 index 0000000000..2e3b77d2ee --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/options-object.js @@ -0,0 +1,22 @@ +// 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.plainyearmonth.prototype.tostring +description: Empty or a function object may be used as options +features: [Temporal] +---*/ + +const instance = new Temporal.PlainYearMonth(2019, 10); + +const result1 = instance.toString({}); +assert.sameValue( + result1, "2019-10", + "options may be an empty plain object" +); + +const result2 = instance.toString(() => {}); +assert.sameValue( + result2, "2019-10", + "options may be a function object" +); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/options-object.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/options-object.js new file mode 100644 index 0000000000..3b4e832963 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/options-object.js @@ -0,0 +1,23 @@ +// 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.plainyearmonth.prototype.until +description: Empty or a function object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainYearMonth(2019, 10); + +const result1 = instance.until(new Temporal.PlainYearMonth(1976, 11), {}); +TemporalHelpers.assertDuration( + result1, -42, -11, 0, 0, 0, 0, 0, 0, 0, 0, + "options may be an empty plain object" +); + +const result2 = instance.until(new Temporal.PlainYearMonth(1976, 11), () => {}); +TemporalHelpers.assertDuration( + result2, -42, -11, 0, 0, 0, 0, 0, 0, 0, 0, + "options may be a function object" +); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/with/options-object.js b/test/built-ins/Temporal/PlainYearMonth/prototype/with/options-object.js new file mode 100644 index 0000000000..f216ce517f --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/with/options-object.js @@ -0,0 +1,23 @@ +// 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.plainyearmonth.prototype.with +description: Empty or a function object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainYearMonth(2019, 10); + +const result1 = instance.with({ year: 2020 }, {}); +TemporalHelpers.assertPlainYearMonth( + result1, 2020, 10, "M10", + "options may be an empty plain object" +); + +const result2 = instance.with({ year: 2020 }, () => {}); +TemporalHelpers.assertPlainYearMonth( + result2, 2020, 10, "M10", + "options may be a function object" +); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/options-object.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/options-object.js new file mode 100644 index 0000000000..f6beb88df0 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/options-object.js @@ -0,0 +1,22 @@ +// 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.timezone.prototype.getinstantfor +description: Empty or a function object may be used as options +features: [Temporal] +---*/ + +const instance = new Temporal.TimeZone("UTC"); + +const result1 = instance.getInstantFor(new Temporal.PlainDateTime(2019, 10, 29, 10, 46, 38), {}); +assert.sameValue( + result1.epochNanoseconds, 1572345998000000000n, + "options may be an empty plain object" +); + +const result2 = instance.getInstantFor(new Temporal.PlainDateTime(2019, 10, 29, 10, 46, 38), () => {}); +assert.sameValue( + result2.epochNanoseconds, 1572345998000000000n, + "options may be a function object" +); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/options-object.js b/test/built-ins/Temporal/ZonedDateTime/from/options-object.js new file mode 100644 index 0000000000..5862288ff4 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/from/options-object.js @@ -0,0 +1,18 @@ +// 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.zoneddatetime.prototype.from +description: Empty object may be used as options +features: [Temporal] +---*/ + +assert.sameValue( + Temporal.ZonedDateTime.from({ year: 1976, month: 11, day: 18, timeZone: "UTC" }, {}).epochNanoseconds, 217123200000000000n, "UTC", + "options may be an empty plain object" +); + +assert.sameValue( + Temporal.ZonedDateTime.from({ year: 1976, month: 11, day: 18, timeZone: "UTC" }, () => {}).epochNanoseconds, 217123200000000000n, "UTC", + "options may be an empty function object" +); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/add/options-object.js b/test/built-ins/Temporal/ZonedDateTime/prototype/add/options-object.js new file mode 100644 index 0000000000..c1a6fc27b9 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/add/options-object.js @@ -0,0 +1,22 @@ +// 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.zoneddatetime.prototype.add +description: Empty or a function object may be used as options +features: [Temporal] +---*/ + +const instance = new Temporal.ZonedDateTime(0n, "UTC"); + +const result1 = instance.add({ years: 1 }, {}); +assert.sameValue( + result1.epochNanoseconds, 31536000000000000n, "UTC", + "options may be an empty plain object" +); + +const result2 = instance.add({ years: 1 }, () => {}); +assert.sameValue( + result2.epochNanoseconds, 31536000000000000n, "UTC", + "options may be a function object" +); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/options-object.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/options-object.js new file mode 100644 index 0000000000..fa0599e662 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/options-object.js @@ -0,0 +1,23 @@ +// 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.zoneddatetime.prototype.since +description: Empty or a function object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.ZonedDateTime(0n, "UTC"); + +const result1 = instance.since(new Temporal.ZonedDateTime(3600_000_000_000n, "UTC"), {}); +TemporalHelpers.assertDuration( + result1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, + "options may be an empty plain object" +); + +const result2 = instance.since(new Temporal.ZonedDateTime(3600_000_000_000n, "UTC"), () => {}); +TemporalHelpers.assertDuration( + result2, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, + "options may be a function object" +); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/options-object.js b/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/options-object.js new file mode 100644 index 0000000000..0fbb14b0dd --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/options-object.js @@ -0,0 +1,22 @@ +// 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.zoneddatetime.prototype.subtract +description: Empty or a function object may be used as options +features: [Temporal] +---*/ + +const instance = new Temporal.ZonedDateTime(0n, "UTC"); + +const result1 = instance.subtract({ years: 1 }, {}); +assert.sameValue( + result1.epochNanoseconds, -31536000000000000n, "UTC", + "options may be an empty plain object" +); + +const result2 = instance.subtract({ years: 1 }, () => {}); +assert.sameValue( + result2.epochNanoseconds, -31536000000000000n, "UTC", + "options may be a function object" +); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/options-object.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/options-object.js new file mode 100644 index 0000000000..0c51e99410 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/options-object.js @@ -0,0 +1,22 @@ +// 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.zoneddatetime.prototype.tostring +description: Empty or a function object may be used as options +features: [Temporal] +---*/ + +const instance = new Temporal.ZonedDateTime(0n, "UTC"); + +const result1 = instance.toString({}); +assert.sameValue( + result1, "1970-01-01T00:00:00+00:00[UTC]", + "options may be an empty plain object" +); + +const result2 = instance.toString(() => {}); +assert.sameValue( + result2, "1970-01-01T00:00:00+00:00[UTC]", + "options may be a function object" +); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/options-object.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/options-object.js new file mode 100644 index 0000000000..3c202b6aa5 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/options-object.js @@ -0,0 +1,23 @@ +// 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.zoneddatetime.prototype.until +description: Empty or a function object may be used as options +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.ZonedDateTime(0n, "UTC"); + +const result1 = instance.until(new Temporal.ZonedDateTime(3600_000_000_000n, "UTC"), {}); +TemporalHelpers.assertDuration( + result1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + "options may be an empty plain object" +); + +const result2 = instance.until(new Temporal.ZonedDateTime(3600_000_000_000n, "UTC"), () => {}); +TemporalHelpers.assertDuration( + result2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + "options may be a function object" +); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/options-object.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/options-object.js new file mode 100644 index 0000000000..144ccf727e --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/with/options-object.js @@ -0,0 +1,22 @@ +// 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.zoneddatetime.prototype.with +description: Empty or a function object may be used as options +features: [Temporal] +---*/ + +const instance = new Temporal.ZonedDateTime(0n, "UTC"); + +const result1 = instance.with({ day: 5 }, {}); +assert.sameValue( + result1.epochNanoseconds, 345600000000000n, "UTC", + "options may be an empty plain object" +); + +const result2 = instance.with({ day: 5 }, () => {}); +assert.sameValue( + result2.epochNanoseconds, 345600000000000n, "UTC", + "options may be a function object" +);