From 79591ae6c8f13f5c558576ad58846d80f33d0f0e Mon Sep 17 00:00:00 2001 From: Frank Yung-Fong Tang <41213225+FrankYFTang@users.noreply.github.com> Date: Tue, 8 Oct 2019 11:54:02 -0700 Subject: [PATCH] Add test for #349 and #351 PR (#2379) Test DateTimeFormat change pattern based on calendar and output relatedYear and yearName based on the assumption that "en-u-ca-chinese" will output 'relatedYear' and 'yearName'. https://github.com/tc39/ecma402/pull/349 https://github.com/tc39/ecma402/pull/351 @rwaldron @leobalter @Ms2ger @littledan --- .../prototype/formatToParts/related-year.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test/intl402/DateTimeFormat/prototype/formatToParts/related-year.js diff --git a/test/intl402/DateTimeFormat/prototype/formatToParts/related-year.js b/test/intl402/DateTimeFormat/prototype/formatToParts/related-year.js new file mode 100644 index 0000000000..4f01d98c2d --- /dev/null +++ b/test/intl402/DateTimeFormat/prototype/formatToParts/related-year.js @@ -0,0 +1,20 @@ +// Copyright 2019 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-partitiondatetimepattern +description: Checks the output of 'relatedYear' and 'yearName' type, and + the choose of pattern base on calendar. +locale: [en-u-ca-chinese] +---*/ + +let df = new Intl.DateTimeFormat("en-u-ca-chinese", {year: "numeric"}); +let parts = df.formatToParts(new Date()); +var relatedYearCount = 0; +var yearNameCount = 0; +parts.forEach(function(part) { + relatedYearCount += (part.type == "relatedYear") ? 1 : 0; + yearNameCount += (part.type == "yearName") ? 1 : 0; +}); +assert.sameValue(relatedYearCount > 0, true); +assert.sameValue(yearNameCount > 0, true);