From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- ...tive-duration-formatToParts-style-default-en.js | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-default-en.js (limited to 'js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-default-en.js') diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-default-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-default-en.js new file mode 100644 index 0000000000..bfc182c34b --- /dev/null +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-default-en.js @@ -0,0 +1,50 @@ +// |reftest| skip -- Intl.DurationFormat is not supported +// Copyright (C) 2023 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat.prototype.formatToParts +description: > + Test formatToParts method with negative duration and default style +locale: [en-US] +includes: [testIntl.js] +features: [Intl.DurationFormat] +---*/ + +function compare(actual, expected, message) { + assert.sameValue(Array.isArray(expected), true, `${message}: expected is Array`); + assert.sameValue(Array.isArray(actual), true, `${message}: actual is Array`); + assert.sameValue(actual.length, expected.length, `${message}: length`); + + for (let i = 0; i < expected.length; ++i) { + let actualEntry = actual[i]; + let expectedEntry = expected[i]; + + assert.sameValue(actualEntry.type, expectedEntry.type, `type for entry ${i}`); + assert.sameValue(actualEntry.value, expectedEntry.value, `value for entry ${i}`); + assert.sameValue("unit" in actualEntry, "unit" in expectedEntry, `unit for entry ${i}`); + if ("unit" in expectedEntry) { + assert.sameValue(actualEntry.unit, expectedEntry.unit, `unit for entry ${i}`); + } + } +} + +const duration = { + years: -1, + months: -2, + weeks: -3, + days: -4, + hours: -5, + minutes: -6, + seconds: -7, + milliseconds: -123, + microseconds: -456, + nanoseconds: -789, +}; + +const expected = partitionDurationFormatPattern(duration); + +const df = new Intl.DurationFormat("en"); +compare(df.formatToParts(duration), expected, `Using style : default`); + +reportCompare(0, 0); -- cgit v1.2.3