@@ -45,12 +45,35 @@ void main() {
4545 reason: 'be careful if you modify the test file' );
4646 expect (sampleAppFuncNames, containsPair (45 , 'usedMethod' ),
4747 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 ));
5477
5578 group ('LcovFormatter' , () {
5679 test ('format()' , () async {
@@ -206,25 +229,22 @@ void main() {
206229 expect (res, contains (' | return a + b;' ));
207230 });
208231
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 ();
213234
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 );
217238
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' ))));
221242
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 ));
228248 });
229249}
230250
0 commit comments