summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-05-24 16:10:59 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-05-24 16:12:17 +0900
commit2893550452f6f3cadb17c670da185813d7d0a835 (patch)
treea19bc3bd37f155cb2155fc1311f85fa851f77b55 /test
parent45ad375acccca2bb0852613b1e809a7af556f5e6 (diff)
Mixed encoding error can continue to parse
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_parse.rb3
-rw-r--r--test/ruby/test_syntax.rb15
2 files changed, 14 insertions, 4 deletions
diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb
index dc4c143241..c59454f8f7 100644
--- a/test/ruby/test_parse.rb
+++ b/test/ruby/test_parse.rb
@@ -562,6 +562,9 @@ class TestParse < Test::Unit::TestCase
assert_raise(SyntaxError) { eval(" ?a\x8a".force_encoding("utf-8")) }
assert_equal("\u{1234}", eval("?\u{1234}"))
assert_equal("\u{1234}", eval('?\u{1234}'))
+ assert_equal("\u{1234}", eval('?\u1234'))
+ e = assert_syntax_error('"#{?\u123}"', 'invalid Unicode escape')
+ assert_not_match(/end-of-input/, e.message)
end
def test_percent
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index 7bf1e0e43c..e640262d90 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -775,32 +775,39 @@ eom
end
def test_heredoc_mixed_encoding
- assert_syntax_error(<<-'HEREDOC', 'UTF-8 mixed within Windows-31J source')
+ e = assert_syntax_error(<<-'HEREDOC', 'UTF-8 mixed within Windows-31J source')
#encoding: cp932
<<-TEXT
\xe9\x9d\u1234
TEXT
HEREDOC
- assert_syntax_error(<<-'HEREDOC', 'UTF-8 mixed within Windows-31J source')
+ assert_not_match(/end-of-input/, e.message)
+
+ e = assert_syntax_error(<<-'HEREDOC', 'UTF-8 mixed within Windows-31J source')
#encoding: cp932
<<-TEXT
\xe9\x9d
\u1234
TEXT
HEREDOC
- assert_syntax_error(<<-'HEREDOC', 'UTF-8 mixed within Windows-31J source')
+ assert_not_match(/end-of-input/, e.message)
+
+ e = assert_syntax_error(<<-'HEREDOC', 'UTF-8 mixed within Windows-31J source')
#encoding: cp932
<<-TEXT
\u1234\xe9\x9d
TEXT
HEREDOC
- assert_syntax_error(<<-'HEREDOC', 'UTF-8 mixed within Windows-31J source')
+ assert_not_match(/end-of-input/, e.message)
+
+ e = assert_syntax_error(<<-'HEREDOC', 'UTF-8 mixed within Windows-31J source')
#encoding: cp932
<<-TEXT
\u1234
\xe9\x9d
TEXT
HEREDOC
+ assert_not_match(/end-of-input/, e.message)
end
def test_lineno_operation_brace_block