File: catch_test.rb

package info (click to toggle)
ruby-byebug 13.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,288 kB
  • sloc: ruby: 9,013; ansic: 1,692; makefile: 4; sh: 4
file content (52 lines) | stat: -rw-r--r-- 1,235 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
# frozen_string_literal: true

require "test_helper"

module Byebug
  #
  # Tests exception catching
  #
  class CatchTest < TestCase
    def test_catch_adds_catchpoints
      enter "catch NoMethodError"
      debug_code(minimal_program)

      assert_equal 1, Byebug.catchpoints.size
    end

    def test_catch_removes_specific_catchpoint
      enter "catch NoMethodError", "catch NoMethodError off"
      debug_code(minimal_program)

      assert_empty Byebug.catchpoints
    end

    def test_catch_off_removes_all_catchpoints_after_confirmation
      enter "catch NoMethodError", "catch off", "y"
      debug_code(minimal_program)

      assert_empty Byebug.catchpoints
    end

    def test_catch_without_arguments_and_no_exceptions_caught
      enter "catch"
      debug_code(minimal_program)

      check_output_includes "No exceptions set to be caught."
    end

    def test_catch_without_arguments_and_exceptions_caught
      enter "catch NoMethodError", "catch"
      debug_code(minimal_program)

      check_output_includes "NoMethodError: false"
    end

    def test_catch_help
      enter "help catch"
      debug_code(minimal_program)

      check_output_includes "cat[ch][ (off|<exception>[ off])]"
    end
  end
end