From 56e537b9161fed58d80a953b02ac54461fffde99 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Wed, 29 Sep 2021 13:25:31 -0700 Subject: [PATCH] Consolidate duplicate tests There were a few tests already in the tree that overlapped ones that I added in the previous commit. I've consolidated these and taken information from the deleted ones where applicable, and improved on the autogenerated assertion messages. --- .../dateAdd/overflow-invalid-string.js | 6 ++++-- ...row-range-error-from-ToTemporalOverflow.js | 15 --------------- .../dateFromFields/fields-not-object.js | 12 +++++++++--- .../dateFromFields/overflow-invalid-string.js | 6 ++++-- ...hrow-range-error-from-ISODateFromFields.js | 14 -------------- .../throw-type-error-fields-is-not-object.js | 19 ------------------- 6 files changed, 17 insertions(+), 55 deletions(-) delete mode 100644 test/built-ins/Temporal/Calendar/prototype/dateAdd/throw-range-error-from-ToTemporalOverflow.js delete mode 100644 test/built-ins/Temporal/Calendar/prototype/dateFromFields/throw-range-error-from-ISODateFromFields.js delete mode 100644 test/built-ins/Temporal/Calendar/prototype/dateFromFields/throw-type-error-fields-is-not-object.js diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/overflow-invalid-string.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/overflow-invalid-string.js index 004385da73a..3197c54007c 100644 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/overflow-invalid-string.js +++ b/test/built-ins/Temporal/Calendar/prototype/dateAdd/overflow-invalid-string.js @@ -11,10 +11,12 @@ info: | 1. Return ? GetOption(_normalizedOptions_, *"overflow"*, « String », « *"constrain"*, *"reject"* », *"constrain"*). sec-temporal.calendar.prototype.dateadd step 7: 7. Let _overflow_ be ? ToTemporalOverflow(_options_). -features: [Temporal] +features: [Temporal, arrow-function] ---*/ const calendar = new Temporal.Calendar("iso8601"); const date = new Temporal.PlainDate(2000, 5, 2, calendar); const duration = new Temporal.Duration(3, 3, 0, 3); -assert.throws(RangeError, () => calendar.dateAdd(date, duration, { overflow: "other string" })); +assert.throws(RangeError, + () => calendar.dateAdd(date, duration, { overflow: "other string" }), + "Value for overflow not one of the allowed string values"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/throw-range-error-from-ToTemporalOverflow.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/throw-range-error-from-ToTemporalOverflow.js deleted file mode 100644 index d922bd57acf..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/throw-range-error-from-ToTemporalOverflow.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Temporal.Calendar.prototype.dateAdd should throw from ToTemporalOverflow. -info: | - 7. Let overflow be ? ToTemporalOverflow(options). -features: [Temporal, arrow-function] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, - () => cal.dateAdd("2020-02-29", "PT1M", {overflow: "bad value"}), - 'cal.dateAdd("2020-02-29", "PT1M", {overflow: "bad value"}) throws a RangeError exception'); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/fields-not-object.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/fields-not-object.js index 97ce2e33433..68224ebe2c6 100644 --- a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/fields-not-object.js +++ b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/fields-not-object.js @@ -4,11 +4,17 @@ /*--- esid: sec-temporal.calendar.prototype.datefromfields description: Throw a TypeError if the fields is not an object -features: [Symbol, Temporal] +info: | + 4. If Type(_fields_) is not Object, throw a *TypeError* exception. +features: [BigInt, Symbol, Temporal, arrow-function] ---*/ -const tests = [undefined, null, false, "string", Symbol("sym"), Math.PI, 42n]; +const tests = [undefined, null, true, false, "string", Symbol("sym"), Infinity, NaN, Math.PI, 42n]; const iso = Temporal.Calendar.from("iso8601"); for (const fields of tests) { - assert.throws(TypeError, () => iso.dateFromFields(fields, {})); + assert.throws( + TypeError, + () => iso.dateFromFields(fields, {}) + `dateFromFields(${typeof fields}) throws a TypeError exception` + ); } diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/overflow-invalid-string.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/overflow-invalid-string.js index 76bdfc89821..6cc0d01724d 100644 --- a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/overflow-invalid-string.js +++ b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/overflow-invalid-string.js @@ -13,8 +13,10 @@ info: | 2. Let _overflow_ be ? ToTemporalOverflow(_options_). sec-temporal.calendar.prototype.datefromfields step 6: 6. Let _result_ be ? ISODateFromFields(_fields_, _options_). -features: [Temporal] +features: [Temporal, arrow-function] ---*/ const calendar = new Temporal.Calendar("iso8601"); -assert.throws(RangeError, () => calendar.dateFromFields({ year: 2000, month: 5, day: 2 }, { overflow: "other string" })); +assert.throws(RangeError, () => calendar.dateFromFields({ year: 2000, month: 5, day: 2 }, + { overflow: "other string" }), + "Value for overflow not one of the allowed string values"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/throw-range-error-from-ISODateFromFields.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/throw-range-error-from-ISODateFromFields.js deleted file mode 100644 index b1bbfc53759..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/throw-range-error-from-ISODateFromFields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.datefromfields -description: Temporal.Calendar.prototype.dateFromFields should throw Error from ISODateFromFields. -info: | - 6. Let result be ? ISODateFromFields(fields, options). -features: [Temporal, arrow-function] ----*/ -let cal = new Temporal.Calendar("iso8601") - -assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 7, day: 20}, - {overflow: "invalid garbage"}), - 'cal.dateFromFields({year: 2021, month: 7, day: 20}, {overflow: "invalid garbage"}) throws a RangeError exception'); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/throw-type-error-fields-is-not-object.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/throw-type-error-fields-is-not-object.js deleted file mode 100644 index 13b8357f492..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/throw-type-error-fields-is-not-object.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.datefromfields -description: Temporal.Calendar.prototype.dateFromFields should throw TypeError while fields is not object. -info: | - 4. If Type(fields) is not Object, throw a TypeError exception. -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ -let cal = new Temporal.Calendar('iso8601'); -let notObjectList = [null, undefined, 'string', Symbol('efg'), true, false, Infinity, NaN, 123, 456n]; - -notObjectList.forEach(function(fields) { - assert.throws( - TypeError, - () => cal.dateFromFields(fields), - 'cal.dateFromFields(fields) throws a TypeError exception' - ); -});