summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-07-16 17:38:58 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-09-14 18:19:40 +0900
commit9fbbbadc9634ec4cdfe378bba62bfb706f4bb03a (patch)
treebc89ed3f05ae51d7c90277b1764d3cf1a6898ee5 /tool
parentd52dffd817d9285f7600138e2f69f46891fff845 (diff)
Added just working Test::Unit::CoreAssertions#diff
This is not "diff", but show expected and actual results both, just to get rid of `NoMethodError` when an assertion failed.
Diffstat (limited to 'tool')
-rw-r--r--tool/lib/test/unit/core_assertions.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/tool/lib/test/unit/core_assertions.rb b/tool/lib/test/unit/core_assertions.rb
index adb797ba16..235b116cb7 100644
--- a/tool/lib/test/unit/core_assertions.rb
+++ b/tool/lib/test/unit/core_assertions.rb
@@ -635,6 +635,22 @@ eom
super
end
end
+
+ def diff(exp, act)
+ require 'pp'
+ q = PP.new(+"")
+ q.guard_inspect_key do
+ q.group(2, "expected: ") do
+ q.pp exp
+ end
+ q.text q.newline
+ q.group(2, "actual: ") do
+ q.pp act
+ end
+ q.flush
+ end
+ q.output
+ end
end
end
end