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

Unified Diff: packages/intl/test/intl_test.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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
Index: packages/intl/test/intl_test.dart
diff --git a/packages/intl/test/intl_test.dart b/packages/intl/test/intl_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..268d765bfb565bf64e9ad202e85fdcb063b058ea
--- /dev/null
+++ b/packages/intl/test/intl_test.dart
@@ -0,0 +1,81 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library intl_test;
+
+import 'package:intl/intl.dart';
+import 'package:unittest/unittest.dart';
+import 'package:intl/date_symbol_data_local.dart';
+
+main() {
+ test("Locale setting doesn't verify the core locale", () {
+ var de = new Intl('de_DE');
+ expect(de.locale, equals('de_DE'));
+ });
+
+ test('DateFormat creation does verify the locale', () {
+ // TODO(alanknight): We need to make the locale verification be on a per
+ // usage basis rather than once for the entire Intl object. The set of
+ // locales covered for messages may be different from that for date
+ // formatting.
+ initializeDateFormatting('de_DE', null).then((_) {
+ var de = new Intl('de_DE');
+ var format = de.date().add_d();
+ expect(format.locale, equals('de'));
+ });
+ });
+
+ test("Canonicalizing locales", () {
+ expect(Intl.canonicalizedLocale('en-us'), 'en_US');
+ expect(Intl.canonicalizedLocale('en_us'), 'en_US');
+ expect(Intl.canonicalizedLocale('en_US'), 'en_US');
+ expect(Intl.canonicalizedLocale('xx-yyy'), 'xx_YYY');
+ expect(Intl.canonicalizedLocale('xx_YYY'), 'xx_YYY');
+ expect(Intl.canonicalizedLocale('C'), 'en_ISO');
+ });
+
+ test("Verifying locale fallback for numbers", () {
+ expect(Intl.verifiedLocale('en-us', NumberFormat.localeExists), 'en_US');
+ expect(Intl.verifiedLocale('en_us', NumberFormat.localeExists), 'en_US');
+ expect(Intl.verifiedLocale('es-419', NumberFormat.localeExists), 'es_419');
+ expect(Intl.verifiedLocale('en-ZZ', NumberFormat.localeExists), 'en');
+ expect(Intl.verifiedLocale('es-999', NumberFormat.localeExists), 'es');
+
+ void checkAsNumberDefault(String locale, String expected) {
+ var oldDefault = Intl.defaultLocale;
+ Intl.defaultLocale = locale;
+ var format = new NumberFormat();
+ expect(format.locale, expected);
+ Intl.defaultLocale = oldDefault;
+ }
+
+ checkAsNumberDefault('en-us', 'en_US');
+ checkAsNumberDefault('en_us', 'en_US');
+ checkAsNumberDefault('es-419', 'es_419');
+ checkAsNumberDefault('en-ZZ', 'en');
+ checkAsNumberDefault('es-999', 'es');
+ });
+
+ test("Verifying locale fallback for dates", () {
+ expect(Intl.verifiedLocale('en-us', DateFormat.localeExists), 'en_US');
+ expect(Intl.verifiedLocale('en_us', DateFormat.localeExists), 'en_US');
+ expect(Intl.verifiedLocale('es-419', DateFormat.localeExists), 'es_419');
+ expect(Intl.verifiedLocale('en-ZZ', DateFormat.localeExists), 'en');
+ expect(Intl.verifiedLocale('es-999', DateFormat.localeExists), 'es');
+
+ void checkAsDateDefault(String locale, String expected) {
+ var oldDefault = Intl.defaultLocale;
+ Intl.defaultLocale = locale;
+ var format = new DateFormat();
+ expect(format.locale, expected);
+ Intl.defaultLocale = oldDefault;
+ }
+
+ checkAsDateDefault('en-us', 'en_US');
+ checkAsDateDefault('en_us', 'en_US');
+ checkAsDateDefault('es-419', 'es_419');
+ checkAsDateDefault('en-ZZ', 'en');
+ checkAsDateDefault('es-999', 'es');
+ });
+}
« no previous file with comments | « packages/intl/test/intl_message_basic_example_test.dart ('k') | packages/intl/test/message_extraction/debug.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698