| 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 /** | 5 /** |
| 6 * Tests the DateFormat library in dart. This file contains core tests that | 6 * Tests the DateFormat library in dart. This file contains core tests that |
| 7 * are run regardless of where the locale data is found, so it doesn't expect to | 7 * are run regardless of where the locale data is found, so it doesn't expect to |
| 8 * be run on its own, but rather to be imported and run from another test file. | 8 * be run on its own, but rather to be imported and run from another test file. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 170 |
| 171 /** A shortcut for returning all the locales we have available.*/ | 171 /** A shortcut for returning all the locales we have available.*/ |
| 172 List<String> allLocales() => DateFormat.allLocalesWithSymbols(); | 172 List<String> allLocales() => DateFormat.allLocalesWithSymbols(); |
| 173 | 173 |
| 174 /** | 174 /** |
| 175 * Return only the odd-numbered locales. A simple way to divide the list into | 175 * Return only the odd-numbered locales. A simple way to divide the list into |
| 176 * two roughly equal parts. | 176 * two roughly equal parts. |
| 177 */ | 177 */ |
| 178 List oddLocales() { | 178 List oddLocales() { |
| 179 int i = 1; | 179 int i = 1; |
| 180 return allLocales().filter((x) => (i++).isOdd()); | 180 return allLocales().filter((x) => (i++).isOdd); |
| 181 } | 181 } |
| 182 | 182 |
| 183 /** | 183 /** |
| 184 * Return a set of a few locales to run just the tests on a small sample. | 184 * Return a set of a few locales to run just the tests on a small sample. |
| 185 */ | 185 */ |
| 186 List smallSetOfLocales() { | 186 List smallSetOfLocales() { |
| 187 return allLocales().getRange(0,10); | 187 return allLocales().getRange(0,10); |
| 188 } | 188 } |
| 189 | 189 |
| 190 /** | 190 /** |
| 191 * Return only the even-numbered locales. A simple way to divide the list into | 191 * Return only the even-numbered locales. A simple way to divide the list into |
| 192 * two roughly equal parts. | 192 * two roughly equal parts. |
| 193 */ | 193 */ |
| 194 List evenLocales() { | 194 List evenLocales() { |
| 195 int i = 1; | 195 int i = 1; |
| 196 return allLocales().filter((x) => !((i++).isOdd())); | 196 return allLocales().filter((x) => !((i++).isOdd)); |
| 197 } | 197 } |
| 198 | 198 |
| 199 // TODO(alanknight): Run specific tests for the en_ISO locale which isn't | 199 // TODO(alanknight): Run specific tests for the en_ISO locale which isn't |
| 200 // included in CLDR, and check that our patterns for it are correct (they | 200 // included in CLDR, and check that our patterns for it are correct (they |
| 201 // very likely aren't). | 201 // very likely aren't). |
| 202 runDateTests([List<String> subset]) { | 202 runDateTests([List<String> subset]) { |
| 203 test('Multiple patterns', () { | 203 test('Multiple patterns', () { |
| 204 var date = new Date.now(); | 204 var date = new Date.now(); |
| 205 var multiple1 = new DateFormat.yMd().add_jms(); | 205 var multiple1 = new DateFormat.yMd().add_jms(); |
| 206 var multiple2 = new DateFormat("yMd").add_jms(); | 206 var multiple2 = new DateFormat("yMd").add_jms(); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 | 338 |
| 339 test('Test default format', () { | 339 test('Test default format', () { |
| 340 var someDate = new Date(2012, 1, 27, 20, 58, 59, 1); | 340 var someDate = new Date(2012, 1, 27, 20, 58, 59, 1); |
| 341 var emptyFormat = new DateFormat(null, "en_US"); | 341 var emptyFormat = new DateFormat(null, "en_US"); |
| 342 var knownDefault = new DateFormat.yMMMMd("en_US").add_jms(); | 342 var knownDefault = new DateFormat.yMMMMd("en_US").add_jms(); |
| 343 var result = emptyFormat.format(someDate); | 343 var result = emptyFormat.format(someDate); |
| 344 var knownResult = knownDefault.format(someDate); | 344 var knownResult = knownDefault.format(someDate); |
| 345 expect(result, knownResult); | 345 expect(result, knownResult); |
| 346 }); | 346 }); |
| 347 } | 347 } |
| OLD | NEW |