1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Fix over-expansion

* test/lib/minitest/unit.rb (MiniTest::Assertions#mu_pp_for_diff):
  do not expand escaped backslash followed by 'n'.
This commit is contained in:
Nobuyoshi Nakada 2019-06-22 09:29:33 +09:00
parent d01fd82187
commit 4d650bc257
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60
2 changed files with 8 additions and 1 deletions

View file

@ -179,7 +179,7 @@ module MiniTest
# uses mu_pp to do the first pass and then cleans it up.
def mu_pp_for_diff obj
mu_pp(obj).gsub(/\\n/, "\n").gsub(/:0x[a-fA-F0-9]{4,}/m, ':0xXXXXXX')
mu_pp(obj).gsub(/(?<!\\)(?:\\\\)*\K\\n/, "\n").gsub(/:0x[a-fA-F0-9]{4,}/m, ':0xXXXXXX')
end
def _assertions= n # :nodoc:

View file

@ -868,6 +868,13 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
end
end
def test_assert_equal_different_escaped_newline
msg = "--- expected\n+++ actual\n@@ -1,2 +1,2 @@\n \"xxx\n-a\\\\nb\"\n+a\\\\nc\"\n"
util_assert_triggered msg do
@tc.assert_equal "xxx\na\\nb", "xxx\na\\nc"
end
end
def test_assert_in_delta
@tc.assert_in_delta 0.0, 1.0 / 1000, 0.1
end