### ----------------------------------------------------
### -- Code::Coverage
### -- Licenses: Artistic-2.0
### -- Authors: Elizabeth Mattijsen
### -- File: t/01-basic.rakutest
### ----------------------------------------------------
use Test;

use Code::Coverage;

plan 14;

my $tester := $*PROGRAM.sibling("cover.raku").absolute;

my $cc := Code::Coverage.new(
  targets => $tester,
  runners => $tester,
);
is $cc.coverables{$tester}.line-numbers,
  "5 7 8 9 11 12 15 16 17 18 20 21 22 23 27 29 30 32 33",
  "are the coverables ok";

$cc.run;
is $cc.out, "alas\n", "out on first run ok";
is $cc.err, "",       "err on first run ok";
is $cc.covered{$tester},
  "1 5 7 9 12 15 20 22 23 27 29 30 33",
  "is the first coverage ok";

$cc.run(42);
is $cc.out, "84\n", "out on first run ok";
is $cc.err, "",     "err on first run ok";
is $cc.covered{$tester},
  "1 5 7 8 9 12 15 20 22 23 27 29 30 33",
  "is the second coverage ok";

is $cc.missed{$tester},
  "11 16 17 18 21 32",
  "is missed ok";

is $cc.coverage.head.value, "68.42%", "is the coverage ok";

is $cc.source($tester).absolute, $tester, 'can we get the source';

is $cc.num-coverable-lines, 19, 'num-coverable-lines ok';
is $cc.num-covered-lines,   14, 'num-covered-lines ok';
is $cc.num-missed-lines,     6, 'num-missed-lines ok';
is $cc.max-lines,           19, 'max-lines ok';

# vim: expandtab shiftwidth=4


