Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Side by Side Diff: packages/intl/test/date_time_loose_parsing_test.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
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.
4
5 /// Tests for the loose option when parsing dates and times, which accept
6 /// mixed-case input and are able to skip missing delimiters. This is only
7 /// tested in basic US locale, it's hard to define for others.
8 library date_time_loose_test;
9
10 import 'package:intl/intl.dart';
11 import 'package:unittest/unittest.dart';
12
13 main() {
14 var format;
15
16 var date = new DateTime(2014, 9, 3);
17
18 check(String s) {
19 expect(() => format.parse(s), throwsFormatException);
20 expect(format.parseLoose(s), date);
21 }
22
23 test("Loose parsing yMMMd", () {
24 // Note: We can't handle e.g. Sept, we don't have those abbreviations
25 // in our data.
26 // Also doesn't handle "sep3,2014", or "sep 3.2014"
27 format = new DateFormat.yMMMd("en_US");
28 check("Sep 3 2014");
29 check("sep 3 2014");
30 check("sep 3 2014");
31 check("sep 3 2014");
32 check("sep 3 2014");
33 check("sep3 2014");
34 check("september 3, 2014");
35 check("sEPTembER 3, 2014");
36 check("seP 3, 2014");
37 });
38
39 test("Loose parsing yMMMd that parses strict", () {
40 expect(format.parseLoose("Sep 3, 2014"), date);
41 });
42
43 test("Loose parsing yMd", () {
44 format = new DateFormat.yMd("en_US");
45 check("09 3 2014");
46 check("09 00003 2014");
47 check("09/ 03/2014");
48 expect(() => format.parseLoose("09 / 03 / 2014"),
49 throwsA(new isInstanceOf<FormatException>()));
50 });
51
52 test("Loose parsing yMd that parses strict", () {
53 expect(format.parseLoose("09/03/2014"), date);
54 expect(format.parseLoose("09/3/2014"), date);
55 });
56 }
OLDNEW
« no previous file with comments | « packages/intl/test/date_time_format_uninitialized_test.dart ('k') | packages/intl/test/date_time_strict_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698