Skip to content

Commit 1842fbf

Browse files
committed
test all actions
1 parent 0b7f721 commit 1842fbf

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

test/utils/LoopStateMachine.jl

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
using Test
2-
using GeometryOps.LoopStateMachine: @controlflow, Continue, Break
2+
using GeometryOps.LoopStateMachine: @controlflow, Action
33

44
@testset "Continue action" begin
55
count = 0
66
f(i) = begin
77
count += 1
88
if i == 3
9-
return Continue()
9+
return Action(:continue)
1010
end
1111
count += 1
1212
end
@@ -21,7 +21,7 @@ end
2121
function f(i)
2222
count += 1
2323
if i == 3
24-
return Break()
24+
return Action(:break)
2525
end
2626
count += 1
2727
end
@@ -31,6 +31,24 @@ end
3131
@test count == 5 # Counts up to i=3, adding 2 for i=1,2 and 1 for i=3
3232
end
3333

34+
@testset "Return action" begin
35+
f(i) = for j in 1:3
36+
i == j && @controlflow Action(:return, i)
37+
end
38+
@test f(1) == 1
39+
@test f(2) == 2
40+
@test f(3) == 3
41+
end
42+
43+
@testset "Full return action" begin
44+
f(i) = for j in 1:3
45+
i == j && @controlflow Action(:full_return, i)
46+
end
47+
@test f(1) == Action(:full_return, 1)
48+
@test f(2) == Action(:full_return, 2)
49+
@test f(3) == Action(:full_return, 3)
50+
end
51+
3452
@testset "Return value" begin
3553
results = Int[]
3654
for i in 1:3

0 commit comments

Comments
 (0)