ruby-changes:62940
From: Nobuyoshi <ko1@a...>
Date: Mon, 14 Sep 2020 18:28:38 +0900 (JST)
Subject: [ruby-changes:62940] 9fbbbadc96 (master): Added just working Test::Unit::CoreAssertions#diff
https://git.ruby-lang.org/ruby.git/commit/?id=9fbbbadc96 From 9fbbbadc9634ec4cdfe378bba62bfb706f4bb03a Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Thu, 16 Jul 2020 17:38:58 +0900 Subject: 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. diff --git a/tool/lib/test/unit/core_assertions.rb b/tool/lib/test/unit/core_assertions.rb index adb797b..235b116 100644 --- a/tool/lib/test/unit/core_assertions.rb +++ b/tool/lib/test/unit/core_assertions.rb @@ -635,6 +635,22 @@ eom https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit/core_assertions.rb#L635 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 -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/