mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@e2d0d1e
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60975 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
60775cc48a
commit
d209b4c0a2
2 changed files with 53 additions and 34 deletions
|
@ -3,18 +3,18 @@ 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
|
||||
called = false
|
||||
trace = TracePoint.new(:call) do |tp|
|
||||
event_name = tp.event
|
||||
method_name = tp.method_id
|
||||
called = true
|
||||
end
|
||||
|
||||
trace.enable
|
||||
trace.disable.should be_true
|
||||
event_name, method_name = nil
|
||||
|
||||
# Check the TracePoint is disabled
|
||||
called = false
|
||||
test
|
||||
method_name.equal?(:test).should be_false
|
||||
event_name.should equal(nil)
|
||||
called.should == false
|
||||
end
|
||||
|
||||
it 'returns false if trace was disabled' do
|
||||
|
@ -35,30 +35,39 @@ describe 'TracePoint#disable' do
|
|||
enabled = nil
|
||||
trace = TracePoint.new(:line) {}
|
||||
trace.enable
|
||||
begin
|
||||
trace.disable { enabled = trace.enabled? }
|
||||
enabled.should be_false
|
||||
trace.enabled?.should be_true
|
||||
ensure
|
||||
trace.disable
|
||||
end
|
||||
end
|
||||
|
||||
it 'is disabled within a block & also returns false when its called with a block' do
|
||||
trace = TracePoint.new(:line) {}
|
||||
trace.enable
|
||||
begin
|
||||
trace.disable { trace.enabled? }.should == false
|
||||
trace.enabled?.should equal(true)
|
||||
ensure
|
||||
trace.disable
|
||||
end
|
||||
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
|
||||
begin
|
||||
trace.disable do |*args|
|
||||
args.should == []
|
||||
end
|
||||
trace.enabled?.should be_true
|
||||
ensure
|
||||
trace.disable
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,21 +5,22 @@ describe 'TracePoint#enable' do
|
|||
|
||||
describe 'without a block' do
|
||||
it 'returns true if trace was enabled' do
|
||||
event_name, method_name = nil, nil
|
||||
method_name = []
|
||||
event_name = nil
|
||||
trace = TracePoint.new(:call) do |tp|
|
||||
event_name = tp.event
|
||||
method_name << tp.method_id
|
||||
end
|
||||
|
||||
test
|
||||
event_name.should == nil
|
||||
|
||||
trace.enable
|
||||
begin
|
||||
test
|
||||
event_name.should equal(:call)
|
||||
ensure
|
||||
trace.disable
|
||||
end
|
||||
end
|
||||
|
||||
it 'returns false if trace was disabled' do
|
||||
event_name, method_name = nil, nil
|
||||
|
@ -29,23 +30,29 @@ describe 'TracePoint#enable' do
|
|||
end
|
||||
|
||||
trace.enable.should be_false
|
||||
begin
|
||||
event_name.should equal(:call)
|
||||
test
|
||||
method_name.equal?(:test).should be_true
|
||||
|
||||
ensure
|
||||
trace.disable
|
||||
end
|
||||
|
||||
event_name, method_name = nil
|
||||
test
|
||||
method_name.equal?(:test).should be_false
|
||||
event_name.should equal(nil)
|
||||
|
||||
trace.enable.should be_false
|
||||
begin
|
||||
event_name.should equal(:call)
|
||||
test
|
||||
method_name.equal?(:test).should be_true
|
||||
ensure
|
||||
trace.disable
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with a block' do
|
||||
it 'enables the trace object within a block' do
|
||||
|
@ -71,10 +78,13 @@ describe 'TracePoint#enable' do
|
|||
enabled = nil
|
||||
trace = TracePoint.new(:line) {}
|
||||
trace.enable
|
||||
begin
|
||||
trace.enable { enabled = trace.enabled? }
|
||||
enabled.should == true
|
||||
ensure
|
||||
trace.disable
|
||||
end
|
||||
end
|
||||
|
||||
it 'returns value returned by the block' do
|
||||
trace = TracePoint.new(:line) {}
|
||||
|
|
Loading…
Reference in a new issue