path_coverage 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +260 -300
- data/exe/path_coverage_report +4 -0
- data/lib/path_coverage/call_trace.rb +109 -0
- data/lib/path_coverage/calls.rb +73 -43
- data/lib/path_coverage/{html_syntax.rb → code_tokens.rb} +35 -33
- data/lib/path_coverage/condition.rb +14 -14
- data/lib/path_coverage/configuration.rb +7 -4
- data/lib/path_coverage/configuration_limits.rb +52 -0
- data/lib/path_coverage/configuration_paths.rb +7 -7
- data/lib/path_coverage/console_summary.rb +28 -26
- data/lib/path_coverage/{site.rb → decision.rb} +2 -2
- data/lib/path_coverage/decision_locations.rb +76 -0
- data/lib/path_coverage/{site_paths.rb → decision_paths.rb} +13 -11
- data/lib/path_coverage/{site_tree.rb → decision_tree.rb} +25 -16
- data/lib/path_coverage/fold_branches.rb +18 -0
- data/lib/path_coverage/fold_cells.rb +42 -0
- data/lib/path_coverage/{html_tree.rb → fold_rows.rb} +43 -72
- data/lib/path_coverage/gaps.rb +33 -15
- data/lib/path_coverage/json_reader.rb +54 -19
- data/lib/path_coverage/json_reports.rb +109 -0
- data/lib/path_coverage/json_writer.rb +29 -14
- data/lib/path_coverage/kernel.rb +77 -58
- data/lib/path_coverage/kinds/base.rb +16 -16
- data/lib/path_coverage/kinds/block.rb +16 -15
- data/lib/path_coverage/kinds/case.rb +14 -12
- data/lib/path_coverage/kinds/chain.rb +40 -11
- data/lib/path_coverage/kinds/choice.rb +4 -3
- data/lib/path_coverage/kinds/contains.rb +40 -32
- data/lib/path_coverage/kinds/safe.rb +38 -26
- data/lib/path_coverage/kinds/write.rb +6 -6
- data/lib/path_coverage/kinds.rb +2 -2
- data/lib/path_coverage/leaving.rb +52 -0
- data/lib/path_coverage/loop_forks.rb +57 -0
- data/lib/path_coverage/loop_nodes.rb +91 -0
- data/lib/path_coverage/manifest.rb +92 -58
- data/lib/path_coverage/manifest_blocks.rb +5 -26
- data/lib/path_coverage/manifest_case.rb +2 -2
- data/lib/path_coverage/manifest_chains.rb +8 -8
- data/lib/path_coverage/manifest_choices.rb +23 -20
- data/lib/path_coverage/manifest_disabled.rb +97 -0
- data/lib/path_coverage/manifest_folding.rb +43 -40
- data/lib/path_coverage/manifest_ignoring.rb +6 -6
- data/lib/path_coverage/manifest_writes.rb +11 -10
- data/lib/path_coverage/measured_by.rb +20 -0
- data/lib/path_coverage/merge.rb +7 -7
- data/lib/path_coverage/method_loops.rb +172 -0
- data/lib/path_coverage/method_statements.rb +150 -134
- data/lib/path_coverage/method_ways.rb +170 -0
- data/lib/path_coverage/paths_context.rb +104 -0
- data/lib/path_coverage/paths_fitting.rb +31 -0
- data/lib/path_coverage/paths_forks.rb +72 -0
- data/lib/path_coverage/paths_gaps.rb +137 -0
- data/lib/path_coverage/paths_leaving.rb +40 -0
- data/lib/path_coverage/paths_report.rb +16 -16
- data/lib/path_coverage/paths_rescues.rb +146 -0
- data/lib/path_coverage/paths_scopes.rb +37 -0
- data/lib/path_coverage/paths_tree.rb +203 -0
- data/lib/path_coverage/paths_way_lists.rb +72 -0
- data/lib/path_coverage/paths_ways.rb +193 -0
- data/lib/path_coverage/recorder.rb +71 -36
- data/lib/path_coverage/recorder_blocks.rb +17 -17
- data/lib/path_coverage/recorder_cases.rb +12 -11
- data/lib/path_coverage/recorder_chains.rb +12 -12
- data/lib/path_coverage/recorder_writes.rb +9 -9
- data/lib/path_coverage/render.rb +58 -51
- data/lib/path_coverage/rescue_forks.rb +174 -0
- data/lib/path_coverage/result.rb +32 -31
- data/lib/path_coverage/rewriter.rb +116 -35
- data/lib/path_coverage/rewriter_nested.rb +13 -13
- data/lib/path_coverage/runs_report.rb +84 -0
- data/lib/path_coverage/source_lines.rb +16 -16
- data/lib/path_coverage/source_report.rb +100 -0
- data/lib/path_coverage/stable_leaves.rb +162 -0
- data/lib/path_coverage/statement_arms.rb +53 -38
- data/lib/path_coverage/summary.rb +4 -62
- data/lib/path_coverage/totals.rb +12 -10
- data/lib/path_coverage/version.rb +1 -1
- data/lib/path_coverage/walk.rb +106 -0
- data/lib/path_coverage/way_algebras.rb +127 -0
- data/lib/path_coverage/ways_report.rb +91 -0
- data/lib/path_coverage/ways_totals.rb +46 -0
- data/lib/path_coverage/within_methods.rb +152 -97
- metadata +39 -30
- data/lib/path_coverage/card.rb +0 -14
- data/lib/path_coverage/card_tree.rb +0 -186
- data/lib/path_coverage/card_ways.rb +0 -140
- data/lib/path_coverage/html/file.html +0 -33
- data/lib/path_coverage/html/index.html +0 -29
- data/lib/path_coverage/html/settings.js +0 -50
- data/lib/path_coverage/html/side.js +0 -599
- data/lib/path_coverage/html/sort.js +0 -34
- data/lib/path_coverage/html/style.css +0 -484
- data/lib/path_coverage/html/tabs.js +0 -15
- data/lib/path_coverage/html/theme.js +0 -27
- data/lib/path_coverage/html_branch.rb +0 -30
- data/lib/path_coverage/html_cards.rb +0 -88
- data/lib/path_coverage/html_cells.rb +0 -71
- data/lib/path_coverage/html_file.rb +0 -123
- data/lib/path_coverage/html_index.rb +0 -128
- data/lib/path_coverage/html_index_head.rb +0 -29
- data/lib/path_coverage/html_labels.rb +0 -16
- data/lib/path_coverage/html_methods.rb +0 -66
- data/lib/path_coverage/html_nav.rb +0 -67
- data/lib/path_coverage/html_report.rb +0 -131
- data/lib/path_coverage/html_statements.rb +0 -186
- data/lib/path_coverage/html_tabs.rb +0 -26
- data/lib/path_coverage/html_template.rb +0 -26
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
require_relative 'manifest'
|
|
2
|
-
require_relative 'method_statements'
|
|
3
|
-
require_relative 'site_paths'
|
|
4
|
-
require_relative 'site_tree'
|
|
5
|
-
|
|
6
|
-
module PathCoverage
|
|
7
|
-
# How the rows of each card nest: for each row, the site it
|
|
8
|
-
# runs inside, the arm of that site it is in, and the paths of
|
|
9
|
-
# that site on which it runs, so a reader can tell which paths
|
|
10
|
-
# reach a row, and count the paths through a card as a whole.
|
|
11
|
-
module CardTree
|
|
12
|
-
# Part of a site's code that a row can be inside: an arm of
|
|
13
|
-
# statements, or a leaf; owner the key of the site's row,
|
|
14
|
-
# range its bytes, arm its arm's name, nil for a leaf, on
|
|
15
|
-
# the indices of the site's possible paths that run it, and
|
|
16
|
-
# leaf a leaf's index among the site's leaves, nil for an arm.
|
|
17
|
-
Region = Data.define(:owner, :range, :arm, :on, :leaf)
|
|
18
|
-
|
|
19
|
-
# The place of a row inside no other row's site.
|
|
20
|
-
TOP = {
|
|
21
|
-
'parent' => nil, 'in' => nil, 'on' => nil,
|
|
22
|
-
'leaf' => nil, 'gives' => nil
|
|
23
|
-
}.freeze
|
|
24
|
-
|
|
25
|
-
# Example: def f(a); if a then 1 end; end gives the value
|
|
26
|
-
# row 1 its parent, the if, in its then arm, on its path 0.
|
|
27
|
-
# { def site => { "line:column" => { 'parent' =>, 'in' =>,
|
|
28
|
-
# 'on' =>, 'leaf' =>, 'gives' => } } } for each def in
|
|
29
|
-
# source, a row keyed by where it is named. parent is the
|
|
30
|
-
# "line:column" of the site the row runs inside, in the name
|
|
31
|
-
# of its arm, on the indices of that site's possible paths,
|
|
32
|
-
# as SitePaths.possible orders them, that run the row, leaf
|
|
33
|
-
# the index of that site's leaf holding it, and gives, for a
|
|
34
|
-
# row whose site is the whole of that leaf, the leaf's
|
|
35
|
-
# outcome on each of the row's own possible paths, nil where
|
|
36
|
-
# not known; each nil where it does not apply.
|
|
37
|
-
def self.of(source, path, sites = nil)
|
|
38
|
-
sites = Manifest.sites(source, path) if sites.nil?
|
|
39
|
-
cards = MethodStatements.of(source, path, sites)
|
|
40
|
-
cards.transform_values { |rows| nested(source, sites, rows) }
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
# { "line:column" => its place } for each of rows, a card's,
|
|
44
|
-
# each placed in the innermost region of another row's site
|
|
45
|
-
# holding all of its own site's code, or, for a row that is
|
|
46
|
-
# no site, where it starts: a site starting where its child
|
|
47
|
-
# does, eg an || whose first operand is an any?, holds that
|
|
48
|
-
# child, and is not held by it.
|
|
49
|
-
def self.nested(source, sites, rows)
|
|
50
|
-
starts = line_starts(source)
|
|
51
|
-
regions = card_regions(source, sites, rows)
|
|
52
|
-
rows.to_h do |row|
|
|
53
|
-
at = starts[row.line - 1] + row.column
|
|
54
|
-
site = row.site ? sites.fetch(row.site) : nil
|
|
55
|
-
span = site ? site.extent : at...(at + 1)
|
|
56
|
-
key = key_of(row)
|
|
57
|
-
[key, placed(key, span, regions, site)]
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
# The regions of the sites of rows, a card's, sites being
|
|
62
|
-
# { site => Condition }.
|
|
63
|
-
def self.card_regions(source, sites, rows)
|
|
64
|
-
rows.select(&:site).flat_map do |row|
|
|
65
|
-
regions_of(source, key_of(row), sites.fetch(row.site))
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
# The place of the row keyed key, its code the bytes span,
|
|
70
|
-
# site its Condition, nil for a row that is no site: in the
|
|
71
|
-
# site owning the smallest region of another row holding
|
|
72
|
-
# span, as place gives it; TOP for a row in no such region.
|
|
73
|
-
def self.placed(key, span, regions, site)
|
|
74
|
-
holding = holding(key, span, regions)
|
|
75
|
-
inner = smallest(holding)
|
|
76
|
-
return TOP if inner.nil?
|
|
77
|
-
|
|
78
|
-
owner = inner.owner
|
|
79
|
-
own = holding.group_by(&:owner).fetch(owner)
|
|
80
|
-
place(owner, own).merge(leaf_place(own, site))
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
# The leaf and gives of a row's place, own being the regions
|
|
84
|
-
# of its parent holding it, site its Condition: the index of
|
|
85
|
-
# the innermost leaf holding it; and, when site is the whole
|
|
86
|
-
# of that leaf, site's value on each of its possible paths,
|
|
87
|
-
# as its kind gives them, the leaf's outcome there. Neither
|
|
88
|
-
# for a row that is no site, a return or a raise, which gives
|
|
89
|
-
# its parent nothing.
|
|
90
|
-
def self.leaf_place(own, site)
|
|
91
|
-
return { 'leaf' => nil, 'gives' => nil } if site.nil?
|
|
92
|
-
|
|
93
|
-
leaf = smallest(own.reject(&:arm))
|
|
94
|
-
whole = leaf && site.extent == leaf.range
|
|
95
|
-
gives = whole ? SitePaths.values(site) : nil
|
|
96
|
-
{ 'leaf' => leaf&.leaf, 'gives' => gives }
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
# The regions of regions holding all of the bytes span, but
|
|
100
|
-
# for those of the row keyed key itself.
|
|
101
|
-
def self.holding(key, span, regions)
|
|
102
|
-
held = regions.group_by do |region|
|
|
103
|
-
region.owner != key && region.range.cover?(span)
|
|
104
|
-
end
|
|
105
|
-
held.fetch(true, [])
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
# A row's place in the site of the row keyed owner, own being
|
|
109
|
-
# the regions of that site holding the row: the innermost arm
|
|
110
|
-
# of them, nil for none, and the paths on which every one of
|
|
111
|
-
# them runs, as the row runs only where all of them do.
|
|
112
|
-
def self.place(owner, own)
|
|
113
|
-
arm = smallest(own.select(&:arm))
|
|
114
|
-
on = own.map(&:on).reduce(:&)
|
|
115
|
-
{ 'parent' => owner, 'in' => arm&.arm, 'on' => on }
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
# The region of regions with the fewest bytes; nil for none.
|
|
119
|
-
def self.smallest(regions)
|
|
120
|
-
regions.min_by { |region| region.range.size }
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
# The regions of condition, the site of the row keyed owner:
|
|
124
|
-
# its arms', and its leaves'.
|
|
125
|
-
def self.regions_of(source, owner, condition)
|
|
126
|
-
possible = SitePaths.possible(condition)
|
|
127
|
-
node = SiteTree.node(source, condition, possible, (0..).each)
|
|
128
|
-
arm_regions(owner, condition, node) +
|
|
129
|
-
leaf_regions(owner, condition, possible)
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
# The regions of condition's leaves, in no arm, each run on
|
|
133
|
-
# the paths of possible with an outcome at its index.
|
|
134
|
-
def self.leaf_regions(owner, condition, possible)
|
|
135
|
-
condition.leaves.each_with_index.map do |range, index|
|
|
136
|
-
skipped = possible.each_index.group_by do |i|
|
|
137
|
-
possible[i][index].nil?
|
|
138
|
-
end
|
|
139
|
-
on = skipped.fetch(false)
|
|
140
|
-
Region.new(owner:, range:, arm: nil, on:, leaf: index)
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
# The regions of the arms in condition, node its tree, each
|
|
145
|
-
# operand's node at its own index: of its own arms, and of
|
|
146
|
-
# those of each condition nested in it, in an operand or in
|
|
147
|
-
# an arm's body.
|
|
148
|
-
def self.arm_regions(owner, condition, node)
|
|
149
|
-
built = condition.operands.zip(node[:operands])
|
|
150
|
-
built.flat_map do |operand, operand_node|
|
|
151
|
-
case operand
|
|
152
|
-
when Condition then arm_regions(owner, operand, operand_node)
|
|
153
|
-
when Arm then arm_region(owner, operand, operand_node)
|
|
154
|
-
else []
|
|
155
|
-
end
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
# The regions of arm, node its node: its own, named by its
|
|
160
|
-
# kind and run on the paths that take it, none for an arm
|
|
161
|
-
# with no statements, which holds no row; then its body's.
|
|
162
|
-
def self.arm_region(owner, arm, node)
|
|
163
|
-
body = arm.body ? arm_regions(owner, arm.body, node[:body]) : []
|
|
164
|
-
return body if arm.extent.nil?
|
|
165
|
-
|
|
166
|
-
cells = node[:cells]
|
|
167
|
-
on = cells.each_index.group_by { cells[_1] }.fetch(true, [])
|
|
168
|
-
own = Region.new(owner:, range: arm.extent, arm: arm.kind.to_s,
|
|
169
|
-
on:, leaf: nil)
|
|
170
|
-
[own, *body]
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
# The "line:column" key of row, from its name.
|
|
174
|
-
def self.key_of(row)
|
|
175
|
-
row.name.split(':').last(2).join(':')
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
# The byte offset where each line of source starts, first
|
|
179
|
-
# line first.
|
|
180
|
-
def self.line_starts(source)
|
|
181
|
-
source.each_line.reduce([0]) do |starts, line|
|
|
182
|
-
starts << (starts.last + line.bytesize)
|
|
183
|
-
end
|
|
184
|
-
end
|
|
185
|
-
end
|
|
186
|
-
end
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
require_relative 'card_tree'
|
|
2
|
-
require_relative 'manifest'
|
|
3
|
-
require_relative 'method_statements'
|
|
4
|
-
require_relative 'site_paths'
|
|
5
|
-
|
|
6
|
-
module PathCoverage
|
|
7
|
-
# The number of ways one call can go through each card, folded
|
|
8
|
-
# over its tree, as CardTree places its rows. Each row gives a
|
|
9
|
-
# pair, [ways that go on, ways that leave the method]: a return
|
|
10
|
-
# or a raise leaves, and so does each path of a site taking an
|
|
11
|
-
# arm that returns or raises, eg return 0 if a. Rows one after
|
|
12
|
-
# another multiply, but only the ways that go on reach the next
|
|
13
|
-
# row; a site adds up its paths, each with the rows it runs on
|
|
14
|
-
# that path one after another; and a row that is the whole of a
|
|
15
|
-
# leaf counts only those of its paths that give the leaf the
|
|
16
|
-
# outcome the path has, so no impossible way is counted where
|
|
17
|
-
# gives knows it. A block's body counts once.
|
|
18
|
-
class CardWays
|
|
19
|
-
# Example: { "k.rb:1:0" => 3 } for def f(a, b), return 0 if a,
|
|
20
|
-
# then a ?: of b: 1 way leaves, 2 go on.
|
|
21
|
-
# { def site => its ways } for each def in source, its sites
|
|
22
|
-
# those of no settings.
|
|
23
|
-
def self.of(source, path)
|
|
24
|
-
sites = Manifest.sites(source, path)
|
|
25
|
-
cards = MethodStatements.of(source, path, sites)
|
|
26
|
-
cards.transform_values { |rows| card(source, sites, rows) }
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# The ways through a card of rows in source, sites being
|
|
30
|
-
# { site => Condition }, as Manifest.sites gives them.
|
|
31
|
-
def self.card(source, sites, rows)
|
|
32
|
-
places = CardTree.nested(source, sites, rows)
|
|
33
|
-
new(source, rows, places, sites).total
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# The pair of rows one after another, from their pairs: the
|
|
37
|
-
# ways that go on through them all, and those that leave at
|
|
38
|
-
# one of them, having gone on through every one before it.
|
|
39
|
-
def self.sequence(pairs)
|
|
40
|
-
pairs.reduce([1, 0]) do |(on, left), (more, leaving)|
|
|
41
|
-
[on * more, left + (on * leaving)]
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
# The fold of rows, a card's in source, placed as places has
|
|
46
|
-
# them, each site row's Condition among sites.
|
|
47
|
-
def initialize(source, rows, places, sites)
|
|
48
|
-
@source = source
|
|
49
|
-
@rows = rows.to_h { |row| [CardTree.key_of(row), row] }
|
|
50
|
-
@places = places
|
|
51
|
-
@sites = sites
|
|
52
|
-
@children = places.keys.group_by { places[_1]['parent'] }
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
# The ways through the card: its top rows' pairs, one after
|
|
56
|
-
# another, those that go on and those that leave.
|
|
57
|
-
def total
|
|
58
|
-
tops = @children.fetch(nil, []).map { |key| pair_of(key) }
|
|
59
|
-
CardWays.sequence(tops).sum
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
# The pair of the row keyed key: a site's adds up its paths'
|
|
63
|
-
# pairs; any other row is a return or a raise, as no other is
|
|
64
|
-
# a row, so leaves.
|
|
65
|
-
def pair_of(key)
|
|
66
|
-
row = @rows[key]
|
|
67
|
-
return [0, 1] unless row.site
|
|
68
|
-
|
|
69
|
-
pairs = possible(row.site).each_index.map do |path|
|
|
70
|
-
pair_on(key, path)
|
|
71
|
-
end
|
|
72
|
-
added(pairs)
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
# The pair of the site row keyed key on its path at index
|
|
76
|
-
# path: the rows it runs on that path, one after another, each
|
|
77
|
-
# given that path's outcomes; every way of it leaving when the
|
|
78
|
-
# path takes an arm that leaves.
|
|
79
|
-
def pair_on(key, path)
|
|
80
|
-
outcomes = possible(@rows[key].site)[path]
|
|
81
|
-
pairs = running(key, path).map do |child|
|
|
82
|
-
child_pair(child, outcomes)
|
|
83
|
-
end
|
|
84
|
-
pair = CardWays.sequence(pairs)
|
|
85
|
-
leaving(key).include?(path) ? [0, pair.sum] : pair
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
# The keys of the rows the site row keyed key runs on its path
|
|
89
|
-
# at index path, in the order they are written.
|
|
90
|
-
def running(key, path)
|
|
91
|
-
runs = @children.fetch(key, []).group_by do |child|
|
|
92
|
-
@places[child]['on'].include?(path)
|
|
93
|
-
end
|
|
94
|
-
runs.fetch(true, [])
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
# The pair of the row keyed child, its parent's path having
|
|
98
|
-
# outcomes: all of its own, for a row that gives nothing; else
|
|
99
|
-
# those of only its paths that give its leaf the outcome that
|
|
100
|
-
# path has, or that give what is not known.
|
|
101
|
-
def child_pair(child, outcomes)
|
|
102
|
-
place = @places[child]
|
|
103
|
-
gives = place['gives']
|
|
104
|
-
return pair_of(child) if gives.nil?
|
|
105
|
-
|
|
106
|
-
fits = [nil, outcome_of(outcomes, place)]
|
|
107
|
-
pairs = gives.each_index.map do |path|
|
|
108
|
-
fits.include?(gives[path]) ? pair_on(child, path) : [0, 0]
|
|
109
|
-
end
|
|
110
|
-
added(pairs)
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
# The outcome on a parent's path, outcomes, of the leaf place
|
|
114
|
-
# names.
|
|
115
|
-
def outcome_of(outcomes, place)
|
|
116
|
-
outcomes[place['leaf']]
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
# The indices of the paths of the site row keyed key that take
|
|
120
|
-
# an arm whose code returns or raises.
|
|
121
|
-
def leaving(key)
|
|
122
|
-
site = @sites.fetch(@rows[key].site)
|
|
123
|
-
regions = CardTree.regions_of(@source, key, site)
|
|
124
|
-
left = regions.group_by do |region|
|
|
125
|
-
region.arm && @source.byteslice(region.range).match?(LEAVES)
|
|
126
|
-
end
|
|
127
|
-
left.fetch(true, []).flat_map(&:on)
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
# pairs added up, each part on its own.
|
|
131
|
-
def added(pairs)
|
|
132
|
-
pairs.reduce([0, 0]) { |(a, b), (c, d)| [a + c, b + d] }
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
# The possible paths of the site named site.
|
|
136
|
-
def possible(site)
|
|
137
|
-
SitePaths.possible(@sites.fetch(site))
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
end
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8"/>
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
6
|
-
<title>{{path}} · Path coverage</title>
|
|
7
|
-
<style>
|
|
8
|
-
/*<![CDATA[*/
|
|
9
|
-
{{style}}
|
|
10
|
-
/*]]>*/
|
|
11
|
-
</style>
|
|
12
|
-
</head>
|
|
13
|
-
<body>
|
|
14
|
-
<main class="page">
|
|
15
|
-
<header class="head" data-head="">
|
|
16
|
-
<div class="top"><p class="title"><a data-index="" href="{{index}}">Path coverage</a></p><h1 class="path"><a data-row="" href="{{index}}#row-{{path}}">{{path}}</a></h1><button type="button" class="theme" aria-label="Light or dark"></button></div>
|
|
17
|
-
{{jumps}}
|
|
18
|
-
</header>
|
|
19
|
-
<div class="box">
|
|
20
|
-
<div class="rail">
|
|
21
|
-
{{rail}}
|
|
22
|
-
</div>
|
|
23
|
-
{{listing}}
|
|
24
|
-
<div class="divider" role="separator" aria-orientation="vertical" title="Drag to share the width between paths and code"></div>
|
|
25
|
-
</div>
|
|
26
|
-
</main>
|
|
27
|
-
<script>
|
|
28
|
-
//<![CDATA[
|
|
29
|
-
{{script}}
|
|
30
|
-
//]]>
|
|
31
|
-
</script>
|
|
32
|
-
</body>
|
|
33
|
-
</html>
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8"/>
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
6
|
-
<title>Path coverage</title>
|
|
7
|
-
<style>
|
|
8
|
-
/*<![CDATA[*/
|
|
9
|
-
{{style}}
|
|
10
|
-
/*]]>*/
|
|
11
|
-
</style>
|
|
12
|
-
</head>
|
|
13
|
-
<body>
|
|
14
|
-
<main class="page">
|
|
15
|
-
<header class="head" data-head="">
|
|
16
|
-
<div class="top"><h1 class="title">Path coverage</h1><button type="button" class="theme" aria-label="Light or dark"></button></div>
|
|
17
|
-
</header>
|
|
18
|
-
{{tabs}}
|
|
19
|
-
<div class="box">
|
|
20
|
-
{{tables}}
|
|
21
|
-
</div>{{ignored}}
|
|
22
|
-
</main>
|
|
23
|
-
<script>
|
|
24
|
-
//<![CDATA[
|
|
25
|
-
{{script}}
|
|
26
|
-
//]]>
|
|
27
|
-
</script>
|
|
28
|
-
</body>
|
|
29
|
-
</html>
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// The report's settings, eg its theme. Each is carried by
|
|
2
|
-
// every link to another page of the report, as ?name=, since some
|
|
3
|
-
// browsers keep nothing shared between a report's local files, and
|
|
4
|
-
// is also kept in the browser where it can be, for a page opened
|
|
5
|
-
// afresh.
|
|
6
|
-
window.pathCoverageSettings = (function () {
|
|
7
|
-
// The value of setting name the link that opened this page
|
|
8
|
-
// carried, else the one last kept, when it is one of allowed;
|
|
9
|
-
// else null.
|
|
10
|
-
function given(name, allowed) {
|
|
11
|
-
var match = new RegExp('[?&]' + name + '=([a-z]+)').exec(window.location.search);
|
|
12
|
-
if (match && allowed.indexOf(match[1]) >= 0) { return match[1]; }
|
|
13
|
-
try {
|
|
14
|
-
var kept = window.localStorage.getItem('path_coverage.' + name);
|
|
15
|
-
return allowed.indexOf(kept) >= 0 ? kept : null;
|
|
16
|
-
} catch (e) { return null; }
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Keeps value as setting name's, where the browser allows it.
|
|
20
|
-
function keep(name, value) {
|
|
21
|
-
try { window.localStorage.setItem('path_coverage.' + name, value); } catch (e) { /* carried by links only */ }
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// href, a link to another page of the report, with its ?name=
|
|
25
|
-
// set to value, before any #fragment, its other ?settings kept.
|
|
26
|
-
function carrying(href, name, value) {
|
|
27
|
-
var hash = href.indexOf('#');
|
|
28
|
-
var fragment = hash < 0 ? '' : href.slice(hash);
|
|
29
|
-
var rest = hash < 0 ? href : href.slice(0, hash);
|
|
30
|
-
var query = rest.indexOf('?');
|
|
31
|
-
var page = query < 0 ? rest : rest.slice(0, query);
|
|
32
|
-
var settings = query < 0 ? [] : rest.slice(query + 1).split('&').filter(function (pair) {
|
|
33
|
-
return pair && pair.split('=')[0] !== name;
|
|
34
|
-
});
|
|
35
|
-
settings.push(name + '=' + value);
|
|
36
|
-
return page + '?' + settings.join('&') + fragment;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Makes every link to another of the report's pages carry value
|
|
40
|
-
// as setting name's.
|
|
41
|
-
function carry(name, value) {
|
|
42
|
-
document.querySelectorAll('a[href]').forEach(function (link) {
|
|
43
|
-
var href = link.getAttribute('href');
|
|
44
|
-
if (/^[a-z]+:|^#/.test(href) || !/\.html(\?|#|$)/.test(href)) { return; }
|
|
45
|
-
link.setAttribute('href', carrying(href, name, value));
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return { given: given, keep: keep, carry: carry };
|
|
50
|
-
})();
|