Skip to content

Commit 2a13f51

Browse files
test: Add test for flip-flops.
1 parent 9f55cb9 commit 2a13f51

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

test/scip/testdata/loops_and_conditionals.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ def for(xs)
6464
next g+1 if g == 1
6565
break if g == 2
6666
break g+1 if g == 3
67+
# NOTE: redo is unsupported (https://srb.help/3003)
68+
# but emitting a reference here does work
6769
redo if g == 4
6870
end
6971
end
@@ -81,6 +83,8 @@ def while(xs)
8183
next g+1 if g == 1
8284
break if g == 2
8385
break g+1 if g == 3
86+
# NOTE: redo is unsupported (https://srb.help/3003)
87+
# but emitting a reference here does work
8488
redo if g == 4
8589
end
8690
end
@@ -98,6 +102,19 @@ def until(xs)
98102
next g+1 if g == 1
99103
break if g == 2
100104
break g+1 if g == 3
105+
# NOTE: redo is unsupported (https://srb.help/3003)
106+
# but emitting a reference here does work
101107
redo if g == 4
102108
end
103109
end
110+
111+
def flip_flop(xs)
112+
# NOTE: flip-flops are unsupported (https://srb.help/3003)
113+
# Unlike redo, which somehow works, we fail to emit references
114+
# for the conditions.
115+
# Keep this test anyways to check that we don't crash/mess something up
116+
for x in xs
117+
puts x if x==2..x==8
118+
puts x+1 if x==4...x==6
119+
end
120+
end

test/scip/testdata/loops_and_conditionals.snapshot.rb

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
def if_elsif_else()
44
#^^^^^^^^^^^^^^^^^^^ definition scip-ruby gem TODO TODO if_elsif_else().
5-
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition scip-ruby gem TODO TODO <static-init>().
5+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition scip-ruby gem TODO TODO <static-init>().
66
x = 0
77
# ^ definition local 1~#2393773952
88
y = 0
@@ -117,6 +117,8 @@ def for(xs)
117117
break g+1 if g == 3
118118
# ^ reference local 4~#2901640080
119119
# ^ reference local 4~#2901640080
120+
# NOTE: redo is unsupported (https://srb.help/3003)
121+
# but emitting a reference here does work
120122
redo if g == 4
121123
# ^ reference local 4~#2901640080
122124
end
@@ -152,6 +154,8 @@ def while(xs)
152154
break g+1 if g == 3
153155
# ^ reference local 4~#231090382
154156
# ^ reference local 4~#231090382
157+
# NOTE: redo is unsupported (https://srb.help/3003)
158+
# but emitting a reference here does work
155159
redo if g == 4
156160
# ^ reference local 4~#231090382
157161
end
@@ -187,7 +191,26 @@ def until(xs)
187191
break g+1 if g == 3
188192
# ^ reference local 4~#3132432719
189193
# ^ reference local 4~#3132432719
194+
# NOTE: redo is unsupported (https://srb.help/3003)
195+
# but emitting a reference here does work
190196
redo if g == 4
191197
# ^ reference local 4~#3132432719
192198
end
193199
end
200+
201+
def flip_flop(xs)
202+
#^^^^^^^^^^^^^^^^^ definition scip-ruby gem TODO TODO flip_flop().
203+
# ^^ definition local 1~#2191960030
204+
# NOTE: flip-flops are unsupported (https://srb.help/3003)
205+
# Unlike redo, which somehow works, we fail to emit references
206+
# for the conditions.
207+
# Keep this test anyways to check that we don't crash/mess something up
208+
for x in xs
209+
# ^ definition local 2~#2191960030
210+
# ^^ reference local 1~#2191960030
211+
puts x if x==2..x==8
212+
# ^ reference local 2~#2191960030
213+
puts x+1 if x==4...x==6
214+
# ^ reference local 2~#2191960030
215+
end
216+
end

0 commit comments

Comments
 (0)