From 016e4bf8e84c36d1653c6bd53e74c93580d8b1ff Mon Sep 17 00:00:00 2001 From: Guillaume Emont Date: Mon, 17 Jul 2023 16:55:34 +0200 Subject: [PATCH] Temporal Issue 2532 (#3858) * Add tests for the new PrepareTemporalFields behavior for all direct callers See https://github.com/tc39/proposal-temporal/pull/2570 * Add tests for the new PrepareTemporalFields behavior for indirect callers through ToTemporalDate * Add tests for the new PrepareTemporalFields behavior for indirect callers through ToTemporalDateTime * Add tests for the new PrepareTemporalFields behavior for indirect callers through ToTemporalZonedDateTime * Add tests for the new PrepareTemporalFields behavior for indirect callers through ToTemporalYearMonth * Add tests for the new PrepareTemporalFields behavior for indirect callers through ToTemporalMonthDay * Add tests for the new PrepareTemporalFields behavior for indirect callers through ToRelativeTemporalObject * Add tests for the new PrepareTemporalFields behavior for indirect callers through AddDurationToOrSubtractDurationFromPlainYearMonth --- harness/temporalHelpers.js | 19 +++++++++++++++++++ ...argument-constructor-in-calendar-fields.js | 14 ++++++++++++++ .../argument-duplicate-calendar-fields.js | 16 ++++++++++++++++ .../argument-proto-in-calendar-fields.js | 14 ++++++++++++++ ...argument-constructor-in-calendar-fields.js | 14 ++++++++++++++ .../argument-duplicate-calendar-fields.js | 17 +++++++++++++++++ .../argument-proto-in-calendar-fields.js | 14 ++++++++++++++ ...argument-constructor-in-calendar-fields.js | 14 ++++++++++++++ .../day/argument-duplicate-calendar-fields.js | 16 ++++++++++++++++ .../day/argument-proto-in-calendar-fields.js | 14 ++++++++++++++ ...argument-constructor-in-calendar-fields.js | 14 ++++++++++++++ .../argument-duplicate-calendar-fields.js | 16 ++++++++++++++++ .../argument-proto-in-calendar-fields.js | 14 ++++++++++++++ ...argument-constructor-in-calendar-fields.js | 14 ++++++++++++++ .../argument-duplicate-calendar-fields.js | 16 ++++++++++++++++ .../argument-proto-in-calendar-fields.js | 14 ++++++++++++++ ...argument-constructor-in-calendar-fields.js | 14 ++++++++++++++ .../argument-duplicate-calendar-fields.js | 16 ++++++++++++++++ .../argument-proto-in-calendar-fields.js | 14 ++++++++++++++ ...argument-constructor-in-calendar-fields.js | 14 ++++++++++++++ .../argument-duplicate-calendar-fields.js | 16 ++++++++++++++++ .../argument-proto-in-calendar-fields.js | 14 ++++++++++++++ ...argument-constructor-in-calendar-fields.js | 14 ++++++++++++++ .../argument-duplicate-calendar-fields.js | 16 ++++++++++++++++ .../argument-proto-in-calendar-fields.js | 14 ++++++++++++++ ...argument-constructor-in-calendar-fields.js | 14 ++++++++++++++ .../argument-duplicate-calendar-fields.js | 16 ++++++++++++++++ .../argument-proto-in-calendar-fields.js | 14 ++++++++++++++ ...argument-constructor-in-calendar-fields.js | 14 ++++++++++++++ .../argument-duplicate-calendar-fields.js | 16 ++++++++++++++++ .../argument-proto-in-calendar-fields.js | 14 ++++++++++++++ ...argument-constructor-in-calendar-fields.js | 14 ++++++++++++++ .../argument-duplicate-calendar-fields.js | 16 ++++++++++++++++ .../argument-proto-in-calendar-fields.js | 14 ++++++++++++++ ...argument-constructor-in-calendar-fields.js | 14 ++++++++++++++ .../argument-duplicate-calendar-fields.js | 16 ++++++++++++++++ .../argument-proto-in-calendar-fields.js | 14 ++++++++++++++ ...argument-constructor-in-calendar-fields.js | 14 ++++++++++++++ .../argument-duplicate-calendar-fields.js | 16 ++++++++++++++++ .../argument-proto-in-calendar-fields.js | 14 ++++++++++++++ ...argument-constructor-in-calendar-fields.js | 14 ++++++++++++++ .../argument-duplicate-calendar-fields.js | 16 ++++++++++++++++ .../year/argument-proto-in-calendar-fields.js | 14 ++++++++++++++ ...argument-constructor-in-calendar-fields.js | 14 ++++++++++++++ .../argument-duplicate-calendar-fields.js | 16 ++++++++++++++++ .../argument-proto-in-calendar-fields.js | 14 ++++++++++++++ .../compare/constructor-in-calendar-fields.js | 15 +++++++++++++++ .../compare/duplicate-calendar-fields.js | 18 ++++++++++++++++++ .../compare/proto-in-calendar-fields.js | 15 +++++++++++++++ .../add/constructor-in-calendar-fields.js | 14 ++++++++++++++ .../add/duplicate-calendar-fields.js | 16 ++++++++++++++++ .../prototype/add/proto-in-calendar-fields.js | 14 ++++++++++++++ .../round/constructor-in-calendar-fields.js | 14 ++++++++++++++ .../round/duplicate-calendar-fields.js | 16 ++++++++++++++++ .../round/proto-in-calendar-fields.js | 14 ++++++++++++++ .../constructor-in-calendar-fields.js | 14 ++++++++++++++ .../subtract/duplicate-calendar-fields.js | 16 ++++++++++++++++ .../subtract/proto-in-calendar-fields.js | 14 ++++++++++++++ .../total/constructor-in-calendar-fields.js | 14 ++++++++++++++ .../total/duplicate-calendar-fields.js | 16 ++++++++++++++++ .../total/proto-in-calendar-fields.js | 14 ++++++++++++++ ...argument-constructor-in-calendar-fields.js | 13 +++++++++++++ .../argument-duplicate-calendar-fields.js | 16 ++++++++++++++++ .../argument-proto-in-calendar-fields.js | 13 +++++++++++++ ...argument-constructor-in-calendar-fields.js | 13 +++++++++++++ .../argument-duplicate-calendar-fields.js | 15 +++++++++++++++ .../from/argument-proto-in-calendar-fields.js | 13 +++++++++++++ ...argument-constructor-in-calendar-fields.js | 14 ++++++++++++++ .../argument-duplicate-calendar-fields.js | 16 ++++++++++++++++ .../argument-proto-in-calendar-fields.js | 14 ++++++++++++++ ...argument-constructor-in-calendar-fields.js | 14 ++++++++++++++ .../argument-duplicate-calendar-fields.js | 16 ++++++++++++++++ .../argument-proto-in-calendar-fields.js | 14 ++++++++++++++ .../constructor-in-calendar-fields.js | 13 +++++++++++++ .../duplicate-calendar-fields.js | 15 +++++++++++++++ .../proto-in-calendar-fields.js | 13 +++++++++++++ .../constructor-in-calendar-fields.js | 13 +++++++++++++ .../duplicate-calendar-fields.js | 15 +++++++++++++++ .../proto-in-calendar-fields.js | 13 +++++++++++++ ...argument-constructor-in-calendar-fields.js | 14 ++++++++++++++ .../argument-duplicate-calendar-fields.js | 16 ++++++++++++++++ .../argument-proto-in-calendar-fields.js | 14 ++++++++++++++ .../with/constructor-in-calendar-fields.js | 13 +++++++++++++ .../with/duplicate-calendar-fields.js | 15 +++++++++++++++ .../with/proto-in-calendar-fields.js | 13 +++++++++++++ .../compare/constructor-in-calendar-fields.js | 14 ++++++++++++++ .../compare/duplicate-calendar-fields.js | 17 +++++++++++++++++ .../compare/proto-in-calendar-fields.js | 14 ++++++++++++++ .../from/constructor-in-calendar-fields.js | 13 +++++++++++++ .../from/duplicate-calendar-fields.js | 16 ++++++++++++++++ .../from/proto-in-calendar-fields.js | 13 +++++++++++++ .../equals/constructor-in-calendar-fields.js | 14 ++++++++++++++ .../equals/duplicate-calendar-fields.js | 16 ++++++++++++++++ .../equals/proto-in-calendar-fields.js | 14 ++++++++++++++ .../since/constructor-in-calendar-fields.js | 14 ++++++++++++++ .../since/duplicate-calendar-fields.js | 16 ++++++++++++++++ .../since/proto-in-calendar-fields.js | 14 ++++++++++++++ .../constructor-in-calendar-fields.js | 13 +++++++++++++ .../duplicate-calendar-fields.js | 15 +++++++++++++++ .../proto-in-calendar-fields.js | 13 +++++++++++++ .../constructor-in-calendar-fields.js | 13 +++++++++++++ .../duplicate-calendar-fields.js | 15 +++++++++++++++ .../proto-in-calendar-fields.js | 13 +++++++++++++ .../until/constructor-in-calendar-fields.js | 14 ++++++++++++++ .../until/duplicate-calendar-fields.js | 16 ++++++++++++++++ .../until/proto-in-calendar-fields.js | 14 ++++++++++++++ .../with/constructor-in-calendar-fields.js | 13 +++++++++++++ .../with/duplicate-calendar-fields.js | 15 +++++++++++++++ .../with/proto-in-calendar-fields.js | 13 +++++++++++++ ...argument-constructor-in-calendar-fields.js | 14 ++++++++++++++ .../argument-duplicate-calendar-fields.js | 16 ++++++++++++++++ .../argument-proto-in-calendar-fields.js | 14 ++++++++++++++ .../from/constructor-in-calendar-fields.js | 13 +++++++++++++ .../from/duplicate-calendar-fields.js | 16 ++++++++++++++++ .../from/proto-in-calendar-fields.js | 13 +++++++++++++ .../equals/constructor-in-calendar-fields.js | 14 ++++++++++++++ .../equals/duplicate-calendar-fields.js | 16 ++++++++++++++++ .../equals/proto-in-calendar-fields.js | 14 ++++++++++++++ .../constructor-in-calendar-fields.js | 13 +++++++++++++ .../toPlainDate/duplicate-calendar-fields.js | 15 +++++++++++++++ .../toPlainDate/proto-in-calendar-fields.js | 13 +++++++++++++ .../with/constructor-in-calendar-fields.js | 13 +++++++++++++ .../with/duplicate-calendar-fields.js | 15 +++++++++++++++ .../with/proto-in-calendar-fields.js | 13 +++++++++++++ ...argument-constructor-in-calendar-fields.js | 14 ++++++++++++++ .../argument-duplicate-calendar-fields.js | 16 ++++++++++++++++ .../argument-proto-in-calendar-fields.js | 14 ++++++++++++++ ...argument-constructor-in-calendar-fields.js | 14 ++++++++++++++ .../argument-duplicate-calendar-fields.js | 16 ++++++++++++++++ .../argument-proto-in-calendar-fields.js | 14 ++++++++++++++ .../compare/constructor-in-calendar-fields.js | 14 ++++++++++++++ .../compare/duplicate-calendar-fields.js | 17 +++++++++++++++++ .../compare/proto-in-calendar-fields.js | 14 ++++++++++++++ .../from/constructor-in-calendar-fields.js | 13 +++++++++++++ .../from/duplicate-calendar-fields.js | 16 ++++++++++++++++ .../from/proto-in-calendar-fields.js | 13 +++++++++++++ .../add/constructor-in-calendar-fields.js | 13 +++++++++++++ .../add/duplicate-calendar-fields.js | 15 +++++++++++++++ .../prototype/add/proto-in-calendar-fields.js | 13 +++++++++++++ .../equals/constructor-in-calendar-fields.js | 14 ++++++++++++++ .../equals/duplicate-calendar-fields.js | 16 ++++++++++++++++ .../equals/proto-in-calendar-fields.js | 14 ++++++++++++++ .../since/constructor-in-calendar-fields.js | 14 ++++++++++++++ .../since/duplicate-calendar-fields.js | 16 ++++++++++++++++ .../since/proto-in-calendar-fields.js | 14 ++++++++++++++ .../constructor-in-calendar-fields.js | 13 +++++++++++++ .../subtract/duplicate-calendar-fields.js | 15 +++++++++++++++ .../subtract/proto-in-calendar-fields.js | 13 +++++++++++++ .../constructor-in-calendar-fields.js | 13 +++++++++++++ .../toPlainDate/duplicate-calendar-fields.js | 15 +++++++++++++++ .../toPlainDate/proto-in-calendar-fields.js | 13 +++++++++++++ .../until/constructor-in-calendar-fields.js | 14 ++++++++++++++ .../until/duplicate-calendar-fields.js | 16 ++++++++++++++++ .../until/proto-in-calendar-fields.js | 14 ++++++++++++++ .../with/constructor-in-calendar-fields.js | 13 +++++++++++++ .../with/duplicate-calendar-fields.js | 15 +++++++++++++++ .../with/proto-in-calendar-fields.js | 13 +++++++++++++ .../constructor-in-calendar-fields.js | 14 ++++++++++++++ .../duplicate-calendar-fields.js | 16 ++++++++++++++++ .../getInstantFor/proto-in-calendar-fields.js | 14 ++++++++++++++ .../constructor-in-calendar-fields.js | 14 ++++++++++++++ .../duplicate-calendar-fields.js | 16 ++++++++++++++++ .../proto-in-calendar-fields.js | 14 ++++++++++++++ .../compare/constructor-in-calendar-fields.js | 16 ++++++++++++++++ .../compare/duplicate-calendar-fields.js | 19 +++++++++++++++++++ .../compare/proto-in-calendar-fields.js | 16 ++++++++++++++++ .../from/constructor-in-calendar-fields.js | 14 ++++++++++++++ .../from/duplicate-calendar-fields.js | 17 +++++++++++++++++ .../from/proto-in-calendar-fields.js | 14 ++++++++++++++ .../equals/constructor-in-calendar-fields.js | 15 +++++++++++++++ .../equals/duplicate-calendar-fields.js | 17 +++++++++++++++++ .../equals/proto-in-calendar-fields.js | 15 +++++++++++++++ .../since/constructor-in-calendar-fields.js | 15 +++++++++++++++ .../since/duplicate-calendar-fields.js | 17 +++++++++++++++++ .../since/proto-in-calendar-fields.js | 15 +++++++++++++++ .../constructor-in-calendar-fields.js | 13 +++++++++++++ .../duplicate-calendar-fields.js | 15 +++++++++++++++ .../proto-in-calendar-fields.js | 13 +++++++++++++ .../constructor-in-calendar-fields.js | 13 +++++++++++++ .../duplicate-calendar-fields.js | 15 +++++++++++++++ .../proto-in-calendar-fields.js | 13 +++++++++++++ .../until/constructor-in-calendar-fields.js | 15 +++++++++++++++ .../until/duplicate-calendar-fields.js | 17 +++++++++++++++++ .../until/proto-in-calendar-fields.js | 15 +++++++++++++++ .../with/constructor-in-calendar-fields.js | 13 +++++++++++++ .../with/duplicate-calendar-fields.js | 15 +++++++++++++++ .../with/proto-in-calendar-fields.js | 13 +++++++++++++ ...argument-constructor-in-calendar-fields.js | 14 ++++++++++++++ .../argument-duplicate-calendar-fields.js | 16 ++++++++++++++++ .../argument-proto-in-calendar-fields.js | 14 ++++++++++++++ ...argument-constructor-in-calendar-fields.js | 14 ++++++++++++++ .../era/argument-duplicate-calendar-fields.js | 16 ++++++++++++++++ .../era/argument-proto-in-calendar-fields.js | 14 ++++++++++++++ ...argument-constructor-in-calendar-fields.js | 14 ++++++++++++++ .../argument-duplicate-calendar-fields.js | 16 ++++++++++++++++ .../argument-proto-in-calendar-fields.js | 14 ++++++++++++++ 196 files changed, 2847 insertions(+) create mode 100644 test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/day/argument-constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/day/argument-duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/day/argument-proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/month/argument-constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/month/argument-duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/month/argument-proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/monthCode/argument-constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/monthCode/argument-duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/monthCode/argument-proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/year/argument-constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/year/argument-duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/year/argument-proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Duration/compare/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Duration/compare/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/Duration/compare/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Duration/prototype/add/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Duration/prototype/add/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/Duration/prototype/add/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Duration/prototype/round/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Duration/prototype/round/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/Duration/prototype/round/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Duration/prototype/subtract/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Duration/prototype/subtract/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/Duration/prototype/subtract/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Duration/prototype/total/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/Duration/prototype/total/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/Duration/prototype/total/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDate/compare/argument-constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDate/compare/argument-duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDate/compare/argument-proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDate/from/argument-constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDate/from/argument-duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDate/from/argument-proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/equals/argument-constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/equals/argument-duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/equals/argument-proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/since/argument-constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/since/argument-duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/since/argument-proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/until/argument-constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/until/argument-duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/until/argument-proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/with/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/with/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/with/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDateTime/compare/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDateTime/compare/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDateTime/compare/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDateTime/from/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDateTime/from/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDateTime/from/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/equals/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/equals/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/equals/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/since/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/since/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/since/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/until/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/until/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/until/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/with/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/with/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/with/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/from/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/from/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/from/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/prototype/equals/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/prototype/equals/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/prototype/equals/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/prototype/with/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/prototype/with/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/prototype/with/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/compare/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/compare/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/compare/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/from/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/from/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/from/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/add/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/add/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/add/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/equals/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/equals/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/equals/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/since/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/since/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/since/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/subtract/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/subtract/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/subtract/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/until/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/until/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/until/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/with/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/with/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/with/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getInstantFor/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getInstantFor/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getInstantFor/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/compare/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/compare/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/compare/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/from/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/from/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/from/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/equals/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/equals/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/equals/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/since/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/since/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/since/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/until/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/until/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/until/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/with/constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/with/duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/with/proto-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-constructor-in-calendar-fields.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-duplicate-calendar-fields.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-proto-in-calendar-fields.js create mode 100644 test/intl402/Temporal/Calendar/prototype/era/argument-constructor-in-calendar-fields.js create mode 100644 test/intl402/Temporal/Calendar/prototype/era/argument-duplicate-calendar-fields.js create mode 100644 test/intl402/Temporal/Calendar/prototype/era/argument-proto-in-calendar-fields.js create mode 100644 test/intl402/Temporal/Calendar/prototype/eraYear/argument-constructor-in-calendar-fields.js create mode 100644 test/intl402/Temporal/Calendar/prototype/eraYear/argument-duplicate-calendar-fields.js create mode 100644 test/intl402/Temporal/Calendar/prototype/eraYear/argument-proto-in-calendar-fields.js diff --git a/harness/temporalHelpers.js b/harness/temporalHelpers.js index 84e0fd3fff..017e2d59b5 100644 --- a/harness/temporalHelpers.js +++ b/harness/temporalHelpers.js @@ -1360,6 +1360,25 @@ var TemporalHelpers = { return new CalendarMergeFieldsPrimitive(primitive); }, + /* + * A custom calendar whose fields() method returns the same value as the + * iso8601 calendar, with the addition of extraFields provided as parameter. + */ + calendarWithExtraFields(fields) { + class CalendarWithExtraFields extends Temporal.Calendar { + constructor(extraFields) { + super("iso8601"); + this._extraFields = extraFields; + } + + fields(fieldNames) { + return super.fields(fieldNames).concat(this._extraFields); + } + } + + return new CalendarWithExtraFields(fields); + }, + /* * crossDateLineTimeZone(): * diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-constructor-in-calendar-fields.js new file mode 100644 index 0000000000..40aa916bd8 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.dateadd +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.dateAdd(arg, new Temporal.Duration())); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-duplicate-calendar-fields.js new file mode 100644 index 0000000000..c22b5c53c9 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.calendar.prototype.dateadd +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.Calendar("iso8601"); + + assert.throws(RangeError, () => instance.dateAdd(arg, new Temporal.Duration())); +} diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-proto-in-calendar-fields.js new file mode 100644 index 0000000000..8e8063c04d --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.dateadd +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.dateAdd(arg, new Temporal.Duration())); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-constructor-in-calendar-fields.js new file mode 100644 index 0000000000..df2e139206 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.dateuntil +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19))); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-duplicate-calendar-fields.js new file mode 100644 index 0000000000..1039216a5a --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-duplicate-calendar-fields.js @@ -0,0 +1,17 @@ +// 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.calendar.prototype.dateuntil +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.Calendar("iso8601"); + + assert.throws(RangeError, () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19))); + assert.throws(RangeError, () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg)); +} diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-proto-in-calendar-fields.js new file mode 100644 index 0000000000..a1a5f68b33 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.dateuntil +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19))); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-constructor-in-calendar-fields.js new file mode 100644 index 0000000000..b61e725dd6 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/day/argument-constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.day +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.day(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-duplicate-calendar-fields.js new file mode 100644 index 0000000000..a170c7ad47 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/day/argument-duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.calendar.prototype.day +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.Calendar("iso8601"); + + assert.throws(RangeError, () => instance.day(arg)); +} diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-proto-in-calendar-fields.js new file mode 100644 index 0000000000..01a7de5317 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/day/argument-proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.day +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.day(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-constructor-in-calendar-fields.js new file mode 100644 index 0000000000..290f8c8232 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.dayofweek +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.dayOfWeek(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-duplicate-calendar-fields.js new file mode 100644 index 0000000000..69fbae0f80 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.calendar.prototype.dayofweek +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.Calendar("iso8601"); + + assert.throws(RangeError, () => instance.dayOfWeek(arg)); +} diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-proto-in-calendar-fields.js new file mode 100644 index 0000000000..930b2560ad --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.dayofweek +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.dayOfWeek(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-constructor-in-calendar-fields.js new file mode 100644 index 0000000000..f48a2ec2de --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.dayofyear +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.dayOfYear(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-duplicate-calendar-fields.js new file mode 100644 index 0000000000..3434126f79 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.calendar.prototype.dayofyear +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.Calendar("iso8601"); + + assert.throws(RangeError, () => instance.dayOfYear(arg)); +} diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-proto-in-calendar-fields.js new file mode 100644 index 0000000000..723c9e39d9 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.dayofyear +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.dayOfYear(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-constructor-in-calendar-fields.js new file mode 100644 index 0000000000..c424f636f2 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.daysinmonth +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.daysInMonth(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-duplicate-calendar-fields.js new file mode 100644 index 0000000000..dc0081f5da --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.calendar.prototype.daysinmonth +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.Calendar("iso8601"); + + assert.throws(RangeError, () => instance.daysInMonth(arg)); +} diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-proto-in-calendar-fields.js new file mode 100644 index 0000000000..397e366f91 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.daysinmonth +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.daysInMonth(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-constructor-in-calendar-fields.js new file mode 100644 index 0000000000..6db6ae2688 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.daysinweek +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.daysInWeek(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-duplicate-calendar-fields.js new file mode 100644 index 0000000000..9abf392169 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.calendar.prototype.daysinweek +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.Calendar("iso8601"); + + assert.throws(RangeError, () => instance.daysInWeek(arg)); +} diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-proto-in-calendar-fields.js new file mode 100644 index 0000000000..8198113c23 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.daysinweek +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.daysInWeek(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-constructor-in-calendar-fields.js new file mode 100644 index 0000000000..6d76185838 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.daysinyear +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.daysInYear(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-duplicate-calendar-fields.js new file mode 100644 index 0000000000..b1e3ca6935 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.calendar.prototype.daysinyear +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.Calendar("iso8601"); + + assert.throws(RangeError, () => instance.daysInYear(arg)); +} diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-proto-in-calendar-fields.js new file mode 100644 index 0000000000..7fe5c089ab --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.daysinyear +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.daysInYear(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-constructor-in-calendar-fields.js new file mode 100644 index 0000000000..6eef969355 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.inleapyear +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.inLeapYear(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-duplicate-calendar-fields.js new file mode 100644 index 0000000000..02870abe19 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.calendar.prototype.inleapyear +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.Calendar("iso8601"); + + assert.throws(RangeError, () => instance.inLeapYear(arg)); +} diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-proto-in-calendar-fields.js new file mode 100644 index 0000000000..79ad523e9c --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.inleapyear +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.inLeapYear(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-constructor-in-calendar-fields.js new file mode 100644 index 0000000000..47b5719e18 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/month/argument-constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.month +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.month(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-duplicate-calendar-fields.js new file mode 100644 index 0000000000..dda70202eb --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/month/argument-duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.calendar.prototype.month +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.Calendar("iso8601"); + + assert.throws(RangeError, () => instance.month(arg)); +} diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-proto-in-calendar-fields.js new file mode 100644 index 0000000000..8bf8306607 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/month/argument-proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.month +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.month(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-constructor-in-calendar-fields.js new file mode 100644 index 0000000000..6a25d2e651 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.monthcode +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.monthCode(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-duplicate-calendar-fields.js new file mode 100644 index 0000000000..c5229c71e8 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.calendar.prototype.monthcode +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.Calendar("iso8601"); + + assert.throws(RangeError, () => instance.monthCode(arg)); +} diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-proto-in-calendar-fields.js new file mode 100644 index 0000000000..c7e0b17fc1 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.monthcode +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.monthCode(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-constructor-in-calendar-fields.js new file mode 100644 index 0000000000..85db3e6b70 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.monthsinyear +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.monthsInYear(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-duplicate-calendar-fields.js new file mode 100644 index 0000000000..90719c38f8 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.calendar.prototype.monthsinyear +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.Calendar("iso8601"); + + assert.throws(RangeError, () => instance.monthsInYear(arg)); +} diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-proto-in-calendar-fields.js new file mode 100644 index 0000000000..7030f584d9 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.monthsinyear +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.monthsInYear(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-constructor-in-calendar-fields.js new file mode 100644 index 0000000000..a788ec42f4 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.weekofyear +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.weekOfYear(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-duplicate-calendar-fields.js new file mode 100644 index 0000000000..3d51dd9f8f --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.calendar.prototype.weekofyear +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.Calendar("iso8601"); + + assert.throws(RangeError, () => instance.weekOfYear(arg)); +} diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-proto-in-calendar-fields.js new file mode 100644 index 0000000000..56a0915d04 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.weekofyear +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.weekOfYear(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-constructor-in-calendar-fields.js new file mode 100644 index 0000000000..e75b31aad3 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/year/argument-constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.year +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.year(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-duplicate-calendar-fields.js new file mode 100644 index 0000000000..f32d15c290 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/year/argument-duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.calendar.prototype.year +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.Calendar("iso8601"); + + assert.throws(RangeError, () => instance.year(arg)); +} diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-proto-in-calendar-fields.js new file mode 100644 index 0000000000..fadb95c321 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/year/argument-proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.year +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.year(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-constructor-in-calendar-fields.js new file mode 100644 index 0000000000..f400367952 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.yearofweek +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.yearOfWeek(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-duplicate-calendar-fields.js new file mode 100644 index 0000000000..1c2b345ac7 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.calendar.prototype.yearofweek +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.Calendar("iso8601"); + + assert.throws(RangeError, () => instance.yearOfWeek(arg)); +} diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-proto-in-calendar-fields.js new file mode 100644 index 0000000000..48a03876cd --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.yearofweek +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.yearOfWeek(arg)); diff --git a/test/built-ins/Temporal/Duration/compare/constructor-in-calendar-fields.js b/test/built-ins/Temporal/Duration/compare/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..db3d5834e3 --- /dev/null +++ b/test/built-ins/Temporal/Duration/compare/constructor-in-calendar-fields.js @@ -0,0 +1,15 @@ +// 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.duration.prototype.compare +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const relativeTo = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: 'Europe/Paris' }; +const duration1 = new Temporal.Duration(1); +const duration2 = new Temporal.Duration(0, 12); + +assert.throws(RangeError, () => Temporal.Duration.compare(duration1, duration2, {relativeTo: relativeTo})); diff --git a/test/built-ins/Temporal/Duration/compare/duplicate-calendar-fields.js b/test/built-ins/Temporal/Duration/compare/duplicate-calendar-fields.js new file mode 100644 index 0000000000..827376b034 --- /dev/null +++ b/test/built-ins/Temporal/Duration/compare/duplicate-calendar-fields.js @@ -0,0 +1,18 @@ +// 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.duration.prototype.compare +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const relativeTo = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: 'Europe/Paris' }; + const duration1 = new Temporal.Duration(1); + const duration2 = new Temporal.Duration(0, 12); + + assert.throws(RangeError, () => Temporal.Duration.compare(duration1, duration2, {relativeTo: relativeTo})); +} diff --git a/test/built-ins/Temporal/Duration/compare/proto-in-calendar-fields.js b/test/built-ins/Temporal/Duration/compare/proto-in-calendar-fields.js new file mode 100644 index 0000000000..3f0c4634e6 --- /dev/null +++ b/test/built-ins/Temporal/Duration/compare/proto-in-calendar-fields.js @@ -0,0 +1,15 @@ +// 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.duration.prototype.compare +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const relativeTo = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: 'Europe/Paris' }; +const duration1 = new Temporal.Duration(1); +const duration2 = new Temporal.Duration(0, 12); + +assert.throws(RangeError, () => Temporal.Duration.compare(duration1, duration2, {relativeTo: relativeTo})); diff --git a/test/built-ins/Temporal/Duration/prototype/add/constructor-in-calendar-fields.js b/test/built-ins/Temporal/Duration/prototype/add/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..f96a739fe5 --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/add/constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.duration.prototype.add +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const relativeTo = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: 'Europe/Paris' }; +const instance = new Temporal.Duration(1, 0, 0, 1); + +assert.throws(RangeError, () => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo })); diff --git a/test/built-ins/Temporal/Duration/prototype/add/duplicate-calendar-fields.js b/test/built-ins/Temporal/Duration/prototype/add/duplicate-calendar-fields.js new file mode 100644 index 0000000000..f6feeb45d0 --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/add/duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.duration.prototype.add +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const relativeTo = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: 'Europe/Paris' }; + const instance = new Temporal.Duration(1, 0, 0, 1); + + assert.throws(RangeError, () => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo })); +} diff --git a/test/built-ins/Temporal/Duration/prototype/add/proto-in-calendar-fields.js b/test/built-ins/Temporal/Duration/prototype/add/proto-in-calendar-fields.js new file mode 100644 index 0000000000..0d05beff68 --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/add/proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.duration.prototype.add +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const relativeTo = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: 'Europe/Paris' }; +const instance = new Temporal.Duration(1, 0, 0, 1); + +assert.throws(RangeError, () => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo })); diff --git a/test/built-ins/Temporal/Duration/prototype/round/constructor-in-calendar-fields.js b/test/built-ins/Temporal/Duration/prototype/round/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..8d528e96b2 --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/round/constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.duration.prototype.round +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const relativeTo = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: 'Europe/Paris' }; +const instance = new Temporal.Duration(1, 0, 0, 0, 24); + +assert.throws(RangeError, () => instance.round({ largestUnit: "years", relativeTo })); diff --git a/test/built-ins/Temporal/Duration/prototype/round/duplicate-calendar-fields.js b/test/built-ins/Temporal/Duration/prototype/round/duplicate-calendar-fields.js new file mode 100644 index 0000000000..a7446eee49 --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/round/duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.duration.prototype.round +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const relativeTo = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: 'Europe/Paris' }; + const instance = new Temporal.Duration(1, 0, 0, 0, 24); + + assert.throws(RangeError, () => instance.round({ largestUnit: "years", relativeTo })); +} diff --git a/test/built-ins/Temporal/Duration/prototype/round/proto-in-calendar-fields.js b/test/built-ins/Temporal/Duration/prototype/round/proto-in-calendar-fields.js new file mode 100644 index 0000000000..c7a1c3dc25 --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/round/proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.duration.prototype.round +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const relativeTo = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: 'Europe/Paris' }; +const instance = new Temporal.Duration(1, 0, 0, 0, 24); + +assert.throws(RangeError, () => instance.round({ largestUnit: "years", relativeTo })); diff --git a/test/built-ins/Temporal/Duration/prototype/subtract/constructor-in-calendar-fields.js b/test/built-ins/Temporal/Duration/prototype/subtract/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..57fdb7666d --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/subtract/constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.duration.prototype.subtract +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const relativeTo = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: 'Europe/Paris' }; +const instance = new Temporal.Duration(1, 0, 0, 1); + +assert.throws(RangeError, () => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo })); diff --git a/test/built-ins/Temporal/Duration/prototype/subtract/duplicate-calendar-fields.js b/test/built-ins/Temporal/Duration/prototype/subtract/duplicate-calendar-fields.js new file mode 100644 index 0000000000..67687b8a7f --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/subtract/duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.duration.prototype.subtract +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const relativeTo = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: 'Europe/Paris' }; + const instance = new Temporal.Duration(1, 0, 0, 1); + + assert.throws(RangeError, () => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo })); +} diff --git a/test/built-ins/Temporal/Duration/prototype/subtract/proto-in-calendar-fields.js b/test/built-ins/Temporal/Duration/prototype/subtract/proto-in-calendar-fields.js new file mode 100644 index 0000000000..891959b8ad --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/subtract/proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.duration.prototype.subtract +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const relativeTo = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: 'Europe/Paris' }; +const instance = new Temporal.Duration(1, 0, 0, 1); + +assert.throws(RangeError, () => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo })); diff --git a/test/built-ins/Temporal/Duration/prototype/total/constructor-in-calendar-fields.js b/test/built-ins/Temporal/Duration/prototype/total/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..1ee7fee5bc --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/total/constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.duration.prototype.total +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const relativeTo = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: 'Europe/Paris' }; +const instance = new Temporal.Duration(1, 0, 0, 0, 24); + +assert.throws(RangeError, () => instance.total({ unit: "days", relativeTo })); diff --git a/test/built-ins/Temporal/Duration/prototype/total/duplicate-calendar-fields.js b/test/built-ins/Temporal/Duration/prototype/total/duplicate-calendar-fields.js new file mode 100644 index 0000000000..94eaed07fd --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/total/duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.duration.prototype.total +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const relativeTo = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: 'Europe/Paris' }; + const instance = new Temporal.Duration(1, 0, 0, 0, 24); + + assert.throws(RangeError, () => instance.total({ unit: "days", relativeTo })); +} diff --git a/test/built-ins/Temporal/Duration/prototype/total/proto-in-calendar-fields.js b/test/built-ins/Temporal/Duration/prototype/total/proto-in-calendar-fields.js new file mode 100644 index 0000000000..5c75d3706c --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/total/proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.duration.prototype.total +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const relativeTo = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: 'Europe/Paris' }; +const instance = new Temporal.Duration(1, 0, 0, 0, 24); + +assert.throws(RangeError, () => instance.total({ unit: "days", relativeTo })); diff --git a/test/built-ins/Temporal/PlainDate/compare/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/compare/argument-constructor-in-calendar-fields.js new file mode 100644 index 0000000000..999aea9bc6 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/compare/argument-constructor-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.plaindate.prototype.compare +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; + +assert.throws(RangeError, () => Temporal.PlainDate.compare(arg, new Temporal.PlainDate(1976, 11, 18))); diff --git a/test/built-ins/Temporal/PlainDate/compare/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDate/compare/argument-duplicate-calendar-fields.js new file mode 100644 index 0000000000..067cb5aa6d --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/compare/argument-duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.plaindate.prototype.compare +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + + assert.throws(RangeError, () => Temporal.PlainDate.compare(arg, new Temporal.PlainDate(1976, 11, 18))); + assert.throws(RangeError, () => Temporal.PlainDate.compare(new Temporal.PlainDate(1976, 11, 18), arg)); +} diff --git a/test/built-ins/Temporal/PlainDate/compare/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/compare/argument-proto-in-calendar-fields.js new file mode 100644 index 0000000000..142e103488 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/compare/argument-proto-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.plaindate.prototype.compare +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; + +assert.throws(RangeError, () => Temporal.PlainDate.compare(arg, new Temporal.PlainDate(1976, 11, 18))); diff --git a/test/built-ins/Temporal/PlainDate/from/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/from/argument-constructor-in-calendar-fields.js new file mode 100644 index 0000000000..46dbb7603b --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/from/argument-constructor-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.plaindate.prototype.from +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; + +assert.throws(RangeError, () => Temporal.PlainDate.from(arg)); diff --git a/test/built-ins/Temporal/PlainDate/from/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDate/from/argument-duplicate-calendar-fields.js new file mode 100644 index 0000000000..f49238d08c --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/from/argument-duplicate-calendar-fields.js @@ -0,0 +1,15 @@ +// 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.plaindate.prototype.from +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + + assert.throws(RangeError, () => Temporal.PlainDate.from(arg)); +} diff --git a/test/built-ins/Temporal/PlainDate/from/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/from/argument-proto-in-calendar-fields.js new file mode 100644 index 0000000000..f350e49966 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/from/argument-proto-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.plaindate.prototype.from +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; + +assert.throws(RangeError, () => Temporal.PlainDate.from(arg)); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-constructor-in-calendar-fields.js new file mode 100644 index 0000000000..5f90050c0c --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.plaindate.prototype.equals +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.PlainDate(2000, 5, 2); + +assert.throws(RangeError, () => instance.equals(arg)); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-duplicate-calendar-fields.js new file mode 100644 index 0000000000..87d5b82aa1 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.plaindate.prototype.equals +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.PlainDate(2000, 5, 2); + + assert.throws(RangeError, () => instance.equals(arg)); +} diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-proto-in-calendar-fields.js new file mode 100644 index 0000000000..6ceb3d7e15 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.plaindate.prototype.equals +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.PlainDate(2000, 5, 2); + +assert.throws(RangeError, () => instance.equals(arg)); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/since/argument-constructor-in-calendar-fields.js new file mode 100644 index 0000000000..7bf7b1cbbf --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/since/argument-constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.plaindate.prototype.since +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.PlainDate(2000, 5, 2); + +assert.throws(RangeError, () => instance.since(arg)); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/since/argument-duplicate-calendar-fields.js new file mode 100644 index 0000000000..8eb663563b --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/since/argument-duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.plaindate.prototype.since +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.PlainDate(2000, 5, 2); + + assert.throws(RangeError, () => instance.since(arg)); +} diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/since/argument-proto-in-calendar-fields.js new file mode 100644 index 0000000000..c11d30bbda --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/since/argument-proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.plaindate.prototype.since +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.PlainDate(2000, 5, 2); + +assert.throws(RangeError, () => instance.since(arg)); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..909debb9eb --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/constructor-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.plaindate.prototype.toplainmonthday +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const date = new Temporal.PlainDate(2023, 5, 1, calendar); + +assert.throws(RangeError, () => date.toPlainMonthDay()); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/duplicate-calendar-fields.js new file mode 100644 index 0000000000..3f2cfd33e1 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/duplicate-calendar-fields.js @@ -0,0 +1,15 @@ +// 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.plaindate.prototype.toplainmonthday +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['monthCode'], ['day']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const date = new Temporal.PlainDate(2023, 5, 1, calendar); + + assert.throws(RangeError, () => date.toPlainMonthDay()); +} diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/proto-in-calendar-fields.js new file mode 100644 index 0000000000..99105732a4 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/proto-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.plaindate.prototype.toplainmonthday +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const date = new Temporal.PlainDate(2023, 5, 1, calendar); + +assert.throws(RangeError, () => date.toPlainMonthDay()); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..7d77028b7a --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/constructor-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.plaindate.prototype.toplainyearmonth +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const date = new Temporal.PlainDate(2023, 5, 1, calendar); + +assert.throws(RangeError, () => date.toPlainYearMonth()); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/duplicate-calendar-fields.js new file mode 100644 index 0000000000..fcfcda724a --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/duplicate-calendar-fields.js @@ -0,0 +1,15 @@ +// 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.plaindate.prototype.toplainyearmonth +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const date = new Temporal.PlainDate(2023, 5, 1, calendar); + + assert.throws(RangeError, () => date.toPlainYearMonth()); +} diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/proto-in-calendar-fields.js new file mode 100644 index 0000000000..c8d1a8fa43 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/proto-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.plaindate.prototype.toplainyearmonth +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const date = new Temporal.PlainDate(2023, 5, 1, calendar); + +assert.throws(RangeError, () => date.toPlainYearMonth()); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/until/argument-constructor-in-calendar-fields.js new file mode 100644 index 0000000000..1c3fb02454 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/until/argument-constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.plaindate.prototype.until +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.PlainDate(2000, 5, 2); + +assert.throws(RangeError, () => instance.until(arg)); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/until/argument-duplicate-calendar-fields.js new file mode 100644 index 0000000000..342c0a1dd4 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/until/argument-duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.plaindate.prototype.until +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.PlainDate(2000, 5, 2); + + assert.throws(RangeError, () => instance.until(arg)); +} diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/until/argument-proto-in-calendar-fields.js new file mode 100644 index 0000000000..73fe934d58 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/until/argument-proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.plaindate.prototype.until +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.PlainDate(2000, 5, 2); + +assert.throws(RangeError, () => instance.until(arg)); diff --git a/test/built-ins/Temporal/PlainDate/prototype/with/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/with/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..67cc276cf3 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/with/constructor-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.plaindate.prototype.with +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const date = new Temporal.PlainDate(2023, 5, 1, calendar); + +assert.throws(RangeError, () => date.with({day: 15})); diff --git a/test/built-ins/Temporal/PlainDate/prototype/with/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/with/duplicate-calendar-fields.js new file mode 100644 index 0000000000..5e895c43ed --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/with/duplicate-calendar-fields.js @@ -0,0 +1,15 @@ +// 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.plaindate.prototype.with +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['monthCode'], ['day'], ['month'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const date = new Temporal.PlainDate(2023, 5, 1, calendar); + + assert.throws(RangeError, () => date.with({day: 15})); +} diff --git a/test/built-ins/Temporal/PlainDate/prototype/with/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/with/proto-in-calendar-fields.js new file mode 100644 index 0000000000..3b0d5d9ffc --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/with/proto-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.plaindate.prototype.with +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const date = new Temporal.PlainDate(2023, 5, 1, calendar); + +assert.throws(RangeError, () => date.with({day: 15})); diff --git a/test/built-ins/Temporal/PlainDateTime/compare/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/compare/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..6883de7a81 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/compare/constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.plaindatetime.prototype.compare +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; + +assert.throws(RangeError, () => Temporal.PlainDateTime.compare(arg, new Temporal.PlainDateTime(1976, 11, 18))); +assert.throws(RangeError, () => Temporal.PlainDateTime.compare(new Temporal.PlainDateTime(1976, 11, 18), arg)); diff --git a/test/built-ins/Temporal/PlainDateTime/compare/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/compare/duplicate-calendar-fields.js new file mode 100644 index 0000000000..8176133e82 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/compare/duplicate-calendar-fields.js @@ -0,0 +1,17 @@ +// 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.plaindatetime.prototype.compare +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + + +for (const extra_fields of [['foo', 'foo'], ['day'], ['hour'], ['microsecond'], ['millisecond'], ['minute'], ['month'], ['monthCode'], ['nanosecond'], ['second'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + + assert.throws(RangeError, () => Temporal.PlainDateTime.compare(arg, new Temporal.PlainDateTime(1976, 11, 18))); + assert.throws(RangeError, () => Temporal.PlainDateTime.compare(new Temporal.PlainDateTime(1976, 11, 18), arg)); +} diff --git a/test/built-ins/Temporal/PlainDateTime/compare/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/compare/proto-in-calendar-fields.js new file mode 100644 index 0000000000..ecca8b72c0 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/compare/proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.plaindatetime.prototype.compare +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; + +assert.throws(RangeError, () => Temporal.PlainDateTime.compare(arg, new Temporal.PlainDateTime(1976, 11, 18))); +assert.throws(RangeError, () => Temporal.PlainDateTime.compare(new Temporal.PlainDateTime(1976, 11, 18), arg)); diff --git a/test/built-ins/Temporal/PlainDateTime/from/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/from/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..9439882931 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/from/constructor-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.plaindatetime.prototype.from +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; + +assert.throws(RangeError, () => Temporal.PlainDateTime.from(arg)); diff --git a/test/built-ins/Temporal/PlainDateTime/from/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/from/duplicate-calendar-fields.js new file mode 100644 index 0000000000..7e25ff716b --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/from/duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.plaindatetime.prototype.from +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + + +for (const extra_fields of [['foo', 'foo'], ['day'], ['hour'], ['microsecond'], ['millisecond'], ['minute'], ['month'], ['monthCode'], ['nanosecond'], ['second'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + + assert.throws(RangeError, () => Temporal.PlainDateTime.from(arg)); +} diff --git a/test/built-ins/Temporal/PlainDateTime/from/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/from/proto-in-calendar-fields.js new file mode 100644 index 0000000000..485df8ba91 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/from/proto-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.plaindatetime.prototype.from +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; + +assert.throws(RangeError, () => Temporal.PlainDateTime.from(arg)); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..1afac8a644 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/equals/constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.plaindatetime.prototype.equals +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); + +assert.throws(RangeError, () => instance.equals(arg)); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/duplicate-calendar-fields.js new file mode 100644 index 0000000000..b1c3b9cadf --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/equals/duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.plaindatetime.prototype.equals +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['hour'], ['microsecond'], ['millisecond'], ['minute'], ['month'], ['monthCode'], ['nanosecond'], ['second'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); + + assert.throws(RangeError, () => instance.equals(arg)); +} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/proto-in-calendar-fields.js new file mode 100644 index 0000000000..56b7c48827 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/equals/proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.plaindatetime.prototype.equals +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); + +assert.throws(RangeError, () => instance.equals(arg)); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..37ae19eb2d --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.plaindatetime.prototype.since +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); + +assert.throws(RangeError, () => instance.since(arg)); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/duplicate-calendar-fields.js new file mode 100644 index 0000000000..f43dfcb833 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.plaindatetime.prototype.since +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['hour'], ['microsecond'], ['millisecond'], ['minute'], ['month'], ['monthCode'], ['nanosecond'], ['second'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); + + assert.throws(RangeError, () => instance.since(arg)); +} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/proto-in-calendar-fields.js new file mode 100644 index 0000000000..42a37ce6db --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.plaindatetime.prototype.since +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); + +assert.throws(RangeError, () => instance.since(arg)); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..91e4e895e5 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/constructor-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.plaindatetime.prototype.toplainmonthday +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const datetime = new Temporal.PlainDateTime(2023, 5, 1, 0, 0, 0, 0, 0, 0, calendar); + +assert.throws(RangeError, () => datetime.toPlainMonthDay()); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/duplicate-calendar-fields.js new file mode 100644 index 0000000000..ba6b61834a --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/duplicate-calendar-fields.js @@ -0,0 +1,15 @@ +// 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.plaindatetime.prototype.toplainmonthday +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['monthCode'], ['day']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const datetime = new Temporal.PlainDateTime(2023, 5, 1, 0, 0, 0, 0, 0, 0, calendar); + + assert.throws(RangeError, () => datetime.toPlainMonthDay()); +} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/proto-in-calendar-fields.js new file mode 100644 index 0000000000..732ab30431 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/proto-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.plaindatetime.prototype.toplainmonthday +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const datetime = new Temporal.PlainDateTime(2023, 5, 1, 0, 0, 0, 0, 0, 0, calendar); + +assert.throws(RangeError, () => datetime.toPlainMonthDay()); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..7460225811 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/constructor-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.plaindatetime.prototype.toplainyearmonth +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const datetime = new Temporal.PlainDateTime(2023, 5, 1, 0, 0, 0, 0, 0, 0, calendar); + +assert.throws(RangeError, () => datetime.toPlainYearMonth()); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/duplicate-calendar-fields.js new file mode 100644 index 0000000000..e8bf36a8cc --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/duplicate-calendar-fields.js @@ -0,0 +1,15 @@ +// 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.plaindatetime.prototype.toplainyearmonth +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const datetime = new Temporal.PlainDateTime(2023, 5, 1, 0, 0, 0, 0, 0, 0, calendar); + + assert.throws(RangeError, () => datetime.toPlainYearMonth()); +} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/proto-in-calendar-fields.js new file mode 100644 index 0000000000..2c9c60888b --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/proto-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.plaindatetime.prototype.toplainyearmonth +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const datetime = new Temporal.PlainDateTime(2023, 5, 1, 0, 0, 0, 0, 0, 0, calendar); + +assert.throws(RangeError, () => datetime.toPlainYearMonth()); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..36cd1428a0 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.plaindatetime.prototype.until +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); + +assert.throws(RangeError, () => instance.until(arg)); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/duplicate-calendar-fields.js new file mode 100644 index 0000000000..19dd63b116 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.plaindatetime.prototype.until +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['hour'], ['microsecond'], ['millisecond'], ['minute'], ['month'], ['monthCode'], ['nanosecond'], ['second'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); + + assert.throws(RangeError, () => instance.until(arg)); +} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/proto-in-calendar-fields.js new file mode 100644 index 0000000000..ecf8ff624f --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.plaindatetime.prototype.until +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); + +assert.throws(RangeError, () => instance.until(arg)); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/with/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/with/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..83c17c6142 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/with/constructor-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.plaindatetime.prototype.with +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const datetime = new Temporal.PlainDateTime(2023, 5, 1, 0, 0, 0, 0, 0, 0, calendar); + +assert.throws(RangeError, () => datetime.with({hour: 12})); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/with/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/with/duplicate-calendar-fields.js new file mode 100644 index 0000000000..290ee6442d --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/with/duplicate-calendar-fields.js @@ -0,0 +1,15 @@ +// 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.plaindatetime.prototype.with +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['monthCode'], ['day'], ['hour'], ['microsecond'], ['millisecond'], ['minute'], ['month'], ['nanosecond'], ['second'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const datetime = new Temporal.PlainDateTime(2023, 5, 1, 0, 0, 0, 0, 0, 0, calendar); + + assert.throws(RangeError, () => datetime.with({hour: 12})); +} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/with/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/with/proto-in-calendar-fields.js new file mode 100644 index 0000000000..2cdeb3356f --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/with/proto-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.plaindatetime.prototype.with +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const datetime = new Temporal.PlainDateTime(2023, 5, 1, 0, 0, 0, 0, 0, 0, calendar); + +assert.throws(RangeError, () => datetime.with({hour: 12})); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-constructor-in-calendar-fields.js new file mode 100644 index 0000000000..d33f40668f --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.plaindatetime.prototype.withplaindate +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); + +assert.throws(RangeError, () => instance.withPlainDate(arg)); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-duplicate-calendar-fields.js new file mode 100644 index 0000000000..13845bf5af --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.plaindatetime.prototype.withplaindate +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); + + assert.throws(RangeError, () => instance.withPlainDate(arg)); +} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-proto-in-calendar-fields.js new file mode 100644 index 0000000000..c19f0a5f67 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.plaindatetime.prototype.withplaindate +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); + +assert.throws(RangeError, () => instance.withPlainDate(arg)); diff --git a/test/built-ins/Temporal/PlainMonthDay/from/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainMonthDay/from/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..2f79e1144e --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/from/constructor-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.prototype.from +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; + +assert.throws(RangeError, () => Temporal.PlainMonthDay.from(arg)); diff --git a/test/built-ins/Temporal/PlainMonthDay/from/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainMonthDay/from/duplicate-calendar-fields.js new file mode 100644 index 0000000000..858b0466f7 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/from/duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.prototype.from +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + + assert.throws(RangeError, () => Temporal.PlainMonthDay.from(arg)); +} diff --git a/test/built-ins/Temporal/PlainMonthDay/from/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainMonthDay/from/proto-in-calendar-fields.js new file mode 100644 index 0000000000..5ca42aeb38 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/from/proto-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.prototype.from +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; + +assert.throws(RangeError, () => Temporal.PlainMonthDay.from(arg)); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..4f4058f0c5 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.prototype.equals +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.PlainMonthDay(5, 2, calendar); + +assert.throws(RangeError, () => instance.equals(arg)); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/duplicate-calendar-fields.js new file mode 100644 index 0000000000..d7d9379c9c --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.prototype.equals +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.PlainMonthDay(5, 2, calendar); + + assert.throws(RangeError, () => instance.equals(arg)); +} diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/proto-in-calendar-fields.js new file mode 100644 index 0000000000..0e3a9f958f --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.prototype.equals +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.PlainMonthDay(5, 2, calendar); + +assert.throws(RangeError, () => instance.equals(arg)); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..eddae70a34 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/constructor-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.prototype.toplaindate +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const md = new Temporal.PlainMonthDay(5, 1, calendar); + +assert.throws(RangeError, () => md.toPlainDate({year: 2023})); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/duplicate-calendar-fields.js new file mode 100644 index 0000000000..9f0ce3c688 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/duplicate-calendar-fields.js @@ -0,0 +1,15 @@ +// 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.prototype.toplaindate +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['monthCode'], ['day'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const md = new Temporal.PlainMonthDay(5, 1, calendar); + + assert.throws(RangeError, () => md.toPlainDate({year: 2023})); +} diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/proto-in-calendar-fields.js new file mode 100644 index 0000000000..160fe30df9 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/proto-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.prototype.toplaindate +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const md = new Temporal.PlainMonthDay(5, 1, calendar); + +assert.throws(RangeError, () => md.toPlainDate({year: 2023})); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/with/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainMonthDay/prototype/with/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..ba57169d68 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/with/constructor-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.prototype.with +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const md = new Temporal.PlainMonthDay(5, 1, calendar); + +assert.throws(RangeError, () => md.with({day: 15})); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/with/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainMonthDay/prototype/with/duplicate-calendar-fields.js new file mode 100644 index 0000000000..a3cc5a097d --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/with/duplicate-calendar-fields.js @@ -0,0 +1,15 @@ +// 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.prototype.with +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['monthCode'], ['day'], ['month'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const md = new Temporal.PlainMonthDay(5, 1, calendar); + + assert.throws(RangeError, () => md.with({day: 15})); +} diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/with/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainMonthDay/prototype/with/proto-in-calendar-fields.js new file mode 100644 index 0000000000..41d557ae56 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/with/proto-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.prototype.with +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const md = new Temporal.PlainMonthDay(5, 1, calendar); + +assert.throws(RangeError, () => md.with({day: 15})); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-constructor-in-calendar-fields.js new file mode 100644 index 0000000000..d7980dc0fd --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.plaintime.prototype.toplaindatetime +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); + +assert.throws(RangeError, () => instance.toPlainDateTime(arg)); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-duplicate-calendar-fields.js new file mode 100644 index 0000000000..ad36cecc7b --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.plaintime.prototype.toplaindatetime +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); + + assert.throws(RangeError, () => instance.toPlainDateTime(arg)); +} diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-proto-in-calendar-fields.js new file mode 100644 index 0000000000..13b391418d --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.plaintime.prototype.toplaindatetime +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); + +assert.throws(RangeError, () => instance.toPlainDateTime(arg)); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-constructor-in-calendar-fields.js new file mode 100644 index 0000000000..cbae8d4bdc --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.plaintime.prototype.tozoneddatetime +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); + +assert.throws(RangeError, () => instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" })); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-duplicate-calendar-fields.js new file mode 100644 index 0000000000..5485aea3ab --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.plaintime.prototype.tozoneddatetime +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); + + assert.throws(RangeError, () => instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" })); +} diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-proto-in-calendar-fields.js new file mode 100644 index 0000000000..fc7dbc35e7 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.plaintime.prototype.tozoneddatetime +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); + +assert.throws(RangeError, () => instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" })); diff --git a/test/built-ins/Temporal/PlainYearMonth/compare/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/compare/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..12a8f3eddb --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/compare/constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.prototype.compare +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; + +assert.throws(RangeError, () => Temporal.PlainYearMonth.compare(arg, new Temporal.PlainYearMonth(2019, 6))); +assert.throws(RangeError, () => Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2019, 6), arg)); diff --git a/test/built-ins/Temporal/PlainYearMonth/compare/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/compare/duplicate-calendar-fields.js new file mode 100644 index 0000000000..9227ce04aa --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/compare/duplicate-calendar-fields.js @@ -0,0 +1,17 @@ +// 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.prototype.compare +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + + +for (const extra_fields of [['foo', 'foo'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + + assert.throws(RangeError, () => Temporal.PlainYearMonth.compare(arg, new Temporal.PlainYearMonth(2019, 6))); + assert.throws(RangeError, () => Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2019, 6), arg)); +} diff --git a/test/built-ins/Temporal/PlainYearMonth/compare/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/compare/proto-in-calendar-fields.js new file mode 100644 index 0000000000..5291744de9 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/compare/proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.prototype.compare +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; + +assert.throws(RangeError, () => Temporal.PlainYearMonth.compare(arg, new Temporal.PlainYearMonth(2019, 6))); +assert.throws(RangeError, () => Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2019, 6), arg)); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/from/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..26574f87ee --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/from/constructor-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.prototype.from +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; + +assert.throws(RangeError, () => Temporal.PlainYearMonth.from(arg)); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/from/duplicate-calendar-fields.js new file mode 100644 index 0000000000..03f93d3a10 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/from/duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.prototype.from +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + + +for (const extra_fields of [['foo', 'foo'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + + assert.throws(RangeError, () => Temporal.PlainYearMonth.from(arg)); +} diff --git a/test/built-ins/Temporal/PlainYearMonth/from/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/from/proto-in-calendar-fields.js new file mode 100644 index 0000000000..c816a8e31f --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/from/proto-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.prototype.from +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; + +assert.throws(RangeError, () => Temporal.PlainYearMonth.from(arg)); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..f85b7eded5 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/add/constructor-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.prototype.add +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const ym = new Temporal.PlainYearMonth(2023, 5, calendar); + +assert.throws(RangeError, () => ym.add({days: 123})); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/duplicate-calendar-fields.js new file mode 100644 index 0000000000..0cc84dbd96 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/add/duplicate-calendar-fields.js @@ -0,0 +1,15 @@ +// 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.prototype.add +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const ym = new Temporal.PlainYearMonth(2023, 5, calendar); + + assert.throws(RangeError, () => ym.add({days: 123})); +} diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/proto-in-calendar-fields.js new file mode 100644 index 0000000000..79adbbe278 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/add/proto-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.prototype.add +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const ym = new Temporal.PlainYearMonth(2023, 5, calendar); + +assert.throws(RangeError, () => ym.add({days: 123})); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..48fc21d6cd --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.prototype.equals +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.PlainYearMonth(2000, 5, calendar); + +assert.throws(RangeError, () => instance.equals(arg)); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/duplicate-calendar-fields.js new file mode 100644 index 0000000000..ae7a132a0c --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.prototype.equals +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.PlainYearMonth(2000, 5, calendar); + + assert.throws(RangeError, () => instance.equals(arg)); +} diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/proto-in-calendar-fields.js new file mode 100644 index 0000000000..d299fd21bc --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.prototype.equals +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.PlainYearMonth(2000, 5, calendar); + +assert.throws(RangeError, () => instance.equals(arg)); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..ad7c8ca708 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.prototype.since +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.PlainYearMonth(2000, 5, calendar); + +assert.throws(RangeError, () => instance.since(arg)); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/duplicate-calendar-fields.js new file mode 100644 index 0000000000..209f708b63 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.prototype.since +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.PlainYearMonth(2000, 5, calendar); + + assert.throws(RangeError, () => instance.since(arg)); +} diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/proto-in-calendar-fields.js new file mode 100644 index 0000000000..dd597d4f8d --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.prototype.since +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.PlainYearMonth(2000, 5, calendar); + +assert.throws(RangeError, () => instance.since(arg)); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..fe1ddcc8d7 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/constructor-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.prototype.subtract +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const ym = new Temporal.PlainYearMonth(2023, 5, calendar); + +assert.throws(RangeError, () => ym.subtract({days: 123})); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/duplicate-calendar-fields.js new file mode 100644 index 0000000000..bcbbdd57cd --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/duplicate-calendar-fields.js @@ -0,0 +1,15 @@ +// 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.prototype.subtract +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const ym = new Temporal.PlainYearMonth(2023, 5, calendar); + + assert.throws(RangeError, () => ym.subtract({days: 123})); +} diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/proto-in-calendar-fields.js new file mode 100644 index 0000000000..a18f5a7c21 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/proto-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.prototype.subtract +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const ym = new Temporal.PlainYearMonth(2023, 5, calendar); + +assert.throws(RangeError, () => ym.subtract({days: 123})); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..b7eea31a28 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/constructor-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.prototype.toplaindate +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const ym = new Temporal.PlainYearMonth(2023, 5, calendar); + +assert.throws(RangeError, () => ym.toPlainDate({day: 1})); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/duplicate-calendar-fields.js new file mode 100644 index 0000000000..3e79b3a69d --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/duplicate-calendar-fields.js @@ -0,0 +1,15 @@ +// 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.prototype.toplaindate +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['monthCode'], ['year'], ['day']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const ym = new Temporal.PlainYearMonth(2023, 5, calendar); + + assert.throws(RangeError, () => ym.toPlainDate({day: 1})); +} diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/proto-in-calendar-fields.js new file mode 100644 index 0000000000..efbf50d20a --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/proto-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.prototype.toplaindate +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const ym = new Temporal.PlainYearMonth(2023, 5, calendar); + +assert.throws(RangeError, () => ym.toPlainDate({day: 1})); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..7129de812d --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.prototype.until +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.PlainYearMonth(2000, 5, calendar); + +assert.throws(RangeError, () => instance.until(arg)); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/duplicate-calendar-fields.js new file mode 100644 index 0000000000..b1e6e75d14 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.prototype.until +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.PlainYearMonth(2000, 5, calendar); + + assert.throws(RangeError, () => instance.until(arg)); +} diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/proto-in-calendar-fields.js new file mode 100644 index 0000000000..6714dcc2cb --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.prototype.until +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.PlainYearMonth(2000, 5, calendar); + +assert.throws(RangeError, () => instance.until(arg)); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/with/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/with/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..18f1e5591a --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/with/constructor-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.prototype.with +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const ym = new Temporal.PlainYearMonth(2023, 5, calendar); + +assert.throws(RangeError, () => ym.with({month: 1})); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/with/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/with/duplicate-calendar-fields.js new file mode 100644 index 0000000000..7acea42172 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/with/duplicate-calendar-fields.js @@ -0,0 +1,15 @@ +// 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.prototype.with +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['monthCode'], ['month'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const ym = new Temporal.PlainYearMonth(2023, 5, calendar); + + assert.throws(RangeError, () => ym.with({month: 1})); +} diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/with/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/with/proto-in-calendar-fields.js new file mode 100644 index 0000000000..cace4f11fa --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/with/proto-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.prototype.with +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const ym = new Temporal.PlainYearMonth(2023, 5, calendar); + +assert.throws(RangeError, () => ym.with({month: 1})); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/constructor-in-calendar-fields.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..cecf13fbc5 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.timezone.prototype.getinstantfor +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.TimeZone("UTC"); + +assert.throws(RangeError, () => instance.getInstantFor(arg)); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/duplicate-calendar-fields.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/duplicate-calendar-fields.js new file mode 100644 index 0000000000..9b686411ff --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.timezone.prototype.getinstantfor +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['hour'], ['microsecond'], ['millisecond'], ['minute'], ['month'], ['monthCode'], ['nanosecond'], ['second'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.TimeZone("UTC"); + + assert.throws(RangeError, () => instance.getInstantFor(arg)); +} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/proto-in-calendar-fields.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/proto-in-calendar-fields.js new file mode 100644 index 0000000000..4579bff80e --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.timezone.prototype.getinstantfor +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.TimeZone("UTC"); + +assert.throws(RangeError, () => instance.getInstantFor(arg)); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/constructor-in-calendar-fields.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..5bc24ee6d3 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.timezone.prototype.getpossibleinstantsfor +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.TimeZone("UTC"); + +assert.throws(RangeError, () => instance.getPossibleInstantsFor(arg)); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/duplicate-calendar-fields.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/duplicate-calendar-fields.js new file mode 100644 index 0000000000..3b6e5f57f8 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.timezone.prototype.getpossibleinstantsfor +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['hour'], ['microsecond'], ['millisecond'], ['minute'], ['month'], ['monthCode'], ['nanosecond'], ['second'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.TimeZone("UTC"); + + assert.throws(RangeError, () => instance.getPossibleInstantsFor(arg)); +} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/proto-in-calendar-fields.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/proto-in-calendar-fields.js new file mode 100644 index 0000000000..9c2c1c3241 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.timezone.prototype.getpossibleinstantsfor +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.TimeZone("UTC"); + +assert.throws(RangeError, () => instance.getPossibleInstantsFor(arg)); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/constructor-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/compare/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..3788d16b3a --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/compare/constructor-in-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.zoneddatetime.prototype.compare +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const timeZone = 'Europe/Paris' +const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; +const datetime = Temporal.ZonedDateTime.from({ year: 2023, month: 5, monthCode: 'M05', day: 15, timeZone: 'Europe/Paris' }); + +assert.throws(RangeError, () => Temporal.ZonedDateTime.compare(arg, datetime)); +assert.throws(RangeError, () => Temporal.ZonedDateTime.compare(datetime, arg)); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/duplicate-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/compare/duplicate-calendar-fields.js new file mode 100644 index 0000000000..817ea785f0 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/compare/duplicate-calendar-fields.js @@ -0,0 +1,19 @@ +// 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.zoneddatetime.prototype.compare +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + + +for (const extra_fields of [['foo', 'foo'], ['day'], ['hour'], ['microsecond'], ['millisecond'], ['minute'], ['month'], ['monthCode'], ['nanosecond'], ['second'], ['year'], ['timeZone'], ['offset']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const timeZone = 'Europe/Paris' + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; + const datetime = Temporal.ZonedDateTime.from({year: 2023, month: 5, monthCode: 'M05', day: 15, timeZone: 'Europe/Paris'}); + + assert.throws(RangeError, () => Temporal.ZonedDateTime.compare(arg, datetime)); + assert.throws(RangeError, () => Temporal.ZonedDateTime.compare(datetime, arg)); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/proto-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/compare/proto-in-calendar-fields.js new file mode 100644 index 0000000000..c9c485eb35 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/compare/proto-in-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.zoneddatetime.prototype.compare +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const timeZone = 'Europe/Paris' +const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; +const datetime = Temporal.ZonedDateTime.from({ year: 2023, month: 5, monthCode: 'M05', day: 15, timeZone: 'Europe/Paris' }); + +assert.throws(RangeError, () => Temporal.ZonedDateTime.compare(arg, datetime)); +assert.throws(RangeError, () => Temporal.ZonedDateTime.compare(datetime, arg)); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/constructor-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/from/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..520b3042ed --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/from/constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.zoneddatetime.prototype.from +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const timeZone = 'Europe/Paris' +const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; + +assert.throws(RangeError, () => Temporal.ZonedDateTime.from(arg)); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/duplicate-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/from/duplicate-calendar-fields.js new file mode 100644 index 0000000000..9af871f423 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/from/duplicate-calendar-fields.js @@ -0,0 +1,17 @@ +// 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.zoneddatetime.prototype.from +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + + +for (const extra_fields of [['foo', 'foo'], ['day'], ['hour'], ['microsecond'], ['millisecond'], ['minute'], ['month'], ['monthCode'], ['nanosecond'], ['second'], ['year'], ['timeZone'], ['offset']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const timeZone = 'Europe/Paris' + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; + + assert.throws(RangeError, () => Temporal.ZonedDateTime.from(arg)); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/from/proto-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/from/proto-in-calendar-fields.js new file mode 100644 index 0000000000..8683b2057f --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/from/proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.zoneddatetime.prototype.from +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const timeZone = 'Europe/Paris' +const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; + +assert.throws(RangeError, () => Temporal.ZonedDateTime.from(arg)); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/constructor-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..c353bbb70d --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/constructor-in-calendar-fields.js @@ -0,0 +1,15 @@ +// 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.zoneddatetime.prototype.equals +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const timeZone = 'Europe/Paris' +const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +assert.throws(RangeError, () => instance.equals(arg)); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/duplicate-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/duplicate-calendar-fields.js new file mode 100644 index 0000000000..1bceadc5ca --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/duplicate-calendar-fields.js @@ -0,0 +1,17 @@ +// 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.zoneddatetime.prototype.equals +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['hour'], ['microsecond'], ['millisecond'], ['minute'], ['month'], ['monthCode'], ['nanosecond'], ['second'], ['year'], ['timeZone'], ['offset']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const timeZone = 'Europe/Paris' + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; + const instance = new Temporal.ZonedDateTime(0n, timeZone); + + assert.throws(RangeError, () => instance.equals(arg)); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/proto-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/proto-in-calendar-fields.js new file mode 100644 index 0000000000..72df1a3def --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/proto-in-calendar-fields.js @@ -0,0 +1,15 @@ +// 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.zoneddatetime.prototype.equals +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const timeZone = 'Europe/Paris' +const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +assert.throws(RangeError, () => instance.equals(arg)); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/constructor-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..b91c1f7386 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/constructor-in-calendar-fields.js @@ -0,0 +1,15 @@ +// 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.zoneddatetime.prototype.since +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const timeZone = 'Europe/Paris' +const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +assert.throws(RangeError, () => instance.since(arg)); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/duplicate-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/duplicate-calendar-fields.js new file mode 100644 index 0000000000..bdd842fa3a --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/duplicate-calendar-fields.js @@ -0,0 +1,17 @@ +// 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.zoneddatetime.prototype.since +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['hour'], ['microsecond'], ['millisecond'], ['minute'], ['month'], ['monthCode'], ['nanosecond'], ['second'], ['year'], ['timeZone'], ['offset']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const timeZone = 'Europe/Paris' + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; + const instance = new Temporal.ZonedDateTime(0n, timeZone); + + assert.throws(RangeError, () => instance.since(arg)); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/proto-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/proto-in-calendar-fields.js new file mode 100644 index 0000000000..a8e540675b --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/proto-in-calendar-fields.js @@ -0,0 +1,15 @@ +// 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.zoneddatetime.prototype.since +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const timeZone = 'Europe/Paris' +const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +assert.throws(RangeError, () => instance.since(arg)); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/constructor-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..14b0a742fa --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/constructor-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.zoneddatetime.prototype.toplainmonthday +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const zoneddatetime = new Temporal.ZonedDateTime(1682892000000000000n, 'Europe/Madrid', calendar); + +assert.throws(RangeError, () => zoneddatetime.toPlainMonthDay()); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/duplicate-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/duplicate-calendar-fields.js new file mode 100644 index 0000000000..2321c14d2c --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/duplicate-calendar-fields.js @@ -0,0 +1,15 @@ +// 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.zoneddatetime.prototype.toplainmonthday +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['monthCode'], ['day']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const zoneddatetime = new Temporal.ZonedDateTime(1682892000000000000n, 'Europe/Madrid', calendar); + + assert.throws(RangeError, () => zoneddatetime.toPlainMonthDay()); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/proto-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/proto-in-calendar-fields.js new file mode 100644 index 0000000000..057adfd893 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/proto-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.zoneddatetime.prototype.toplainmonthday +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const zoneddatetime = new Temporal.ZonedDateTime(1682892000000000000n, 'Europe/Madrid', calendar); + +assert.throws(RangeError, () => zoneddatetime.toPlainMonthDay()); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/constructor-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..6fe0dd5e1d --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/constructor-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.zoneddatetime.prototype.toplainyearmonth +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const zoneddatetime = new Temporal.ZonedDateTime(1682892000000000000n, 'Europe/Madrid', calendar); + +assert.throws(RangeError, () => zoneddatetime.toPlainYearMonth()); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/duplicate-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/duplicate-calendar-fields.js new file mode 100644 index 0000000000..3592083aac --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/duplicate-calendar-fields.js @@ -0,0 +1,15 @@ +// 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.zoneddatetime.prototype.toplainyearmonth +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const zoneddatetime = new Temporal.ZonedDateTime(1682892000000000000n, 'Europe/Madrid', calendar); + + assert.throws(RangeError, () => zoneddatetime.toPlainYearMonth()); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/proto-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/proto-in-calendar-fields.js new file mode 100644 index 0000000000..97b7ef2ceb --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/proto-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.zoneddatetime.prototype.toplainyearmonth +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const zoneddatetime = new Temporal.ZonedDateTime(1682892000000000000n, 'Europe/Madrid', calendar); + +assert.throws(RangeError, () => zoneddatetime.toPlainYearMonth()); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/constructor-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..7bc0a72b86 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/constructor-in-calendar-fields.js @@ -0,0 +1,15 @@ +// 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.zoneddatetime.prototype.until +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const timeZone = 'Europe/Paris' +const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +assert.throws(RangeError, () => instance.until(arg)); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/duplicate-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/duplicate-calendar-fields.js new file mode 100644 index 0000000000..a84eba429d --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/duplicate-calendar-fields.js @@ -0,0 +1,17 @@ +// 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.zoneddatetime.prototype.until +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['hour'], ['microsecond'], ['millisecond'], ['minute'], ['month'], ['monthCode'], ['nanosecond'], ['second'], ['year'], ['timeZone'], ['offset']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const timeZone = 'Europe/Paris' + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; + const instance = new Temporal.ZonedDateTime(0n, timeZone); + + assert.throws(RangeError, () => instance.until(arg)); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/proto-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/proto-in-calendar-fields.js new file mode 100644 index 0000000000..1ed94b4b87 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/proto-in-calendar-fields.js @@ -0,0 +1,15 @@ +// 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.zoneddatetime.prototype.until +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const timeZone = 'Europe/Paris' +const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +assert.throws(RangeError, () => instance.until(arg)); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/constructor-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/constructor-in-calendar-fields.js new file mode 100644 index 0000000000..904c2fb37b --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/with/constructor-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.zoneddatetime.prototype.with +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const zoneddatetime = new Temporal.ZonedDateTime(1682892000000000000n, 'Europe/Madrid', calendar); + +assert.throws(RangeError, () => zoneddatetime.with({hour: 12})); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/duplicate-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/duplicate-calendar-fields.js new file mode 100644 index 0000000000..e8e2f34545 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/with/duplicate-calendar-fields.js @@ -0,0 +1,15 @@ +// 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.zoneddatetime.prototype.with +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['monthCode'], ['day'], ['hour'], ['microsecond'], ['millisecond'], ['minute'], ['month'], ['nanosecond'], ['second'], ['year'], ['offset']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const zoneddatetime = new Temporal.ZonedDateTime(1682892000000000000n, 'Europe/Madrid', calendar); + + assert.throws(RangeError, () => zoneddatetime.with({hour: 12})); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/proto-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/proto-in-calendar-fields.js new file mode 100644 index 0000000000..7a5e30265a --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/with/proto-in-calendar-fields.js @@ -0,0 +1,13 @@ +// 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.zoneddatetime.prototype.with +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const zoneddatetime = new Temporal.ZonedDateTime(1682892000000000000n, 'Europe/Madrid', calendar); + +assert.throws(RangeError, () => zoneddatetime.with({hour: 12})); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-constructor-in-calendar-fields.js new file mode 100644 index 0000000000..1451aaa816 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.zoneddatetime.prototype.withplaindate +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); + +assert.throws(RangeError, () => instance.withPlainDate(arg)); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-duplicate-calendar-fields.js new file mode 100644 index 0000000000..0426ed60a9 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.zoneddatetime.prototype.withplaindate +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); + + assert.throws(RangeError, () => instance.withPlainDate(arg)); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-proto-in-calendar-fields.js new file mode 100644 index 0000000000..78eb025e79 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.zoneddatetime.prototype.withplaindate +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); + +assert.throws(RangeError, () => instance.withPlainDate(arg)); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-constructor-in-calendar-fields.js b/test/intl402/Temporal/Calendar/prototype/era/argument-constructor-in-calendar-fields.js new file mode 100644 index 0000000000..712d00399d --- /dev/null +++ b/test/intl402/Temporal/Calendar/prototype/era/argument-constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.era +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.era(arg)); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-duplicate-calendar-fields.js b/test/intl402/Temporal/Calendar/prototype/era/argument-duplicate-calendar-fields.js new file mode 100644 index 0000000000..2b8536da12 --- /dev/null +++ b/test/intl402/Temporal/Calendar/prototype/era/argument-duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.calendar.prototype.era +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.Calendar("iso8601"); + + assert.throws(RangeError, () => instance.era(arg)); +} diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-proto-in-calendar-fields.js b/test/intl402/Temporal/Calendar/prototype/era/argument-proto-in-calendar-fields.js new file mode 100644 index 0000000000..c31d3171a3 --- /dev/null +++ b/test/intl402/Temporal/Calendar/prototype/era/argument-proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.era +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.era(arg)); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-constructor-in-calendar-fields.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-constructor-in-calendar-fields.js new file mode 100644 index 0000000000..fca8011afe --- /dev/null +++ b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-constructor-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.erayear +description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.eraYear(arg)); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-duplicate-calendar-fields.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-duplicate-calendar-fields.js new file mode 100644 index 0000000000..50a64c8a3b --- /dev/null +++ b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-duplicate-calendar-fields.js @@ -0,0 +1,16 @@ +// 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.calendar.prototype.erayear +description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { + const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); + const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; + const instance = new Temporal.Calendar("iso8601"); + + assert.throws(RangeError, () => instance.eraYear(arg)); +} diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-proto-in-calendar-fields.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-proto-in-calendar-fields.js new file mode 100644 index 0000000000..37e03e67d0 --- /dev/null +++ b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-proto-in-calendar-fields.js @@ -0,0 +1,14 @@ +// 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.calendar.prototype.erayear +description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); +const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => instance.eraYear(arg));