summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_string.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index 972f326ab2..9440f93ed4 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -674,6 +674,21 @@ class TestString < Test::Unit::TestCase
assert_raise(ArgumentError) { "foo".gsub }
end
+ def test_gsub_encoding
+ a = S("hello world")
+ a.force_encoding Encoding::UTF_8
+
+ b = S("hi")
+ b.force_encoding Encoding::US_ASCII
+
+ assert_equal Encoding::UTF_8, a.gsub(/hello/, b).encoding
+
+ c = S("everybody")
+ c.force_encoding Encoding::US_ASCII
+
+ assert_equal Encoding::UTF_8, a.gsub(/world/, c).encoding
+ end
+
def test_gsub!
a = S("hello")
b = a.dup