Skip to content

Commit

Permalink
Update Temporal test262 as per the normative changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditi-1400 authored and ptomato committed Jan 4, 2023
1 parent 09f863d commit e1048d0
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 27 deletions.
11 changes: 5 additions & 6 deletions test/built-ins/Temporal/PlainDate/argument-convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ TemporalHelpers.assertPlainDate(new Temporal.PlainDate(2020.6, 11.7, 24.1),
TemporalHelpers.assertPlainDate(new Temporal.PlainDate(-2020.6, 11.7, 24.1),
-2020, 11, "M11", 24, "negative fractional");

TemporalHelpers.assertPlainDate(new Temporal.PlainDate(undefined, 11, 24),
0, 11, "M11", 24, "undefined");

TemporalHelpers.assertPlainDate(new Temporal.PlainDate(null, 11, 24),
0, 11, "M11", 24, "null");

Expand All @@ -26,15 +23,17 @@ TemporalHelpers.assertPlainDate(new Temporal.PlainDate(true, 11, 24),
TemporalHelpers.assertPlainDate(new Temporal.PlainDate("2020.6", "11.7", "24.1"),
2020, 11, "M11", 24, "fractional strings");

TemporalHelpers.assertPlainDate(new Temporal.PlainDate("invalid", 11, 24),
0, 11, "M11", 24, "invalid string");

for (const invalid of [Symbol(), 1n]) {
assert.throws(TypeError, () => new Temporal.PlainDate(invalid, 11, 24), `year ${typeof invalid}`);
assert.throws(TypeError, () => new Temporal.PlainDate(2020, invalid, 24), `month ${typeof invalid}`);
assert.throws(TypeError, () => new Temporal.PlainDate(2020, 11, invalid), `day ${typeof invalid}`);
}

for (const invalid of [undefined, "invalid"]) {
assert.throws(RangeError, () => new Temporal.PlainDate(invalid, 11, 24), `year ${typeof invalid}`);
assert.throws(RangeError, () => new Temporal.PlainDate(2020, invalid, 24), `month ${typeof invalid}`);
assert.throws(RangeError, () => new Temporal.PlainDate(2020, 11, invalid), `day ${typeof invalid}`);
}
const actual = [];
const args = [
TemporalHelpers.toPrimitiveObserver(actual, 2020, "year"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const badResults = [
[-Infinity, RangeError],
[Symbol("foo"), TypeError],
[7n, TypeError],
[NaN, RangeError],
["string", RangeError],
[{}, RangeError],
];

badResults.forEach(([result, error]) => {
Expand All @@ -32,11 +35,8 @@ const convertedResults = [
[7.1, 7],
[-7, -7],
[-0.1, 0],
[NaN, 0],
["string", 0],
["7", 7],
["7.5", 7],
[{}, 0],
[{valueOf() { return 7; }}, 7],
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const badResults = [
[-Infinity, RangeError],
[Symbol("foo"), TypeError],
[7n, TypeError],
[NaN, RangeError],
["string", RangeError],
[{}, RangeError],
];

badResults.forEach(([result, error]) => {
Expand All @@ -32,11 +35,8 @@ const convertedResults = [
[7.1, 7],
[-7, -7],
[-0.1, 0],
[NaN, 0],
["string", 0],
["7", 7],
["7.5", 7],
[{}, 0],
[{valueOf() { return 7; }}, 7],
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const badResults = [
[-Infinity, RangeError],
[Symbol("foo"), TypeError],
[7n, TypeError],
[NaN, RangeError],
["string", RangeError],
[{}, RangeError],
];

badResults.forEach(([result, error]) => {
Expand All @@ -32,11 +35,8 @@ const convertedResults = [
[7.1, 7],
[-7, -7],
[-0.1, 0],
[NaN, 0],
["string", 0],
["7", 7],
["7.5", 7],
[{}, 0],
[{valueOf() { return 7; }}, 7],
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const badResults = [
[-Infinity, RangeError],
[Symbol("foo"), TypeError],
[7n, TypeError],
[NaN, RangeError],
["string", RangeError],
[{}, RangeError],
];

badResults.forEach(([result, error]) => {
Expand All @@ -32,11 +35,8 @@ const convertedResults = [
[7.1, 7],
[-7, -7],
[-0.1, 0],
[NaN, 0],
["string", 0],
["7", 7],
["7.5", 7],
[{}, 0],
[{valueOf() { return 7; }}, 7],
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const badResults = [
[-Infinity, RangeError],
[Symbol("foo"), TypeError],
[7n, TypeError],
[NaN, RangeError],
["string", RangeError],
[{}, RangeError],
];

badResults.forEach(([result, error]) => {
Expand All @@ -32,11 +35,8 @@ const convertedResults = [
[7.1, 7],
[-7, -7],
[-0.1, 0],
[NaN, 0],
["string", 0],
["7", 7],
["7.5", 7],
[{}, 0],
[{valueOf() { return 7; }}, 7],
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const badResults = [
[-Infinity, RangeError],
[Symbol("foo"), TypeError],
[7n, TypeError],
[NaN, RangeError],
["string", RangeError],
[{}, RangeError],
];

badResults.forEach(([result, error]) => {
Expand All @@ -32,11 +35,8 @@ const convertedResults = [
[7.1, 7],
[-7, -7],
[-0.1, 0],
[NaN, 0],
["string", 0],
["7", 7],
["7.5", 7],
[{}, 0],
[{valueOf() { return 7; }}, 7],
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const badResults = [
[-Infinity, RangeError],
[Symbol("foo"), TypeError],
[7n, TypeError],
[NaN, RangeError],
["string", RangeError],
[{}, RangeError],
];

badResults.forEach(([result, error]) => {
Expand All @@ -32,11 +35,8 @@ const convertedResults = [
[7.1, 7],
[-7, -7],
[-0.1, 0],
[NaN, 0],
["string", 0],
["7", 7],
["7.5", 7],
[{}, 0],
[{valueOf() { return 7; }}, 7],
];

Expand Down

0 comments on commit e1048d0

Please sign in to comment.