diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-invalid.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-invalid.js new file mode 100644 index 0000000000..489eba1d68 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-invalid.js @@ -0,0 +1,15 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.prototype.equals +description: An invalid ISO string is never supported +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainMonthDay(11, 18); + +for (const arg of TemporalHelpers.ISO.plainMonthDayStringsInvalid()) { + assert.throws(RangeError, () => instance.equals(arg), `"${arg}" is not a valid PlainMonthDay string`); +} diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string.js new file mode 100644 index 0000000000..f56b14cf93 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string.js @@ -0,0 +1,15 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.prototype.equals +description: A string argument is parsed into a PlainMonthDay +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainMonthDay(10, 1); +for (const arg of TemporalHelpers.ISO.plainMonthDayStringsValid()) { + const result = instance.equals(arg); + assert.sameValue(result, true, `"${arg}" is a valid PlainMonthDay string`); +} diff --git a/test/built-ins/Temporal/PlainYearMonth/compare/argument-string-invalid.js b/test/built-ins/Temporal/PlainYearMonth/compare/argument-string-invalid.js new file mode 100644 index 0000000000..57e79cbf57 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/compare/argument-string-invalid.js @@ -0,0 +1,15 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.compare +description: An invalid ISO string is never supported +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const arg2 = new Temporal.PlainYearMonth(1976, 11); +for (const arg of TemporalHelpers.ISO.plainYearMonthStringsInvalid()) { + assert.throws(RangeError, () => Temporal.PlainYearMonth.compare(arg, arg2), `"${arg}" is invalid (first argument)`); + assert.throws(RangeError, () => Temporal.PlainYearMonth.compare(arg2, arg), `"${arg}" is invalid (second argument)`); +} diff --git a/test/built-ins/Temporal/PlainYearMonth/compare/argument-string.js b/test/built-ins/Temporal/PlainYearMonth/compare/argument-string.js new file mode 100644 index 0000000000..e986932880 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/compare/argument-string.js @@ -0,0 +1,19 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.compare +description: A string is parsed into the correct object when passed as the argument +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const validStrings = TemporalHelpers.ISO.plainYearMonthStringsValid().concat(TemporalHelpers.ISO.plainYearMonthStringsValidNegativeYear()); + +for (const arg of validStrings) { + assert.sameValue( + Temporal.PlainYearMonth.compare(arg, arg), + 0, + `"${arg}" is a valid PlainYearMonth string` + ); +} diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-invalid.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-invalid.js new file mode 100644 index 0000000000..4ccc23cbff --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-invalid.js @@ -0,0 +1,15 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.equals +description: An invalid ISO string is never supported +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainYearMonth(1976, 11); + +for (const arg of TemporalHelpers.ISO.plainYearMonthStringsInvalid()) { + assert.throws(RangeError, () => instance.equals(arg), `"${arg}" is not a valid PlainYearMonth string`); +} diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string.js new file mode 100644 index 0000000000..1980803895 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string.js @@ -0,0 +1,21 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.equals +description: A string argument is parsed into a PlainYearMonth +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainYearMonth(1976, 11); +for (const arg of TemporalHelpers.ISO.plainYearMonthStringsValid()) { + const result = instance.equals(arg); + assert.sameValue(result, true, `"${arg}" is a valid PlainYearMonth string`); +} + +const instanceNegativeYear = new Temporal.PlainYearMonth(-9999, 11); +for (const arg of TemporalHelpers.ISO.plainYearMonthStringsValidNegativeYear()) { + const result = instanceNegativeYear.equals(arg); + assert.sameValue(result, true, `"${arg}" is a valid PlainYearMonth string`); +} diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-invalid.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-invalid.js new file mode 100644 index 0000000000..6a66608ba9 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-invalid.js @@ -0,0 +1,15 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.since +description: An invalid ISO string is never supported +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainYearMonth(1976, 11); + +for (const arg of TemporalHelpers.ISO.plainYearMonthStringsInvalid()) { + assert.throws(RangeError, () => instance.since(arg), `"${arg}" is not a valid PlainYearMonth string`); +} diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string.js new file mode 100644 index 0000000000..48735abd8e --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string.js @@ -0,0 +1,21 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.since +description: A string argument is parsed into a PlainYearMonth +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainYearMonth(1976, 11); +for (const arg of TemporalHelpers.ISO.plainYearMonthStringsValid()) { + const result = instance.since(arg); + TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, `"${arg}" is a valid PlainYearMonth string`); +} + +const instanceNegativeYear = new Temporal.PlainYearMonth(-9999, 11); +for (const arg of TemporalHelpers.ISO.plainYearMonthStringsValidNegativeYear()) { + const result = instanceNegativeYear.since(arg); + TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, `"${arg}" is a valid PlainYearMonth string`); +} diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-invalid.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-invalid.js new file mode 100644 index 0000000000..b7707dd823 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-invalid.js @@ -0,0 +1,15 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.until +description: An invalid ISO string is never supported +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainYearMonth(1976, 11); + +for (const arg of TemporalHelpers.ISO.plainYearMonthStringsInvalid()) { + assert.throws(RangeError, () => instance.until(arg), `"${arg}" is not a valid PlainYearMonth string`); +} diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string.js new file mode 100644 index 0000000000..161ad1e030 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string.js @@ -0,0 +1,21 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.until +description: A string argument is parsed into a PlainYearMonth +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainYearMonth(1976, 11); +for (const arg of TemporalHelpers.ISO.plainYearMonthStringsValid()) { + const result = instance.until(arg); + TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, `"${arg}" is a valid PlainYearMonth string`); +} + +const instanceNegativeYear = new Temporal.PlainYearMonth(-9999, 11); +for (const arg of TemporalHelpers.ISO.plainYearMonthStringsValidNegativeYear()) { + const result = instanceNegativeYear.until(arg); + TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, `"${arg}" is a valid PlainYearMonth string`); +}