ruby-changes:54031
From: ko1 <ko1@a...>
Date: Thu, 6 Dec 2018 22:53:54 +0900 (JST)
Subject: [ruby-changes:54031] ko1:r66251 (trunk): add tests for script_compiled TP event.
ko1 2018-12-06 22:53:48 +0900 (Thu, 06 Dec 2018) New Revision: 66251 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66251 Log: add tests for script_compiled TP event. Modified files: trunk/test/ruby/test_settracefunc.rb Index: test/ruby/test_settracefunc.rb =================================================================== --- test/ruby/test_settracefunc.rb (revision 66250) +++ test/ruby/test_settracefunc.rb (revision 66251) @@ -2084,4 +2084,35 @@ class TestSetTraceFunc < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/ruby/test_settracefunc.rb#L2084 end assert_equal 'target_line is specified, but line event is not specified', e.message end + + def test_script_compiled + events = [] + tp = TracePoint.new(:script_compiled){|tp| + next unless target_thread? + events << [tp.compiled_instruction_sequence.path, + tp.compiled_eval_script] + } + + eval_script = 'a = 1' + tp.enable{ + eval(eval_script, nil, __FILE__+"/eval") + nil.instance_eval(eval_script, __FILE__+"/instance_eval") + Object.class_eval(eval_script, __FILE__+"/class_eval") + } + assert_equal [[__FILE__+"/eval", eval_script], + [__FILE__+"/instance_eval", eval_script], + [__FILE__+"/class_eval", eval_script], + ], events + events.clear + + # TODO: test for requires + return + + tp.enable{ + require '' + require_relative '' + load '' + } + assert_equal [], events + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/