mirror of https://github.com/tc39/test262.git
Temporal: Expand PlainYearMonth and PlainMonthDay strings tests
Use the new collections of strings in TemporalHelpers.ISO to add more tests for ISO strings in API entry points that convert an ISO string to Temporal.PlainYearMonth or Temporal.PlainMonthDay.
This commit is contained in:
parent
7d0dde3635
commit
ec752ebaab
15
test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-invalid.js
vendored
Normal file
15
test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-invalid.js
vendored
Normal file
|
@ -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`);
|
||||
}
|
|
@ -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`);
|
||||
}
|
|
@ -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)`);
|
||||
}
|
|
@ -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`
|
||||
);
|
||||
}
|
15
test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-invalid.js
vendored
Normal file
15
test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-invalid.js
vendored
Normal file
|
@ -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`);
|
||||
}
|
|
@ -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`);
|
||||
}
|
15
test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-invalid.js
vendored
Normal file
15
test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-invalid.js
vendored
Normal file
|
@ -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`);
|
||||
}
|
|
@ -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`);
|
||||
}
|
15
test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-invalid.js
vendored
Normal file
15
test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-invalid.js
vendored
Normal file
|
@ -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`);
|
||||
}
|
|
@ -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`);
|
||||
}
|
Loading…
Reference in New Issue