Jump to content

Functional coverage tree: Difference between revisions

m
→‎{{header|Perl 6}}: tweak, tweak, and restore comments
m (→‎{{header|Perl 6}}: more idiomatic: matching, string formatting)
m (→‎{{header|Perl 6}}: tweak, tweak, and restore comments)
Line 1,740:
 
sub walktree ($data) {
my (@parts, $cnt);
 
my $cnt = 1;
while ($data ~~ m:nth($cnt++$cnt)/$<head>=[(\s*) {} \N+\n ] # split off one level as 'head' (or terminal 'leaf')
$<body>=[[$0 \s+ \N+\n]*]/ ) { # next sub-level is 'body' (defined by extra depth of indentation)
 
my ($head, $body) = ($<head>, $<body>);
$head ~~ /^.*? \| ($<weight>=[\S*)] \s*\| ($<coverage>=[\S*)] \s*\|/; # save values of weight and coverage (if any) for later
my $weight = ($0 ne '' ?? $0 !! 1).fmt('%-8s');
my $coverage = ($1 ne '' ?? $1 !! 0).fmt('%-10s');
 
my ($w, $wsum) = (0, 0);
Line 1,756 ⟶ 1,754:
for walktree( $body );
 
my $coverageweight = (~$wsum/$w<weight> or 1).fmt('%-10.2g8s') unless $w == 0;
my $coverage = ($1w ne '' ?? $1 !!== 0).fmt('%-10s');
my $weight = ($0 ne '' ?? (~$0<coverage> !!or 10).fmt('%-8s10s');
!! ($wsum/$w) .fmt('%-10.2g');
@parts.push: [$head.subst(/\|\N+/, "|$weight|$coverage|"), $weight, $coverage ];
}
2,392

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.