Skip to content

Commit

Permalink
Fix over-expansion
Browse files Browse the repository at this point in the history
* test/lib/minitest/unit.rb (MiniTest::Assertions#mu_pp_for_diff):
  do not expand escaped backslash followed by 'n'.
  • Loading branch information
nobu committed Jun 22, 2019
1 parent d01fd82 commit 4d650bc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/lib/minitest/unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def mu_pp obj
# 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:
Expand Down
7 changes: 7 additions & 0 deletions test/minitest/test_minitest_unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,13 @@ def test_assert_equal_different_short_multiline
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
Expand Down

0 comments on commit 4d650bc

Please sign in to comment.