From 06ced3f8123b578b6cf495113b2b96d3d40d1d57 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Tue, 18 Jan 2022 15:35:02 -0800 Subject: [PATCH] Add forgotten PlainDate tests I forgot to add these to PlainDate, testing what happens when we pass undefined as the value for the largestUnit option. Similar tests already exist for the other types. --- .../prototype/since/largestunit-undefined.js | 17 +++++++++++++++++ .../prototype/until/largestunit-undefined.js | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 test/built-ins/Temporal/PlainDate/prototype/since/largestunit-undefined.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/until/largestunit-undefined.js diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/largestunit-undefined.js b/test/built-ins/Temporal/PlainDate/prototype/since/largestunit-undefined.js new file mode 100644 index 0000000000..2db2928705 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/since/largestunit-undefined.js @@ -0,0 +1,17 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.since +description: Fallback value for largestUnit option +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const earlier = new Temporal.PlainDate(2000, 5, 2); +const later = new Temporal.PlainDate(2001, 6, 3); + +const explicit = later.since(earlier, { largestUnit: undefined }); +TemporalHelpers.assertDuration(explicit, 0, 0, 0, 397, 0, 0, 0, 0, 0, 0, "default largestUnit is day"); +const implicit = later.since(earlier, {}); +TemporalHelpers.assertDuration(implicit, 0, 0, 0, 397, 0, 0, 0, 0, 0, 0, "default largestUnit is day"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/largestunit-undefined.js b/test/built-ins/Temporal/PlainDate/prototype/until/largestunit-undefined.js new file mode 100644 index 0000000000..dd6acd17df --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/until/largestunit-undefined.js @@ -0,0 +1,17 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.until +description: Fallback value for largestUnit option +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const earlier = new Temporal.PlainDate(2000, 5, 2); +const later = new Temporal.PlainDate(2001, 6, 3); + +const explicit = earlier.until(later, { largestUnit: undefined }); +TemporalHelpers.assertDuration(explicit, 0, 0, 0, 397, 0, 0, 0, 0, 0, 0, "default largestUnit is day"); +const implicit = earlier.until(later, {}); +TemporalHelpers.assertDuration(implicit, 0, 0, 0, 397, 0, 0, 0, 0, 0, 0, "default largestUnit is day");