From e1048d0afff177ebe1d8aa0e9ced13702470f47f Mon Sep 17 00:00:00 2001 From: Aditi Date: Wed, 4 Jan 2023 16:23:49 +0530 Subject: [PATCH] Update Temporal test262 as per the normative changes --- test/built-ins/Temporal/PlainDate/argument-convert.js | 11 +++++------ .../prototype/year/validate-calendar-value.js | 6 +++--- .../prototype/yearOfWeek/validate-calendar-value.js | 6 +++--- .../prototype/year/validate-calendar-value.js | 6 +++--- .../prototype/yearOfWeek/validate-calendar-value.js | 6 +++--- .../prototype/year/validate-calendar-value.js | 6 +++--- .../prototype/year/validate-calendar-value.js | 6 +++--- .../prototype/yearOfWeek/validate-calendar-value.js | 6 +++--- 8 files changed, 26 insertions(+), 27 deletions(-) diff --git a/test/built-ins/Temporal/PlainDate/argument-convert.js b/test/built-ins/Temporal/PlainDate/argument-convert.js index 0e00a1278e..5e99117c29 100644 --- a/test/built-ins/Temporal/PlainDate/argument-convert.js +++ b/test/built-ins/Temporal/PlainDate/argument-convert.js @@ -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"); @@ -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"), diff --git a/test/built-ins/Temporal/PlainDate/prototype/year/validate-calendar-value.js b/test/built-ins/Temporal/PlainDate/prototype/year/validate-calendar-value.js index fe99fa065a..f218b25709 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/year/validate-calendar-value.js +++ b/test/built-ins/Temporal/PlainDate/prototype/year/validate-calendar-value.js @@ -13,6 +13,9 @@ const badResults = [ [-Infinity, RangeError], [Symbol("foo"), TypeError], [7n, TypeError], + [NaN, RangeError], + ["string", RangeError], + [{}, RangeError], ]; badResults.forEach(([result, error]) => { @@ -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], ]; diff --git a/test/built-ins/Temporal/PlainDate/prototype/yearOfWeek/validate-calendar-value.js b/test/built-ins/Temporal/PlainDate/prototype/yearOfWeek/validate-calendar-value.js index 0f1c3a0664..f2c69dbe6c 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/yearOfWeek/validate-calendar-value.js +++ b/test/built-ins/Temporal/PlainDate/prototype/yearOfWeek/validate-calendar-value.js @@ -13,6 +13,9 @@ const badResults = [ [-Infinity, RangeError], [Symbol("foo"), TypeError], [7n, TypeError], + [NaN, RangeError], + ["string", RangeError], + [{}, RangeError], ]; badResults.forEach(([result, error]) => { @@ -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], ]; diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/year/validate-calendar-value.js b/test/built-ins/Temporal/PlainDateTime/prototype/year/validate-calendar-value.js index 419206028c..64f9964ad2 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/year/validate-calendar-value.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/year/validate-calendar-value.js @@ -13,6 +13,9 @@ const badResults = [ [-Infinity, RangeError], [Symbol("foo"), TypeError], [7n, TypeError], + [NaN, RangeError], + ["string", RangeError], + [{}, RangeError], ]; badResults.forEach(([result, error]) => { @@ -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], ]; diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/validate-calendar-value.js b/test/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/validate-calendar-value.js index af4f1debf8..a0c6456d58 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/validate-calendar-value.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/validate-calendar-value.js @@ -13,6 +13,9 @@ const badResults = [ [-Infinity, RangeError], [Symbol("foo"), TypeError], [7n, TypeError], + [NaN, RangeError], + ["string", RangeError], + [{}, RangeError], ]; badResults.forEach(([result, error]) => { @@ -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], ]; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/year/validate-calendar-value.js b/test/built-ins/Temporal/PlainYearMonth/prototype/year/validate-calendar-value.js index b8a514f590..6f6437aa15 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/year/validate-calendar-value.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/year/validate-calendar-value.js @@ -13,6 +13,9 @@ const badResults = [ [-Infinity, RangeError], [Symbol("foo"), TypeError], [7n, TypeError], + [NaN, RangeError], + ["string", RangeError], + [{}, RangeError], ]; badResults.forEach(([result, error]) => { @@ -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], ]; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/year/validate-calendar-value.js b/test/built-ins/Temporal/ZonedDateTime/prototype/year/validate-calendar-value.js index bf859f7b66..00b619fd23 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/year/validate-calendar-value.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/year/validate-calendar-value.js @@ -13,6 +13,9 @@ const badResults = [ [-Infinity, RangeError], [Symbol("foo"), TypeError], [7n, TypeError], + [NaN, RangeError], + ["string", RangeError], + [{}, RangeError], ]; badResults.forEach(([result, error]) => { @@ -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], ]; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/validate-calendar-value.js b/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/validate-calendar-value.js index 8777551d4b..cceb1dad18 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/validate-calendar-value.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/validate-calendar-value.js @@ -13,6 +13,9 @@ const badResults = [ [-Infinity, RangeError], [Symbol("foo"), TypeError], [7n, TypeError], + [NaN, RangeError], + ["string", RangeError], + [{}, RangeError], ]; badResults.forEach(([result, error]) => { @@ -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], ];