test/unit/test-prev.rb in rb-threadframe-0.37 vs test/unit/test-prev.rb in rb-threadframe-0.38
- old
+ new
@@ -19,30 +19,41 @@
'The type of the top frame should be "TOP"')
end
def test_prev
- assert RubyVM::ThreadFrame::prev(Thread::current, 0)
- assert(RubyVM::ThreadFrame::prev(Thread::current, 2),
- 'There should be at least two prior frames')
+ assert RubyVM::ThreadFrame::prev(Thread::current, 1),
+ 'should allow 2-arg prev'
+ assert RubyVM::ThreadFrame::prev(Thread::current),
+ 'should allow 1-arg thread prev'
+ assert(RubyVM::ThreadFrame::prev(2),
+ 'There should be at least two prior frames in single Fixnum prev')
top_frame = RubyVM::ThreadFrame::prev(Thread::current, -1)
- assert(top_frame, 'Should give back the top frame')
+ assert(top_frame, 'Should give back the top frame for two arg and -1')
assert_equal('TOP', top_frame.type,
'The type of the top frame should be "TOP"')
+ top_frame = RubyVM::ThreadFrame::prev(-1)
+ assert(top_frame, 'Should give back the top frame for one arg and -1')
+ assert_equal('TOP', top_frame.type,
+ 'The type of the top frame should be "TOP"')
+
assert_equal(nil, RubyVM::ThreadFrame::prev(Thread::current, 1000))
- tf = RubyVM::ThreadFrame::current.prev
+ tf = RubyVM::ThreadFrame.prev
assert tf.prev(2)
assert_equal(tf, tf.prev(0),
'tf.prev(0) is defined as be tf')
assert tf.prev(-1)
assert_equal(nil, tf.prev(1000))
assert_raises TypeError do
tf.prev('a')
+ end
+ assert_raises ArgumentError do
+ tf.prev(RubyVM::ThreadFrame::current, 1, 'bad_arg')
end
assert_raises TypeError do
RubyVM::ThreadFrame::prev([1])
end
assert_raises TypeError do