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

Side by Side 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, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/intl/lib/number_format.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /** 1 /**
2 * Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 * Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
3 * for details. All rights reserved. Use of this source code is governed by a 3 * for details. All rights reserved. Use of this source code is governed by a
4 * BSD-style license that can be found in the LICENSE file. 4 * BSD-style license that can be found in the LICENSE file.
5 */ 5 */
6 6
7 library number_format_test; 7 library number_format_test;
8 8
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 import 'package:intl/number_symbols_data.dart'; 10 import 'package:intl/number_symbols_data.dart';
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } 87 }
88 }); 88 });
89 89
90 test('Exponential form', () { 90 test('Exponential form', () {
91 var number = new NumberFormat("#.###E0"); 91 var number = new NumberFormat("#.###E0");
92 for (var x in testExponential.keys) { 92 for (var x in testExponential.keys) {
93 var formatted = number.format(testExponential[x]); 93 var formatted = number.format(testExponential[x]);
94 expect(formatted, x); 94 expect(formatted, x);
95 } 95 }
96 }); 96 });
97
98 test('Explicit currency name', () {
99 var amount = 1000000.32;
100 var usConvention = new NumberFormat.currencyPattern('en_US', '€');
101 var formatted = usConvention.format(amount);
102 expect(formatted, '€1,000,000.32');
103 var swissConvention = new NumberFormat.currencyPattern('de_CH', r'$');
104 formatted = swissConvention.format(amount);
105 var nbsp = new String.fromCharCode(0xa0);
106 expect(formatted, r"$" + nbsp + "1'000'000.32");
107
108 /// Verify we can leave off the currency and it gets filled in.
109 var plainSwiss = new NumberFormat.currencyPattern('de_CH');
110 formatted = plainSwiss.format(amount);
111 expect(formatted, r"CHF" + nbsp + "1'000'000.32");
112
113 // Verify that we can pass null in order to specify the currency symbol
114 // but use the default locale.
115 var defaultLocale = new NumberFormat.currencyPattern(null, 'Smurfs');
116 formatted = defaultLocale.format(amount);
117 // We don't know what the exact format will be, but it should have Smurfs.
118 expect(formatted.contains('Smurfs'), isTrue);
119 });
97 } 120 }
OLDNEW
« 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