Sha256: d7e5a84e8c744634f7f4b445c328689c72a0e3ef2d338b3044df367df794d3be

Contents?: true

Size: 1.57 KB

Versions: 2

Compression:

Stored size: 1.57 KB

Contents

#!/usr/bin/env ruby
require 'test/unit'
require_relative '../../app/frame'
require 'thread_frame'

class TestAppFrame < Test::Unit::TestCase

  include Trepan::Frame

  def test_app_frame
    frame = RubyVM::ThreadFrame.current
    base_count = frame.stack_size
    s = format_stack_entry(frame)
    pat = /^METHOD .*#test_app_frame\(\) in file .*test-app-frame.rb at line \d+/
    assert(s =~ pat, "got #{s}, expected pat #{pat}")
    1.times do 
      assert_equal(base_count+2, RubyVM::ThreadFrame.current.stack_size)
      s = format_stack_entry(frame)
      assert(s =~ pat, "got #{s}, expected pat #{pat}")
    end

    def inner_test(count)
      frame = RubyVM::ThreadFrame.current
      assert_equal(count, frame.stack_size)

      s = format_stack_entry(frame)
      pat = /^METHOD .*#inner_test\(count\) in file .*test-app-frame.rb at line \d+/
      assert(s =~ pat, "got: #{s.inspect},\nexpected: pat #{pat}")

      s = format_stack_entry(frame, :basename => true)
      pat = /^METHOD .*#inner_test\(count\) in file test-app-frame.rb at line \d+/
      assert(s =~ pat, "got: #{s.inspect},\nexpected: pat #{pat}")

      s = format_stack_entry(frame, :basename => true, :show_pc => true)
      pat = /^METHOD .*#inner_test\(count\) in file test-app-frame.rb at line \d+, pc: \d+/
      assert(s =~ pat, "got: #{s.inspect},\nexpected: pat #{pat}")
    end
    inner_test(base_count+1)
  end

  def test_return
    assert_equal(1, offset_for_return('return'))
    assert_equal(4, offset_for_return('c-return'))
    assert_raises RuntimeError do
      offset_for_return('c-call')
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
trepanning-0.1.4 test/unit/test-app-frame.rb
trepanning-0.1.3 test/unit/test-app-frame.rb