| OLD | NEW |
| 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 Loading... |
| 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 } |
| OLD | NEW |