diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_literal.rb | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/test/ruby/test_literal.rb b/test/ruby/test_literal.rb index 315fe529ea..23c1c9b800 100644 --- a/test/ruby/test_literal.rb +++ b/test/ruby/test_literal.rb @@ -53,15 +53,33 @@ class TestRubyLiteral < Test::Unit::TestCase assert_equal "3", "\x33" assert_equal "\n", "\n" bug2500 = '[ruby-core:27228]' + bug5262 = '[ruby-core:39222]' %w[c C- M-].each do |pre| ["u", %w[u{ }]].each do |open, close| - str = "\"\\#{pre}\\#{open}5555#{close}\"" - assert_raise(SyntaxError, "#{bug2500} eval(#{str})") {eval(str)} + ["?", ['"', '"']].each do |qopen, qclose| + str = "#{qopen}\\#{pre}\\#{open}5555#{close}#{qclose}" + assert_raise(SyntaxError, "#{bug2500} eval(#{str})") {eval(str)} + + str = "#{qopen}\\#{pre}\\#{open}\u201c#{close}#{qclose}" + assert_raise(SyntaxError, "#{bug5262} eval(#{str})") {eval(str)} + + str = "#{qopen}\\#{pre}\\#{open}\u201c#{close}#{qclose}".encode("euc-jp") + assert_raise(SyntaxError, "#{bug5262} eval(#{str})") {eval(str)} + + str = "#{qopen}\\#{pre}\\#{open}\u201c#{close}#{qclose}".encode("iso-8859-13") + assert_raise(SyntaxError, "#{bug5262} eval(#{str})") {eval(str)} + + str = "#{qopen}\\#{pre}\\#{open}\xe2\x7f#{close}#{qclose}".force_encoding("utf-8") + assert_raise(SyntaxError, "#{bug5262} eval(#{str})") {eval(str)} + end end end assert_equal "\x13", "\c\x33" assert_equal "\x13", "\C-\x33" assert_equal "\xB3", "\M-\x33" + assert_equal "\u201c", eval(%["\\\u{201c}"]), bug5262 + assert_equal "\u201c".encode("euc-jp"), eval(%["\\\u{201c}"].encode("euc-jp")), bug5262 + assert_equal "\u201c".encode("iso-8859-13"), eval(%["\\\u{201c}"].encode("iso-8859-13")), bug5262 end def test_dstring |