File tree Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Original file line number Diff line number Diff line change 1
1
using Test
2
- using GeometryOps. LoopStateMachine: @controlflow , Continue, Break
2
+ using GeometryOps. LoopStateMachine: @controlflow , Action
3
3
4
4
@testset " Continue action" begin
5
5
count = 0
6
6
f (i) = begin
7
7
count += 1
8
8
if i == 3
9
- return Continue ( )
9
+ return Action ( :continue )
10
10
end
11
11
count += 1
12
12
end
21
21
function f (i)
22
22
count += 1
23
23
if i == 3
24
- return Break ( )
24
+ return Action ( :break )
25
25
end
26
26
count += 1
27
27
end
31
31
@test count == 5 # Counts up to i=3, adding 2 for i=1,2 and 1 for i=3
32
32
end
33
33
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
+
34
52
@testset " Return value" begin
35
53
results = Int[]
36
54
for i in 1 : 3
You can’t perform that action at this time.
0 commit comments