ruby-changes:56190
From: Nobuyoshi <ko1@a...>
Date: Sat, 22 Jun 2019 09:33:47 +0900 (JST)
Subject: [ruby-changes:56190] Nobuyoshi Nakada: 4d650bc257 (trunk): Fix over-expansion
https://git.ruby-lang.org/ruby.git/commit/?id=4d650bc257 From 4d650bc25737a4d2c0dcc9d4c845688cb5dc85ce Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sat, 22 Jun 2019 09:29:33 +0900 Subject: Fix over-expansion * test/lib/minitest/unit.rb (MiniTest::Assertions#mu_pp_for_diff): do not expand escaped backslash followed by 'n'. diff --git a/test/lib/minitest/unit.rb b/test/lib/minitest/unit.rb index 25fd15d..6ba1c70 100644 --- a/test/lib/minitest/unit.rb +++ b/test/lib/minitest/unit.rb @@ -179,7 +179,7 @@ module MiniTest https://github.com/ruby/ruby/blob/trunk/test/lib/minitest/unit.rb#L179 # 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: diff --git a/test/minitest/test_minitest_unit.rb b/test/minitest/test_minitest_unit.rb index d790a37..c6c8830 100644 --- a/test/minitest/test_minitest_unit.rb +++ b/test/minitest/test_minitest_unit.rb @@ -868,6 +868,13 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/minitest/test_minitest_unit.rb#L868 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 -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/