diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-12-01 15:41:50 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-12-01 15:41:50 +0000 |
commit | 4d7b0b9112f2adf9e87ef75056f930bf7c1f3dc4 (patch) | |
tree | 8d712e18a619a9720d181d0d44e8cc2474ff31ee /spec/ruby/core/tracepoint/disable_spec.rb | |
parent | 821d9a2d30f2e0d3f9009dc001b4b49aaa63c66e (diff) | |
download | ruby-4d7b0b9112f2adf9e87ef75056f930bf7c1f3dc4.tar.gz |
Update to ruby/spec@bacedc5
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/core/tracepoint/disable_spec.rb')
-rw-r--r-- | spec/ruby/core/tracepoint/disable_spec.rb | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/spec/ruby/core/tracepoint/disable_spec.rb b/spec/ruby/core/tracepoint/disable_spec.rb new file mode 100644 index 0000000000..7da644621b --- /dev/null +++ b/spec/ruby/core/tracepoint/disable_spec.rb @@ -0,0 +1,64 @@ +require File.expand_path('../../../spec_helper', __FILE__) + +describe 'TracePoint#disable' do + def test; end + it 'returns true if trace was enabled' do + event_name, method_name = nil + trace = TracePoint.new(:call) do |tp| + event_name = tp.event + method_name = tp.method_id + end + + trace.enable + trace.disable.should be_true + event_name, method_name = nil + test + method_name.equal?(:test).should be_false + event_name.should equal(nil) + end + + it 'returns false if trace was disabled' do + event_name, method_name = nil + trace = TracePoint.new(:call) do |tp| + event_name = tp.event + method_name = tp.method_id + end + + trace.disable.should be_false + event_name, method_name = nil + test + method_name.equal?(:test).should be_false + event_name.should equal(nil) + end + + it 'is disabled within a block & is enabled outside the block' do + enabled = nil + trace = TracePoint.new(:line) {} + trace.enable + trace.disable { enabled = trace.enabled? } + enabled.should be_false + trace.enabled?.should be_true + trace.disable + end + + it 'is disabled within a block & also returns false when its called with a block' do + trace = TracePoint.new(:line) {} + trace.enable + trace.disable { trace.enabled? }.should == false + trace.enabled?.should equal(true) + trace.disable + end + + ruby_bug "#14057", "2.0"..."2.5" do + it 'can accept param within a block but it should not yield arguments' do + event_name = nil + trace = TracePoint.new(:line) {} + trace.enable + trace.disable do |*args| + args.should == [] + end + trace.enabled?.should be_true + trace.disable + end + end +end |