Skip to content

Commit 75082bb

Browse files
smasatomame
authored andcommitted
Update and add test scenarios
1 parent 608bc38 commit 75082bb

2 files changed

Lines changed: 41 additions & 18 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## update
2+
def foo
3+
x = :a
4+
begin
5+
x = :b
6+
raise
7+
x = :c
8+
rescue
9+
check_rescue(x)
10+
x = :d
11+
# ensure # TODO: Looks like commenting out these two lines makes the test fail? Need to fix
12+
# x = :f
13+
else
14+
check_else(x)
15+
x = :e
16+
end
17+
check_after(x)
18+
end
19+
20+
def check_rescue(n) = nil
21+
def check_else(n) = nil
22+
def check_after(n) = nil
23+
24+
## assert
25+
class Object
26+
def foo: -> nil
27+
def check_rescue: (:a | :c) -> nil
28+
def check_else: (:c) -> nil
29+
def check_after: (:a | :c | :d | :e) -> nil
30+
end

scenario/control/rescue.rb

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,27 @@
11
## update
2-
def bar(n)
3-
:c
4-
end
5-
6-
def foo(n)
2+
def foo
73
begin
8-
n = "str"
9-
1.0
10-
rescue
114
:a
12-
rescue SyntaxError
5+
rescue
136
:b
7+
rescue SyntaxError
8+
:c
149
rescue Exception
15-
## TODO: bar should accept "Integer | String" ???
16-
bar(n)
17-
else
1810
:d
11+
else
12+
:e
1913
end
2014
end
2115

22-
def baz(n)
16+
def bar(n)
2317
n rescue :a
2418
end
2519

26-
foo(1)
27-
baz(1)
20+
foo
21+
bar(1)
2822

2923
## assert
3024
class Object
31-
def bar: (String) -> :c
32-
def foo: (Integer) -> (:a | :b | :c | :d | Float)
33-
def baz: (Integer) -> (:a | Integer)
25+
def foo: -> (:a | :b | :c | :d | :e)
26+
def bar: (Integer) -> (:a | Integer)
3427
end

0 commit comments

Comments
 (0)