diff options
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_parse.rb | 9 | ||||
-rw-r--r-- | test/ruby/test_syntax.rb | 6 |
2 files changed, 15 insertions, 0 deletions
diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index 2622ec529c..17a0c8a077 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -720,6 +720,15 @@ x = __ENCODING__ assert_syntax_error("=begin", error) end + def test_embedded_rd_warning + [["\0", "\\0"], ["\C-d", "^D"], ["\C-z", "^Z"]].each do |eof, mesg| + mesg = /encountered #{Regexp.quote(mesg)}/ + assert_warning(mesg) {eval("=begin\n#{eof}\n=end")} + assert_warning(mesg) {eval("=begin#{eof}\n=end")} + assert_warning(mesg) {eval("=begin\n=end#{eof}\n")} + end + end + def test_float assert_equal(1.0/0, eval("1e10000")) assert_syntax_error('1_E', /trailing `_'/) diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 5fb4dfa64f..d0748e7028 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -943,6 +943,12 @@ eom end end + def test_warning_for_eof_in_comment + assert_warning(/encountered \\0/) {eval("#\0")} + assert_warning(/encountered \^D/) {eval("#\C-d")} + assert_warning(/encountered \^Z/) {eval("#\C-z")} + end + def test_unexpected_fraction msg = /unexpected fraction/ assert_syntax_error("0x0.0", msg) |