test/unit/test-settracefunc.rb in rb-threadframe-0.39 vs test/unit/test-settracefunc.rb in rb-threadframe-0.40
- old
+ new
@@ -43,18 +43,22 @@
3: })
4: x = 1 + 1
5: set_trace_func(nil)
EOF
- expected = [
- [4, 'line', __method__, self.class],
- [4, 'send', __method__, self.class],
- [4, "c-call", :+, Fixnum],
- [4, "c-return", :+, Fixnum],
- [5, "line", __method__, self.class],
- [5, "send", __method__, self.class],
- [5, "c-call", :set_trace_func, Kernel]]
+ expected =
+ [
+ [4, 'line', __method__, self.class],
+ [4, 'send', __method__, self.class],
+ [4, "c-call", :+, Fixnum],
+ [4, "c-return", :+, Fixnum],
+ [5, "line", __method__, self.class],
+ [5, "send", __method__, self.class],
+ [5, "c-call", :set_trace_func, Kernel]
+ ]
+ expected.unshift [5, 'c-return', :set_trace_func, Kernel] if
+ '1.9.3' == RUBY_VERSION
checkit(@events, expected)
end
def test_call
eval <<-EOF.gsub(/^.*?: /, '')
@@ -85,10 +89,13 @@
[6, 'leave', :add, self.class],
[8, 'line', __method__, self.class],
[8, 'send', __method__, self.class],
[8, 'c-call', :set_trace_func, Kernel]
]
+ expected.unshift [3, 'c-return', :set_trace_func, Kernel] if
+ '1.9.3' == RUBY_VERSION
+
checkit(@events, expected)
end
def test_class
eval <<-EOF.gsub(/^.*?: /, '')
@@ -100,33 +107,38 @@
6: end
7: end
8: x = Foo.new.bar
9: clear_trace_func()
EOF
- expected = [[4, 'line', __method__, self.class],
- [4, 'c-call', :inherited, Class],
- [4, 'c-return', :inherited, Class],
- [4, 'class', nil, nil],
- [5, 'line', nil, nil],
- [5, 'send', nil, nil],
- [5, 'c-call', :method_added, Module],
- [5, 'c-return', :method_added, Module],
- [7, 'end', nil, nil],
- [7, 'leave', nil, nil],
- [8, 'line', __method__, self.class],
- [8, 'send', __method__, self.class],
- [8, 'c-call', :new, Class],
- [8, 'c-call', :initialize, BasicObject],
- [8, 'c-return', :initialize, BasicObject],
- [8, 'c-return', :new, Class],
- [8, 'send', __method__, Class],
- [5, 'call', :bar, Foo],
- [6, 'return', :bar, Foo],
- [6, 'leave', :bar, Foo],
- [9, 'line', __method__, self.class],
- [9, 'send', __method__, self.class],
- [9, 'c-call', :clear_trace_func, Kernel]]
+ expected =
+ [
+ [4, 'line', __method__, self.class],
+ [4, 'c-call', :inherited, Class],
+ [4, 'c-return', :inherited, Class],
+ [4, 'class', nil, nil],
+ [5, 'line', nil, nil],
+ [5, 'send', nil, nil],
+ [5, 'c-call', :method_added, Module],
+ [5, 'c-return', :method_added, Module],
+ [7, 'end', nil, nil],
+ [7, 'leave', nil, nil],
+ [8, 'line', __method__, self.class],
+ [8, 'send', __method__, self.class],
+ [8, 'c-call', :new, Class],
+ [8, 'c-call', :initialize, BasicObject],
+ [8, 'c-return', :initialize, BasicObject],
+ [8, 'c-return', :new, Class],
+ [8, 'send', __method__, Class],
+ [5, 'call', :bar, Foo],
+ [6, 'return', :bar, Foo],
+ [6, 'leave', :bar, Foo],
+ [9, 'line', __method__, self.class],
+ [9, 'send', __method__, self.class],
+ [9, 'c-call', :clear_trace_func, Kernel]
+ ]
+ expected.unshift [3, 'c-return', :set_trace_func, Kernel] if
+ '1.9.3' == RUBY_VERSION
checkit(@events, expected)
end
def test_return # [ruby-dev:38701]
eval <<-EOF.gsub(/^.*?: /, '')
@@ -192,10 +204,13 @@
[7, 'return', :foo, self.class],
[7, 'leave', :foo, self.class],
[9, 'line', :test_return2, self.class],
[9, 'send', :test_return2, self.class],
[9, 'c-call', :set_trace_func, Kernel]]
+ expected.unshift [3, 'c-return', :set_trace_func, Kernel] if
+ '1.9.3' == RUBY_VERSION
+
@events.each_with_index{|e, i|
assert_equal(e, @events[i], showit(@events, expected))}
assert_equal(expected.size, @events.size, showit(@events, expected))
end
@@ -234,10 +249,13 @@
[7, 'leave', __method__, Module],
[8, 'line', __method__, self.class],
[8, 'send', __method__, self.class],
[8, 'c-call', :set_trace_func, Kernel]
]
+ expected.unshift [3, 'c-return', :set_trace_func, Kernel] if
+ '1.9.3' == RUBY_VERSION
+
checkit(events, expected)
end
def test_break # [ruby-core:27606] [Bug #2610]
events = []
@@ -247,21 +265,27 @@
3: })
4: [1,2,3].any? {|n| n}
8: set_trace_func(nil)
EOF
- expected = [
- [4, 'line', __method__, self.class],
- [4, 'send', __method__, self.class],
- [4, 'c-call', :any?, Enumerable],
- [4, 'c-call', :each, Array],
- [4, 'line', __method__, self.class],
- [4, 'leave', __method__, self.class],
- [4, 'c-return', :each, Array],
- [4, 'c-return', :any?, Enumerable],
- [5, 'line', __method__, self.class],
- [5, 'send', __method__, self.class],
- [5, 'c-call', :set_trace_func, Kernel]]
+ expected =
+ [
+ [4, 'line', __method__, self.class],
+ [4, 'send', __method__, self.class],
+ [4, 'c-call', :any?, Enumerable],
+ [4, 'c-call', :each, Array],
+ [4, 'line', __method__, self.class],
+ [4, 'leave', __method__, self.class],
+ [4, 'c-return', :each, Array],
+ [4, 'c-return', :any?, Enumerable],
+ [5, 'line', __method__, self.class],
+ [5, 'send', __method__, self.class],
+ [5, 'c-call', :set_trace_func, Kernel]
+ ]
+ expected.unshift [3, 'c-return', :set_trace_func, Kernel] if
+ '1.9.3' == RUBY_VERSION
+
+
checkit(events, expected)
end
def test_invalid_proc
assert_raise(TypeError) { set_trace_func(1) }