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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 DateFormat.MONTH_WEEKDAY_DAY, | 156 DateFormat.MONTH_WEEKDAY_DAY, |
157 DateFormat.NUM_MONTH_WEEKDAY_DAY, | 157 DateFormat.NUM_MONTH_WEEKDAY_DAY, |
158 DateFormat.ABBR_MONTH_WEEKDAY_DAY]; | 158 DateFormat.ABBR_MONTH_WEEKDAY_DAY]; |
159 for(int i = 0; i < formatsToTest.length; i++) { | 159 for(int i = 0; i < formatsToTest.length; i++) { |
160 var skeleton = formatsToTest[i]; | 160 var skeleton = formatsToTest[i]; |
161 if (!badSkeletons.any((x) => x == skeleton)) { | 161 if (!badSkeletons.any((x) => x == skeleton)) { |
162 var format = new DateFormat(skeleton, localeName); | 162 var format = new DateFormat(skeleton, localeName); |
163 var actualResult = format.format(date); | 163 var actualResult = format.format(date); |
164 var parsed = format.parse(actualResult); | 164 var parsed = format.parse(actualResult); |
165 var thenPrintAgain = format.format(parsed); | 165 var thenPrintAgain = format.format(parsed); |
166 // Very rarely, it seems like we can get an off-by-one error when using a | |
167 // format that only prints the date. This seems like it might be | |
168 // associated with a daylight savings transition, but it's not at all | |
169 // clear how. Regardless, if we get a non-equal result once, re-parse | |
170 // and re-print in case it's transient. | |
171 if (thenPrintAgain != actualResult) { | |
172 parsed = format.parse(actualResult); | |
173 thenPrintAgain = format.format(parsed); | |
174 } | |
kustermann
2013/11/28 10:16:26
I don't think you should do this.
Now that I see
floitsch
2013/11/28 10:29:05
I agree with Martin. This should never happen, and
| |
166 expect(thenPrintAgain, equals(actualResult)); | 175 expect(thenPrintAgain, equals(actualResult)); |
167 } | 176 } |
168 } | 177 } |
169 } | 178 } |
170 | 179 |
171 /** A shortcut for returning all the locales we have available.*/ | 180 /** A shortcut for returning all the locales we have available.*/ |
172 List<String> allLocales() => DateFormat.allLocalesWithSymbols(); | 181 List<String> allLocales() => DateFormat.allLocalesWithSymbols(); |
173 | 182 |
174 Function _subsetFunc; | 183 Function _subsetFunc; |
175 | 184 |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
395 var f = new DateFormat("D"); | 404 var f = new DateFormat("D"); |
396 var dates = generateDates(2012, 1); | 405 var dates = generateDates(2012, 1); |
397 var nonLeapDates = generateDates(2013, 0); | 406 var nonLeapDates = generateDates(2013, 0); |
398 verifyOrdinals(dates); | 407 verifyOrdinals(dates); |
399 verifyOrdinals(nonLeapDates); | 408 verifyOrdinals(nonLeapDates); |
400 // Check one hard-coded just to be on the safe side. | 409 // Check one hard-coded just to be on the safe side. |
401 var aDate = new DateTime(2012, 4, 27, 13, 58, 59, 012); | 410 var aDate = new DateTime(2012, 4, 27, 13, 58, 59, 012); |
402 expect(f.format(aDate), "118"); | 411 expect(f.format(aDate), "118"); |
403 }); | 412 }); |
404 } | 413 } |
OLD | NEW |