|
|
|
@ -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
|
|
|
|
|