| OLD | NEW |
| 1 // for details. All rights reserved. Use of this source code is governed by a | 1 // for details. All rights reserved. Use of this source code is governed by a |
| 2 // BSD-style license that can be found in the LICENSE file. | 2 // BSD-style license that can be found in the LICENSE file. |
| 3 | 3 |
| 4 /** | 4 /** |
| 5 * Tests based on the closure number formatting tests. | 5 * Tests based on the closure number formatting tests. |
| 6 */ | 6 */ |
| 7 library number_closure_test; | 7 library number_closure_test; |
| 8 | 8 |
| 9 import 'dart:async'; |
| 9 import "package:intl/intl.dart"; | 10 import "package:intl/intl.dart"; |
| 10 import "package:unittest/unittest.dart"; | 11 import "package:unittest/unittest.dart"; |
| 11 | 12 |
| 12 main() { | 13 main() { |
| 13 test("testVeryBigNumber", testVeryBigNumber); | 14 test("testVeryBigNumber", testVeryBigNumber); |
| 14 test("testStandardFormat", testStandardFormat); | 15 test("testStandardFormat", testStandardFormat); |
| 15 test("testNegativePercentage", testNegativePercentage); | 16 test("testNegativePercentage", testNegativePercentage); |
| 16 test("testCustomPercentage", testCustomPercentage); | 17 test("testCustomPercentage", testCustomPercentage); |
| 17 test("testBasicFormat", testBasicFormat); | 18 test("testBasicFormat", testBasicFormat); |
| 18 test("testGrouping", testGrouping); | 19 test("testGrouping", testGrouping); |
| 19 test("testPerMill", testPerMill); | 20 test("testPerMill", testPerMill); |
| 20 test("testQuotes", testQuotes); | 21 test("testQuotes", testQuotes); |
| 21 test("testZeros", testZeros); | 22 test("testZeros", testZeros); |
| 22 test("testExponential", testExponential); | 23 test("testExponential", testExponential); |
| 23 test("testPlusSignInExponentPart", testPlusSignInExponentPart); | 24 test("testPlusSignInExponentPart", testPlusSignInExponentPart); |
| 24 test("testApis", testApis); | 25 test("testApis", testApis); |
| 25 test("testLocaleSwitch", testLocaleSwitch); | 26 test("testLocaleSwitch", testLocaleSwitch); |
| 27 test("testLocaleSwitchAsync", testLocaleSwitchAsync); |
| 26 } | 28 } |
| 27 | 29 |
| 28 /** | 30 /** |
| 29 * Test two large numbers for equality, assuming that there may be some | 31 * Test two large numbers for equality, assuming that there may be some |
| 30 * loss of precision in the less significant digits. | 32 * loss of precision in the less significant digits. |
| 31 */ | 33 */ |
| 32 veryBigNumberCompare(str1, str2) { | 34 veryBigNumberCompare(str1, str2) { |
| 33 return str1.length == str2.length && | 35 return str1.length == str2.length && |
| 34 str1.substring(0, 8) == str2.substring(0, 8); | 36 str1.substring(0, 8) == str2.substring(0, 8); |
| 35 } | 37 } |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 | 376 |
| 375 fmt = new NumberFormat('#,###'); | 377 fmt = new NumberFormat('#,###'); |
| 376 str = fmt.format(1234567890); | 378 str = fmt.format(1234567890); |
| 377 expect('1,234,567,890', str); | 379 expect('1,234,567,890', str); |
| 378 } | 380 } |
| 379 | 381 |
| 380 testLocaleSwitch() { | 382 testLocaleSwitch() { |
| 381 Intl.withLocale("fr", verifyFrenchLocale); | 383 Intl.withLocale("fr", verifyFrenchLocale); |
| 382 } | 384 } |
| 383 | 385 |
| 386 testLocaleSwitchAsync() { |
| 387 Intl.withLocale("fr", () { |
| 388 new Timer(new Duration(milliseconds:10), expectAsync(verifyFrenchLocale)); |
| 389 }); |
| 390 // Verify that things running outside the zone still get en_US. |
| 391 testStandardFormat(); |
| 392 } |
| 393 |
| 384 void verifyFrenchLocale() { | 394 void verifyFrenchLocale() { |
| 385 var fmt = new NumberFormat('#,###'); | 395 var fmt = new NumberFormat('#,###'); |
| 386 var str = fmt.format(1234567890); | 396 var str = fmt.format(1234567890); |
| 387 expect('1\u00a0234\u00a0567\u00a0890', str); | 397 expect(str, '1\u00a0234\u00a0567\u00a0890'); |
| 388 } | 398 } |
| OLD | NEW |