From 7a74a617ea8ba8deba22a22263f4188419d8d02d Mon Sep 17 00:00:00 2001 From: ksss Date: Sun, 19 Mar 2017 23:04:22 +0900 Subject: Callback should yield with pattern every time --- test/t/string.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/t') diff --git a/test/t/string.rb b/test/t/string.rb index ddc74fa54..c99457d7e 100644 --- a/test/t/string.rb +++ b/test/t/string.rb @@ -373,6 +373,11 @@ assert('String#gsub', '15.2.10.5.18') do assert_equal('A', 'a'.gsub('a'){|w| w.capitalize }) assert_equal("<><>", 'a'.gsub('a', '<\0><\1><\2>')) assert_equal(".h.e.l.l.o.", "hello".gsub("", ".")) + a = [] + assert_equal(".h.e.l.l.o.", "hello".gsub("") { |i| a << i; "." }) + assert_equal(["", "", "", "", "", ""], a) + assert_raise(ArgumentError) { "".gsub } + assert_raise(ArgumentError) { "".gsub("", "", "") } end assert('String#gsub with backslash') do -- cgit v1.2.3