OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library find_default_locale_browser_test; | 5 @TestOn("vm") |
6 | |
7 import 'package:intl/intl.dart'; | 6 import 'package:intl/intl.dart'; |
8 import 'package:intl/intl_standalone.dart'; | 7 import 'package:intl/intl_standalone.dart'; |
9 import 'package:unittest/unittest.dart'; | 8 import 'package:test/test.dart'; |
10 | 9 |
11 main() { | 10 main() { |
12 test("Find system locale standalone", () { | 11 test("Find system locale standalone", () { |
13 // TODO (alanknight): This only verifies that we found some locale. We | 12 // TODO (alanknight): This only verifies that we found some locale. We |
14 // should find a way to force the system locale before the test is run | 13 // should find a way to force the system locale before the test is run |
15 // and then verify that it's actually the correct value. | 14 // and then verify that it's actually the correct value. |
16 // We have no way of getting this reliably for Windows, so it will fail. | 15 // We have no way of getting this reliably for Windows, so it will fail. |
17 Intl.systemLocale = "xx_YY"; | 16 Intl.systemLocale = "xx_YY"; |
18 var callback = expectAsync(verifyLocale); | 17 var callback = expectAsync(verifyLocale) as ThenArgument; |
19 findSystemLocale().then(callback); | 18 findSystemLocale().then(callback); |
20 }); | 19 }); |
21 } | 20 } |
22 | 21 |
| 22 typedef ThenArgument(String _); |
23 verifyLocale(_) { | 23 verifyLocale(_) { |
24 expect(Intl.systemLocale, isNot(equals("xx_YY"))); | 24 expect(Intl.systemLocale, isNot(equals("xx_YY"))); |
25 var pattern = new RegExp(r"\w\w_[A-Z0-9]+"); | 25 var pattern = new RegExp(r"\w\w_[A-Z0-9]+"); |
26 var shortPattern = new RegExp(r"\w\w"); | 26 var shortPattern = new RegExp(r"\w\w"); |
27 var match = pattern.hasMatch(Intl.systemLocale); | 27 var match = pattern.hasMatch(Intl.systemLocale); |
28 var shortMatch = shortPattern.hasMatch(Intl.systemLocale); | 28 var shortMatch = shortPattern.hasMatch(Intl.systemLocale); |
29 expect(match || shortMatch, isTrue); | 29 expect(match || shortMatch, isTrue); |
30 } | 30 } |
OLD | NEW |