diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-09-27 08:35:31 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-09-27 08:35:31 +0000 |
commit | a73c7e87fa13490b147b7fe9da9124e168cf5d3f (patch) | |
tree | adb6bcffc42f84464b87227b01889c104ce428ca /test | |
parent | c4766932cc7061ce667dcb8ff61fedc11b247c31 (diff) | |
download | ruby-a73c7e87fa13490b147b7fe9da9124e168cf5d3f.tar.gz |
iseq.c: syntax error in compile_file
* iseq.c (iseqw_s_compile_file): deal with syntax error as well as
compile, and should not abort when rescued.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_iseq.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb index 94aebe1f90..df71e1821e 100644 --- a/test/ruby/test_iseq.rb +++ b/test/ruby/test_iseq.rb @@ -1,4 +1,5 @@ require 'test/unit' +require 'tempfile' class TestISeq < Test::Unit::TestCase ISeq = RubyVM::InstructionSequence @@ -243,6 +244,23 @@ class TestISeq < Test::Unit::TestCase assert_send([e2, :start_with?, __FILE__]) end + def test_compile_file_error + Tempfile.create(%w"test_iseq .rb") do |f| + f.puts "end" + f.close + path = f.path + assert_in_out_err(%W[- #{path}], "#{<<-"begin;"}\n#{<<-"end;"}", /keyword_end/, [], success: true) + begin; + path = ARGV[0] + begin + RubyVM::InstructionSequence.compile_file(path) + rescue SyntaxError => e + puts e.message + end + end; + end + end + def test_translate_by_object assert_separately([], <<-"end;") class Object |