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

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

Issue 259093004: Allow a NumberFormat to be passed a currency name/symbol at creation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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/number_format.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/intl/test/number_format_test.dart
diff --git a/pkg/intl/test/number_format_test.dart b/pkg/intl/test/number_format_test.dart
index 07f1db14b06f1831e68774e029526fc2eb9fc2c7..064933df8c8249e56413606c379b4c25ef65bfd4 100644
--- a/pkg/intl/test/number_format_test.dart
+++ b/pkg/intl/test/number_format_test.dart
@@ -94,4 +94,27 @@ main() {
expect(formatted, x);
}
});
+
+ test('Explicit currency name', () {
+ var amount = 1000000.32;
+ var usConvention = new NumberFormat.currencyPattern('en_US', '€');
+ var formatted = usConvention.format(amount);
+ expect(formatted, '€1,000,000.32');
+ var swissConvention = new NumberFormat.currencyPattern('de_CH', r'$');
+ formatted = swissConvention.format(amount);
+ var nbsp = new String.fromCharCode(0xa0);
+ expect(formatted, r"$" + nbsp + "1'000'000.32");
+
+ /// Verify we can leave off the currency and it gets filled in.
+ var plainSwiss = new NumberFormat.currencyPattern('de_CH');
+ formatted = plainSwiss.format(amount);
+ expect(formatted, r"CHF" + nbsp + "1'000'000.32");
+
+ // Verify that we can pass null in order to specify the currency symbol
+ // but use the default locale.
+ var defaultLocale = new NumberFormat.currencyPattern(null, 'Smurfs');
+ formatted = defaultLocale.format(amount);
+ // We don't know what the exact format will be, but it should have Smurfs.
+ expect(formatted.contains('Smurfs'), isTrue);
+ });
}
« no previous file with comments | « pkg/intl/lib/number_format.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698