summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-03 03:27:43 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-03 03:27:43 +0000
commitd910ce1f908a70afad5261d91fd6dec0a3708240 (patch)
tree72ac3ecb727d68441d804e30fb310a71edf8b16b /test
parentb10c3b6d51d7fb0597670d88a537d713b445098e (diff)
merge revision(s) 42251,46345,46346: [Backport #9903]
* sprintf.c (ruby__sfvextra): add QUOTE flag to escape unprintable characters. * sprintf.c (ruby__sfvextra): add QUOTE flag to escape unprintable characters. * re.c (match_aref, rb_reg_regsub): consider encoding of captured names, encoding-incompatible should not match. [ruby-dev:48278] [Bug #9903] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@47364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/-ext-/test_printf.rb6
-rw-r--r--test/ruby/test_regexp.rb9
2 files changed, 15 insertions, 0 deletions
diff --git a/test/-ext-/test_printf.rb b/test/-ext-/test_printf.rb
index ca624fcf94..c652e46f20 100644
--- a/test/-ext-/test_printf.rb
+++ b/test/-ext-/test_printf.rb
@@ -22,6 +22,12 @@ class Test_SPrintf < Test::Unit::TestCase
assert_equal("{<#{self.class}:#{object_id}>}", Bug::Printf.v(self))
end
+ def test_quote
+ assert_equal('["\n"]', Bug::Printf.q("\n"))
+ assert_equal('[aaa]', Bug::Printf.q('aaa'))
+ assert_equal('[a a]', Bug::Printf.q('a a'))
+ end
+
def test_encoding
def self.to_s
"\u{3042 3044 3046 3048 304a}"
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb
index 28269fbd63..bbf7e67549 100644
--- a/test/ruby/test_regexp.rb
+++ b/test/ruby/test_regexp.rb
@@ -150,6 +150,15 @@ class TestRegexp < Test::Unit::TestCase
}
end
+ def test_named_capture_nonascii
+ bug9903 = '[ruby-dev:48278] [Bug #9903]'
+
+ key = "\xb1\xb2".force_encoding(Encoding::EUC_JP)
+ m = /(?<#{key}>.*)/.match("xxx")
+ assert_equal("xxx", m[key])
+ assert_raise(IndexError, bug9903) {m[key.dup.force_encoding(Encoding::Shift_JIS)]}
+ end
+
def test_assign_named_capture
assert_equal("a", eval('/(?<foo>.)/ =~ "a"; foo'))
assert_equal("a", eval('foo = 1; /(?<foo>.)/ =~ "a"; foo'))