-
Notifications
You must be signed in to change notification settings - Fork 3
/
09-coverable-supplier.rakutest
86 lines (75 loc) · 2.71 KB
/
09-coverable-supplier.rakutest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
use Test;
use lib 'lib';
use lib 't/lib';
use App::Racoco::Coverable::Coverable;
use App::Racoco::Coverable::CoverableLinesSupplier;
use Fixture;
use TestHelper;
plan 7;
my ($supplier, $index, $file-name);
sub setup(
:$hash, :$time = 123, :@lines,
:$hash-c, :$time-c, :@lines-c,
:$file, :$use-index = True
) {
plan $*plan;
$file-name = $file;
my $indexed = Coverable.new(
:$file-name,
timestamp => Instant.from-posix($time-c // $time),
hashcode => $hash-c // $hash,
lines => @lines-c // @lines
);
$index = Fixture::testIndex($use-index ?? $indexed !! ());
my $precomp = Fixture::fakePath($file-name, :modified($time));
my $precomp-supplier = Fixture::testPrecompSupplier($file-name, $precomp);
my $hashcode-reader = Fixture::testHashcodeReader($precomp.Str, $hash);
my $outliner = Fixture::testOutliner($precomp.Str, @lines);
$supplier = CoverableLinesSupplier.new(:$index, :supplier($precomp-supplier), :$hashcode-reader, :$outliner);
}
'01-from-index'.&test(:1plan, {
setup(:file<info-from-index>,
:hash<hashcode>, lines => (1, 2, 3), lines-c => (4, 5, 6));
is $supplier.supply(:file-name<info-from-index>), (4, 5, 6), 'from-index ok';
});
'02-obsolete-hash'.&test(:2plan, {
setup(:file<obsolete-hash>,
:hash<hashcode>, :hash-c<obsolete>,
lines => (1, 2, 3), lines-c => (4, 5, 6));
is $supplier.supply(:$file-name), (1, 2, 3), 'obsolete-hash ok';
is $index.retrieve(:$file-name).lines, (1, 2, 3), 'after index';
});
'03-obsolete-time-never-mind'.&test(:1plan, {
setup(:file<obsolete-time>,
:123time, :122time-c, :hash<hashcode>,
lines => (1, 2, 3), lines-c => (4, 5, 6));
is $supplier.supply(:$file-name), (4, 5, 6), 'obsolete-time ok';
});
'04-empty-index'.&test(:2plan, {
setup(:file<empty-index>,
:hash<hashcode>, lines => (1, 2, 3),
:!use-index);
is $supplier.supply(:$file-name), (1, 2, 3), 'empty-index ok';
is $index.retrieve(:$file-name).lines, (1, 2, 3), 'after index';
});
'05-moarvm-from-index-and-outline-good'.&test(:2plan, {
setup(:file<moarvm-hash>,
:hash<hashcode>, :hash-c<MOARVM>,
lines => (1, 2, 3), lines-c => (4, 5, 6));
is $supplier.supply(:$file-name), (1, 2, 3), 'outline';
is $index.retrieve(:$file-name).hashcode, 'hashcode', 'after index';
});
'06-moarvm-from-index-and-outline-moarvm'.&test(:2plan, {
setup(:file<moarvm-hash>,
:hash<MOARVM>, :hash-c<MOARVM>,
lines => (1, 2, 3), lines-c => (4, 5, 6));
is $supplier.supply(:$file-name), (1, 2, 3), 'outline';
is $index.retrieve(:$file-name).lines, (4, 5, 6), 'after index';
});
'07-empty-index-and-outline-moarvm'.&test(:2plan, {
setup(:file<moarvm-hash>, :!use-index,
:hash<MOARVM>, lines => (1, 2, 3));
is $supplier.supply(:$file-name), (1, 2, 3), 'outline';
nok $index.retrieve(:$file-name), 'after index';
});
done-testing