Sha256: a416aee32e0cc4f0b32e2be706404ebeb9e7bbdc5ee960123b7f6cd4d3171798
Contents?: true
Size: 1.03 KB
Versions: 5
Compression:
Stored size: 1.03 KB
Contents
require 'facets/binding/caller.rb' require 'test/unit' class TestBindingCallStack < Test::Unit::TestCase def setup a = 1 b = 2 x = "hello" # the line number must be updated if it moves @bind = binding; @this_line_no = __LINE__ @this_file_name = File.basename( __FILE__ ) # why does it equal basename only? end def test___LINE__ assert_equal( @this_line_no, @bind.__LINE__ ) end def test___FILE__ assert_equal( @this_file_name, File.basename( @bind.__FILE__ ) ) end def test___DIR__ assert_equal( File.dirname( @bind.__FILE__ ), @bind.__DIR__ ) end def test_callstack assert_instance_of( Array, @bind.callstack ) end def test_caller # how to test? assert_nothing_raised{ @bind.caller } end # These only work for certain versions, which is okay. unless RUBY_VERSION < "1.9" def test_callee assert_equal(:setup, @bind.__callee__) end end unless RUBY_VERSION < "1.8.7" def test_method assert_equal(:setup, @bind.__method__) end end end
Version data entries
5 entries across 5 versions & 1 rubygems