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

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

Issue 179783004: Verify the default locale in case we're given an invalid one and need to fall back. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Review fixes Created 6 years, 10 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 | « pkg/intl/lib/intl.dart ('k') | pkg/intl/test/message_extraction/foo_messages_all.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/intl/test/intl_test.dart
diff --git a/pkg/intl/test/intl_test.dart b/pkg/intl/test/intl_test.dart
index d3571883d13c2830e044a6e061bbb94cbcc06b26..268d765bfb565bf64e9ad202e85fdcb063b058ea 100644
--- a/pkg/intl/test/intl_test.dart
+++ b/pkg/intl/test/intl_test.dart
@@ -34,4 +34,48 @@ main() {
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 | « pkg/intl/lib/intl.dart ('k') | pkg/intl/test/message_extraction/foo_messages_all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698