File: display_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 (54 lines) | stat: -rw-r--r-- 1,123 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
52
53
54
# frozen_string_literal: true

require "test_helper"

module Byebug
  #
  # Tests displaying values of expressions on every stop.
  #
  class DisplayTest < TestCase
    def program
      strip_line_numbers <<-RUBY
        1:  module Byebug
        2:    d = 0
        3:
        4:    byebug
        5:
        6:    d += 3
        7:    d + 6
        8:  end
      RUBY
    end

    def test_shows_expressions
      enter "display d + 1"
      debug_code(program) { clear_displays }

      check_output_includes "1: d + 1 = 1"
    end

    def test_shows_undefined_expressions
      enter "display e"
      debug_code(program) { clear_displays }

      check_output_includes "1: e = (undefined)"
    end

    def test_saves_displayed_expressions
      enter "display d + 1"

      debug_code(program) do
        assert_equal [[true, "d + 1"]], Byebug.displays
        clear_displays
      end
    end

    def test_displays_all_expressions_available
      enter "display d", "display d + 1", "display"

      debug_code(program) { clear_displays }

      check_output_includes "1: d = 0", "2: d + 1 = 1"
    end
  end
end