Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: test/intl/date-format/calendar-with-multiple-type-subtags.js

Issue 2248563003: Support language tag extensions with multiple subtags for a key (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: add a real test for nu in presence of multiple type subtags for ca Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/js/i18n.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/intl/date-format/calendar-with-multiple-type-subtags.js
diff --git a/test/intl/date-format/calendar-with-multiple-type-subtags.js b/test/intl/date-format/calendar-with-multiple-type-subtags.js
new file mode 100644
index 0000000000000000000000000000000000000000..f4c00da61d3ab230dff6b51247d40243926fdfe2
--- /dev/null
+++ b/test/intl/date-format/calendar-with-multiple-type-subtags.js
@@ -0,0 +1,39 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var options = Intl.DateTimeFormat("ar-u-ca-islamic-civil").resolvedOptions();
+assertEquals(options.calendar, "islamic-civil");
+
+options = Intl.DateTimeFormat("ar-u-ca-islamic-umalqura").resolvedOptions();
+assertEquals(options.calendar, "islamic-umalqura");
+
+var options = Intl.DateTimeFormat("ar-u-ca-islamic-civil").resolvedOptions();
+assertEquals(options.calendar, "islamic-civil");
+
+options =
+ Intl.DateTimeFormat("ar-u-ca-islamic-civil-nu-arab").resolvedOptions();
+assertEquals(options.calendar, "islamic-civil");
+assertEquals(options.numberingSystem, "arab");
+
+// The default numberingSystem is 'arab' for 'ar' locale. Set it to 'latn'
+// to check that 'nu-latn' keyword is parsed correctly.
+options =
+ Intl.DateTimeFormat("ar-u-ca-islamic-civil-nu-latn").resolvedOptions();
+assertEquals(options.calendar, "islamic-civil");
+assertEquals(options.numberingSystem, "latn");
+
+// ethioaa is the canonical LDML/BCP 47 name.
+options = Intl.DateTimeFormat("am-u-ca-ethiopic-amete-alem").resolvedOptions();
+assertEquals(options.calendar, "ethioaa");
+
+// Invalid calendar type "foo-bar". Fall back to the default.
+options = Intl.DateTimeFormat("ar-u-ca-foo-bar").resolvedOptions();
+assertEquals(options.calendar, "gregory");
+
+// No type subtag for ca. Fall back to the default.
+options = Intl.DateTimeFormat("ar-u-ca-nu-arab").resolvedOptions();
+assertEquals(options.calendar, "gregory");
+
+// Too long a type subtag for ca.
+assertThrows(() => Intl.DateTimeFormat("ar-u-ca-foobarbaz"), RangeError);
« no previous file with comments | « src/js/i18n.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698