1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Use assert_syntax_error

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59342 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-07-16 11:35:27 +00:00
parent 70af8d3c9c
commit 019f21e580

View file

@ -486,24 +486,16 @@ class TestParse < Test::Unit::TestCase
def test_string
mesg = 'from the backslash through the invalid char'
e = assert_raise_with_message(SyntaxError, /hex escape/) do
eval '"\xg1"'
end
e = assert_syntax_error('"\xg1"', /hex escape/)
assert_equal(' ^', e.message.lines.last, mesg)
e = assert_raise(SyntaxError) do
eval '"\u{1234"'
end
e = assert_syntax_error('"\u{1234"', 'Unicode escape')
assert_match(' ^~~~~~~', e.message.lines.last, mesg)
e = assert_raise_with_message(SyntaxError, /escape character syntax/) do
eval '"\M1"'
end
e = assert_syntax_error('"\M1"', /escape character syntax/)
assert_equal(' ^~~', e.message.lines.last, mesg)
e = assert_raise_with_message(SyntaxError, /escape character syntax/) do
eval '"\C1"'
end
e = assert_syntax_error('"\C1"', /escape character syntax/)
assert_equal(' ^~~', e.message.lines.last, mesg)
assert_equal("\x81", eval('"\C-\M-a"'))