dart-lang / coverage

Dart coverage data manipulation and formatting

Home Page:https://pub.dev/packages/coverage

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Branch coverage shows extra missing lines in enums

liamappelbe opened this issue · comments

Need to investigate further, but it's probably some internal function generated as part of the enum, which gets branch coverage instructions but isn't visible to the user. Just need to add logic to either not insert these instructions, or ignore them in getSourceReport.

Culprit is the enum constructor. I could just mark the constructor as synthetic, but the bug also appears for user defined (ie non-synthetic) constructors using the new enhanced enum features:

       |enum FoodType {
       |  candy();
      0|  const FoodType();
       |}
      1|void main() {
       |  final food = FoodType.candy;
       |  print(food);
       |  print(FoodType.values);
       |}

Better to just add a special case to ignore coverage for enum constructors since it's not possible for the user to invoke them.