File: basic_test.rb

package info (click to toggle)
ruby-debug-inspector 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 140 kB
  • sloc: ruby: 96; ansic: 89; sh: 4; makefile: 4
file content (59 lines) | stat: -rw-r--r-- 1,447 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
require "test_helper"

class BasicTest < Minitest::Test
  def setup
    @offset = DebugInspector.open do |dc|
      dc.backtrace_locations.index { |loc| loc.path == __FILE__ and loc.label == "setup" }
    end
  end

  def test_version
    assert(DebugInspector::VERSION)
  end

  def test_legacy_name
    if RUBY_ENGINE == "ruby"
      if RubyVM.respond_to?(:deprecate_constant)
        warning = /warning: constant RubyVM::DebugInspector is deprecated/
      else
        warning = ''
      end

      assert_output('', warning) do
        assert_same DebugInspector, RubyVM::DebugInspector
      end
    else
      assert !defined?(RubyVM::DebugInspector)
    end
  end

  def test_backtrace_locations
    DebugInspector.open do |dc|
      assert dc.backtrace_locations.size > 0
      dc.backtrace_locations.each{|e| assert_instance_of Thread::Backtrace::Location, e}
    end
  end

  def test_frame_binding
    DebugInspector.open do |dc|
      assert_equal self, dc.frame_binding(@offset).eval("self")
      assert_equal __method__, dc.frame_binding(@offset).eval("__method__")
    end
  end

  def test_frame_class
    DebugInspector.open do |dc|
      assert_equal self.class, dc.frame_class(@offset)
    end
  end

  def test_frame_iseq
    DebugInspector.open do |dc|
      if RUBY_ENGINE == "ruby"
        assert_equal __FILE__, dc.frame_iseq(@offset).path
      else
        assert_nil dc.frame_iseq(@offset)
      end
    end
  end
end