@@ -45,12 +45,35 @@ void main() {
45
45
reason: 'be careful if you modify the test file' );
46
46
expect (sampleAppFuncNames, containsPair (45 , 'usedMethod' ),
47
47
reason: 'be careful if you modify the test file' );
48
- if (platformVersionCheck (2 , 17 )) {
49
- // Dart VM versions before 2.17 don't support branch coverage.
50
- expect (sampleAppBranchHits, containsPair (41 , 1 ),
51
- reason: 'be careful if you modify the test file' );
52
- }
53
- });
48
+ expect (sampleAppBranchHits, containsPair (41 , 1 ),
49
+ reason: 'be careful if you modify the test file' );
50
+ }, skip: ! platformVersionCheck (2 , 17 ));
51
+
52
+ test ('validate hitMap, old VM without branch coverage' , () async {
53
+ final hitmap = await _getHitMap ();
54
+
55
+ expect (hitmap, contains (_sampleAppFileUri));
56
+ expect (hitmap, contains (_isolateLibFileUri));
57
+ expect (hitmap, contains ('package:coverage/src/util.dart' ));
58
+
59
+ final sampleAppHitMap = hitmap[_sampleAppFileUri];
60
+ final sampleAppHitLines = sampleAppHitMap? .lineHits;
61
+ final sampleAppHitFuncs = sampleAppHitMap? .funcHits;
62
+ final sampleAppFuncNames = sampleAppHitMap? .funcNames;
63
+
64
+ expect (sampleAppHitLines, containsPair (46 , greaterThanOrEqualTo (1 )),
65
+ reason: 'be careful if you modify the test file' );
66
+ expect (sampleAppHitLines, containsPair (50 , 0 ),
67
+ reason: 'be careful if you modify the test file' );
68
+ expect (sampleAppHitLines, isNot (contains (32 )),
69
+ reason: 'be careful if you modify the test file' );
70
+ expect (sampleAppHitFuncs, containsPair (45 , 1 ),
71
+ reason: 'be careful if you modify the test file' );
72
+ expect (sampleAppHitFuncs, containsPair (49 , 0 ),
73
+ reason: 'be careful if you modify the test file' );
74
+ expect (sampleAppFuncNames, containsPair (45 , 'usedMethod' ),
75
+ reason: 'be careful if you modify the test file' );
76
+ }, skip: platformVersionCheck (2 , 17 ));
54
77
55
78
group ('LcovFormatter' , () {
56
79
test ('format()' , () async {
@@ -206,25 +229,22 @@ void main() {
206
229
expect (res, contains (' | return a + b;' ));
207
230
});
208
231
209
- if (platformVersionCheck (2 , 17 )) {
210
- // Dart VM versions before 2.17 don't support branch coverage.
211
- test ('prettyPrint() branches' , () async {
212
- final hitmap = await _getHitMap ();
232
+ test ('prettyPrint() branches' , () async {
233
+ final hitmap = await _getHitMap ();
213
234
214
- final resolver = Resolver (packagesPath: '.packages' );
215
- final res =
216
- await hitmap.prettyPrint (resolver, Loader (), reportBranches: true );
235
+ final resolver = Resolver (packagesPath: '.packages' );
236
+ final res =
237
+ await hitmap.prettyPrint (resolver, Loader (), reportBranches: true );
217
238
218
- expect (res, contains (p.absolute (_sampleAppPath)));
219
- expect (res, contains (p.absolute (_isolateLibPath)));
220
- expect (res, contains (p.absolute (p.join ('lib' , 'src' , 'util.dart' ))));
239
+ expect (res, contains (p.absolute (_sampleAppPath)));
240
+ expect (res, contains (p.absolute (_isolateLibPath)));
241
+ expect (res, contains (p.absolute (p.join ('lib' , 'src' , 'util.dart' ))));
221
242
222
- // be very careful if you change the test file
223
- expect (res, contains (' 1| if (x == answer) {' ));
224
- expect (res, contains (' 0| while (i < lines.length) {' ));
225
- expect (res, contains (' | bar.baz();' ));
226
- });
227
- }
243
+ // be very careful if you change the test file
244
+ expect (res, contains (' 1| if (x == answer) {' ));
245
+ expect (res, contains (' 0| while (i < lines.length) {' ));
246
+ expect (res, contains (' | bar.baz();' ));
247
+ }, skip: ! platformVersionCheck (2 , 17 ));
228
248
});
229
249
}
230
250
0 commit comments