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:
parent
d01fd82187
commit
4d650bc257
2 changed files with 8 additions and 1 deletions
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue