Alpha Chen 2 years ago
parent 7bc04b20e2
commit 34dce8f404
Signed by: alpha
SSH Key Fingerprint: SHA256:3fOT8fiYQG/aK9ntivV3Bqtg8AYQ7q4nV6ZgihOA20g

@ -327,16 +327,16 @@ module Minitest
# We enter the choices made in a tree.
node = @tree
test_case.choices.each.with_index do |c, i|
if i + 1 < test_case.choices.length || test_case.status == Status::OVERRUN
if node.has_key?(c)
node = node[c]
else
node = node[c] = {}
end
else
node[c] = test_case.status
end
*rest, last = test_case.choices
rest.each do |c|
node = if node.has_key?(c)
node[c]
else
node[c] = {}
end
end
unless last.nil?
node[last] = test_case.status == Status::OVERRUN ? {} : test_case.status
end
test_case.status

@ -471,6 +471,49 @@ class Minitest::ThesisTest < Minitest::Thesis
end
end
def test_refactoring_cache
old = ->(node, choices, status) {
choices.each.with_index do |c, i|
if i + 1 < choices.length || status == Status::OVERRUN
node = if node.has_key?(c)
node[c]
else
node[c] = {}
end
else
node[c] = status
end
end
}
new = ->(node, choices, status) {
*rest, last = choices
rest.each do |c|
node = if node.has_key?(c)
node[c]
else
node[c] = {}
end
end
unless last.nil?
node[last] = status == Status::OVERRUN ? {} : status
end
}
run_test("refactoring_cache", database: {}) do |tc|
old_tree = {}
new_tree = {}
choices = tc.any(lists(integers(0, 10)))
status = Status.new(tc.choice(4))
old.(old_tree, choices, status)
new.(new_tree, choices, status)
assert_equal old_tree, new_tree
end
end
private
def suppress_warnings

Loading…
Cancel
Save