File: debug_test.rb

package info (click to toggle)
ruby-byebug 11.1.3-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,252 kB
  • sloc: ruby: 8,835; ansic: 1,662; sh: 6; makefile: 4
file content (51 lines) | stat: -rw-r--r-- 1,289 bytes parent folder | download | duplicates (3)
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
# frozen_string_literal: true

require "test_helper"

module Byebug
  #
  # Tests launching new debuggers from byebug's prompt
  #
  class SubdebuggersTest < TestCase
    def program
      strip_line_numbers <<-RUBY
         1:  module Byebug
         2:   #
         3:   # Toy class to test subdebuggers inside evaluation prompt
         4:   #
         5:   class #{example_class}
         6:     def self.a
         7:       byebug
         8:     end
         9:   end
        10:
        11:   byebug
        12:
        13:   "Bye!"
        14:  end
      RUBY
    end

    def test_subdebugger_stops_at_correct_point_when_invoked_through_byebug_call
      enter "debug #{example_class}.a"

      debug_code(program) { assert_equal 8, frame.line }
    end

    def test_subdebugger_stops_at_correct_point_when_invoked_from_breakpoint
      enter "break #{example_class}.a", "debug #{example_class}.a"

      if RUBY_VERSION >= "2.5.0"
        debug_code(program) { assert_equal 7, frame.line }
      else
        debug_code(program) { assert_equal 6, frame.line }
      end
    end

    def test_subdebugger_goes_back_to_previous_debugger_after_continue
      enter "debug #{example_class}.a", "continue"

      debug_code(program) { assert_equal 13, frame.line }
    end
  end
end