@@ -37,13 +37,13 @@ void main() {
37
37
38
38
final prng = Random (42 );
39
39
for (var i = 0 ; i < 50 ; i++ ) {
40
- final chars = '{}[]abcd \ 0 """"\\\\\\\\\$\$\'\' ' .split ('' );
40
+ final chars = '{}[]abcd 0""""\\\\\\\\\$\$\'\' ' .split ('' );
41
41
chars.shuffle (prng);
42
42
testValue ('shuffled string ($i )' , chars.join ('' ));
43
43
testValue ('shuffled map key ($i )' , {chars.join ('' ): 42 });
44
44
}
45
45
46
- [
46
+ for ( var data in [
47
47
'""' ,
48
48
'"hello world"' ,
49
49
r'"test\"test"' ,
@@ -67,21 +67,23 @@ void main() {
67
67
'-120' ,
68
68
'"Äffin"' ,
69
69
// Test valid canonical JSON cases.
70
- ].forEach ((String data) => test ('isValidCanonicalJSON($data )' , () {
71
- final value = json.decode (data);
72
- final encoded = canonicalJson.encode (value);
73
- expect (utf8.decode (encoded), equals (data));
74
- final decoded = canonicalJson.decode (encoded);
75
- expect (decoded, equals (value));
76
- final encodedAgain = canonicalJson.encode (decoded);
77
- expect (encodedAgain, encoded);
78
- // TODO: Use json.fuse(utf8) when: http://dartbug.com/46205 is fixed!
79
- // final decodedJson = json.fuse(utf8).decode(encoded);
80
- final decodedJson = json.decode (utf8.decode (encoded));
81
- expect (decodedJson, equals (value));
82
- }));
70
+ ]) {
71
+ test ('isValidCanonicalJSON($data )' , () {
72
+ final value = json.decode (data);
73
+ final encoded = canonicalJson.encode (value);
74
+ expect (utf8.decode (encoded), equals (data));
75
+ final decoded = canonicalJson.decode (encoded);
76
+ expect (decoded, equals (value));
77
+ final encodedAgain = canonicalJson.encode (decoded);
78
+ expect (encodedAgain, encoded);
79
+ // TODO: Use json.fuse(utf8) when: http://dartbug.com/46205 is fixed!
80
+ // final decodedJson = json.fuse(utf8).decode(encoded);
81
+ final decodedJson = json.decode (utf8.decode (encoded));
82
+ expect (decodedJson, equals (value));
83
+ });
84
+ }
83
85
84
- [
86
+ for ( var data in [
85
87
'42.1' ,
86
88
't' ,
87
89
'f' ,
@@ -118,19 +120,23 @@ void main() {
118
120
'-0' ,
119
121
'"A\u 0308ffin"' , // not unicode normalization form C
120
122
// Test invalid canonical JSON cases.
121
- ].forEach ((String data) => test ('isInvalidCanonicalJSON($data )' , () {
122
- final raw = utf8.encode (data);
123
- expect (() => canonicalJson.decode (raw),
124
- throwsA (TypeMatcher <InvalidCanonicalJsonException >()));
125
- }));
123
+ ]) {
124
+ test ('isInvalidCanonicalJSON($data )' , () {
125
+ final raw = utf8.encode (data);
126
+ expect (() => canonicalJson.decode (raw),
127
+ throwsA (TypeMatcher <InvalidCanonicalJsonException >()));
128
+ });
129
+ }
126
130
127
- [
131
+ for ( var data in [
128
132
1.2 ,
129
133
- 0.0 ,
130
- ].forEach ((Object data) => test ('cannotBeCanonicalized($data )' , () {
131
- expect (() => canonicalJson.encode (data),
132
- throwsA (TypeMatcher <ArgumentError >()));
133
- }));
134
+ ]) {
135
+ test ('cannotBeCanonicalized($data )' , () {
136
+ expect (() => canonicalJson.encode (data),
137
+ throwsA (TypeMatcher <ArgumentError >()));
138
+ });
139
+ }
134
140
135
141
test ('unicode normalization form C' , () {
136
142
final nonFormC = 'A\u 0308\u FB03n' ;
0 commit comments