forked from ruby/debug
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrap_test.rb
More file actions
54 lines (47 loc) · 1.04 KB
/
trap_test.rb
File metadata and controls
54 lines (47 loc) · 1.04 KB
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
# frozen_string_literal: true
require_relative '../support/console_test_case'
module DEBUGGER__
class TrapTest < ConsoleTestCase
def program
<<~RUBY
1| trap('SIGINT'){ puts "SIGINT" }
2| Process.kill('SIGINT', Process.pid)
3| p :ok
RUBY
end
def test_sigint
debug_code program, remote: false do
type 'b 3'
type 'c'
assert_line_text(/is registered as SIGINT handler/)
type 'sigint'
assert_line_num 3
assert_line_text(/SIGINT/)
type 'c'
end
end
def test_trap_with
debug_code %q{
1| trap(:INT){} # Symbol
2| _ = 1
}, remote: false do
type 'n'
type 'n'
end
debug_code %q{
1| trap('INT'){} # String
2| _ = 1
}, remote: false do
type 'n'
type 'n'
end
debug_code %q{
1| trap(Signal.list['INT']){} if Signal.list['INT'] # Integer
2| _ = 1
}, remote: false do
type 'n'
type 'n'
end
end
end
end