Skip to content

Commit b449bd7

Browse files
committed
unformat
1 parent 4810415 commit b449bd7

12 files changed

+408
-448
lines changed

pkgs/intl4x/test/collation_test.dart

+16-12
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ import 'package:test/test.dart';
99
import 'utils.dart';
1010

1111
void main() {
12-
test('Does not compare in tests', () {
13-
final unsorted = ['Z', 'a', 'z', 'ä'];
14-
final collationGerman =
15-
Intl(locale: const Locale(language: 'de', region: 'DE')).collation();
16-
expect(unsorted..sort(collationGerman.compare), orderedEquals(unsorted));
17-
});
12+
test(
13+
'Does not compare in tests',
14+
() {
15+
final unsorted = ['Z', 'a', 'z', 'ä'];
16+
final collationGerman =
17+
Intl(locale: const Locale(language: 'de', region: 'DE')).collation();
18+
expect(unsorted..sort(collationGerman.compare), orderedEquals(unsorted));
19+
},
20+
);
1821

1922
testWithFormatting('Simple EN', () {
2023
final list = ['A', 'B', 'C'];
@@ -35,14 +38,15 @@ void main() {
3538
final intl = Intl(locale: const Locale(language: 'de'));
3639
final list = ['AE', 'Ä'];
3740

38-
final searchCollation = intl.collation(
39-
const CollationOptions(usage: Usage.search),
41+
final searchCollation =
42+
intl.collation(const CollationOptions(usage: Usage.search));
43+
expect(
44+
list..sort(searchCollation.compare),
45+
orderedEquals(list),
4046
);
41-
expect(list..sort(searchCollation.compare), orderedEquals(list));
4247

43-
final sortCollation = intl.collation(
44-
const CollationOptions(usage: Usage.sort),
45-
);
48+
final sortCollation =
49+
intl.collation(const CollationOptions(usage: Usage.sort));
4650
expect(
4751
list..sort(sortCollation.compare),
4852
orderedEquals(list.reversed),

pkgs/intl4x/test/datetime_format_test.dart

+140-146
Original file line numberDiff line numberDiff line change
@@ -9,167 +9,161 @@ import 'package:test/test.dart';
99
import 'utils.dart';
1010

1111
void main() {
12-
testWithFormatting('Basic', () {
13-
expect(
14-
Intl(
15-
locale: const Locale(language: 'en', region: 'US'),
16-
).datetimeFormat().format(DateTime.utc(2012, 12, 20, 3, 0, 0)),
17-
'12/20/2012',
18-
);
19-
}, tags: ['icu4xUnimplemented']);
12+
testWithFormatting(
13+
'Basic',
14+
() {
15+
expect(
16+
Intl(locale: const Locale(language: 'en', region: 'US'))
17+
.datetimeFormat()
18+
.format(DateTime.utc(2012, 12, 20, 3, 0, 0)),
19+
'12/20/2012');
20+
},
21+
tags: ['icu4xUnimplemented'],
22+
);
2023

21-
testWithFormatting('timezone', () {
22-
final date = DateTime.utc(2021, 12, 17, 3, 0, 42);
23-
final intl = Intl(locale: const Locale(language: 'en', region: 'US'));
24-
final timeZone = 'America/Los_Angeles';
25-
expect(
26-
intl
27-
.datetimeFormat(
28-
DateTimeFormatOptions(
24+
testWithFormatting(
25+
'timezone',
26+
() {
27+
final date = DateTime.utc(2021, 12, 17, 3, 0, 42);
28+
final intl = Intl(locale: const Locale(language: 'en', region: 'US'));
29+
final timeZone = 'America/Los_Angeles';
30+
expect(
31+
intl
32+
.datetimeFormat(DateTimeFormatOptions(
2933
timeZone: timeZone,
3034
timeZoneName: TimeZoneName.short,
31-
),
32-
)
33-
.format(date),
34-
'12/16/2021, PST',
35-
);
36-
expect(
37-
intl
38-
.datetimeFormat(
39-
DateTimeFormatOptions(
35+
))
36+
.format(date),
37+
'12/16/2021, PST',
38+
);
39+
expect(
40+
intl
41+
.datetimeFormat(DateTimeFormatOptions(
4042
timeZone: timeZone,
4143
timeZoneName: TimeZoneName.long,
42-
),
43-
)
44-
.format(date),
45-
'12/16/2021, Pacific Standard Time',
46-
);
47-
expect(
48-
intl
49-
.datetimeFormat(
50-
DateTimeFormatOptions(
44+
))
45+
.format(date),
46+
'12/16/2021, Pacific Standard Time',
47+
);
48+
expect(
49+
intl
50+
.datetimeFormat(DateTimeFormatOptions(
5151
timeZone: timeZone,
5252
timeZoneName: TimeZoneName.shortOffset,
53-
),
54-
)
55-
.format(date),
56-
'12/16/2021, GMT-8',
57-
);
58-
expect(
59-
intl
60-
.datetimeFormat(
61-
DateTimeFormatOptions(
53+
))
54+
.format(date),
55+
'12/16/2021, GMT-8',
56+
);
57+
expect(
58+
intl
59+
.datetimeFormat(DateTimeFormatOptions(
6260
timeZone: timeZone,
6361
timeZoneName: TimeZoneName.longOffset,
64-
),
65-
)
66-
.format(date),
67-
'12/16/2021, GMT-08:00',
68-
);
69-
expect(
70-
intl
71-
.datetimeFormat(
72-
DateTimeFormatOptions(
62+
))
63+
.format(date),
64+
'12/16/2021, GMT-08:00',
65+
);
66+
expect(
67+
intl
68+
.datetimeFormat(DateTimeFormatOptions(
7369
timeZone: timeZone,
7470
timeZoneName: TimeZoneName.shortGeneric,
75-
),
76-
)
77-
.format(date),
78-
'12/16/2021, PT',
79-
);
80-
expect(
81-
intl
82-
.datetimeFormat(
83-
DateTimeFormatOptions(
71+
))
72+
.format(date),
73+
'12/16/2021, PT',
74+
);
75+
expect(
76+
intl
77+
.datetimeFormat(DateTimeFormatOptions(
8478
timeZone: timeZone,
8579
timeZoneName: TimeZoneName.longGeneric,
86-
),
87-
)
88-
.format(date),
89-
'12/16/2021, Pacific Time',
90-
);
91-
}, tags: ['icu4xUnimplemented']);
80+
))
81+
.format(date),
82+
'12/16/2021, Pacific Time',
83+
);
84+
},
85+
tags: ['icu4xUnimplemented'],
86+
);
9287

93-
testWithFormatting('day period', () {
94-
final date = DateTime.utc(2021, 12, 17, 4, 0, 42);
95-
expect(
96-
Intl(locale: const Locale(language: 'en', region: 'GB'))
97-
.datetimeFormat(
98-
const DateTimeFormatOptions(
99-
hour: TimeStyle.numeric,
100-
clockstyle: ClockStyle(is12Hour: true, startAtZero: false),
101-
dayPeriod: DayPeriod.short,
102-
timeZone: 'UTC',
103-
),
104-
)
105-
.format(date),
106-
'4 at night',
107-
);
88+
testWithFormatting(
89+
'day period',
90+
() {
91+
final date = DateTime.utc(2021, 12, 17, 4, 0, 42);
92+
expect(
93+
Intl(locale: const Locale(language: 'en', region: 'GB'))
94+
.datetimeFormat(const DateTimeFormatOptions(
95+
hour: TimeStyle.numeric,
96+
clockstyle: ClockStyle(
97+
is12Hour: true,
98+
startAtZero: false,
99+
),
100+
dayPeriod: DayPeriod.short,
101+
timeZone: 'UTC',
102+
))
103+
.format(date),
104+
'4 at night');
108105

109-
expect(
110-
Intl(locale: const Locale(language: 'fr'))
111-
.datetimeFormat(
112-
const DateTimeFormatOptions(
113-
hour: TimeStyle.numeric,
114-
clockstyle: ClockStyle(is12Hour: true, startAtZero: false),
115-
dayPeriod: DayPeriod.narrow,
116-
timeZone: 'UTC',
117-
),
118-
)
119-
.format(date),
120-
'4 mat.',
121-
);
106+
expect(
107+
Intl(locale: const Locale(language: 'fr'))
108+
.datetimeFormat(const DateTimeFormatOptions(
109+
hour: TimeStyle.numeric,
110+
clockstyle: ClockStyle(
111+
is12Hour: true,
112+
startAtZero: false,
113+
),
114+
dayPeriod: DayPeriod.narrow,
115+
timeZone: 'UTC',
116+
))
117+
.format(date),
118+
'4 mat.');
122119

123-
expect(
124-
Intl(locale: const Locale(language: 'fr'))
125-
.datetimeFormat(
126-
const DateTimeFormatOptions(
127-
hour: TimeStyle.numeric,
128-
clockstyle: ClockStyle(is12Hour: true, startAtZero: false),
129-
dayPeriod: DayPeriod.long,
130-
timeZone: 'UTC',
131-
),
132-
)
133-
.format(date),
134-
'4 du matin',
135-
);
136-
}, tags: ['icu4xUnimplemented']);
120+
expect(
121+
Intl(locale: const Locale(language: 'fr'))
122+
.datetimeFormat(const DateTimeFormatOptions(
123+
hour: TimeStyle.numeric,
124+
clockstyle: ClockStyle(
125+
is12Hour: true,
126+
startAtZero: false,
127+
),
128+
dayPeriod: DayPeriod.long,
129+
timeZone: 'UTC',
130+
))
131+
.format(date),
132+
'4 du matin');
133+
},
134+
tags: ['icu4xUnimplemented'],
135+
);
137136

138-
testWithFormatting('style', () {
139-
final date = DateTime.utc(2021, 12, 17, 4, 0, 42);
140-
expect(
141-
Intl(locale: const Locale(language: 'en'))
142-
.datetimeFormat(
143-
const DateTimeFormatOptions(
144-
timeFormatStyle: TimeFormatStyle.short,
145-
timeZone: 'UTC',
146-
),
147-
)
148-
.format(date),
149-
'4:00 AM',
150-
);
151-
expect(
152-
Intl(locale: const Locale(language: 'en'))
153-
.datetimeFormat(
154-
const DateTimeFormatOptions(
155-
dateFormatStyle: DateFormatStyle.short,
156-
timeZone: 'UTC',
157-
),
158-
)
159-
.format(date),
160-
'12/17/21',
161-
);
162-
expect(
163-
Intl(locale: const Locale(language: 'en'))
164-
.datetimeFormat(
165-
const DateTimeFormatOptions(
166-
timeFormatStyle: TimeFormatStyle.medium,
167-
dateFormatStyle: DateFormatStyle.short,
168-
timeZone: 'UTC',
169-
),
170-
)
171-
.format(date),
172-
'12/17/21, 4:00:42 AM',
173-
);
174-
}, tags: ['icu4xUnimplemented']);
137+
testWithFormatting(
138+
'style',
139+
() {
140+
final date = DateTime.utc(2021, 12, 17, 4, 0, 42);
141+
expect(
142+
Intl(locale: const Locale(language: 'en'))
143+
.datetimeFormat(const DateTimeFormatOptions(
144+
timeFormatStyle: TimeFormatStyle.short,
145+
timeZone: 'UTC',
146+
))
147+
.format(date),
148+
'4:00 AM');
149+
expect(
150+
Intl(locale: const Locale(language: 'en'))
151+
.datetimeFormat(const DateTimeFormatOptions(
152+
dateFormatStyle: DateFormatStyle.short,
153+
timeZone: 'UTC',
154+
))
155+
.format(date),
156+
'12/17/21');
157+
expect(
158+
Intl(locale: const Locale(language: 'en'))
159+
.datetimeFormat(const DateTimeFormatOptions(
160+
timeFormatStyle: TimeFormatStyle.medium,
161+
dateFormatStyle: DateFormatStyle.short,
162+
timeZone: 'UTC',
163+
))
164+
.format(date),
165+
'12/17/21, 4:00:42 AM');
166+
},
167+
tags: ['icu4xUnimplemented'],
168+
);
175169
}

0 commit comments

Comments
 (0)