Skip to content

Commit aa8ea43

Browse files
committed
test all of LoopStateMachine
1 parent 7dd4014 commit aa8ea43

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/utils/LoopStateMachine/LoopStateMachine.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,16 @@ struct Action{T}
5252
end
5353

5454
Action() = Action{Nothing}(:unnamed, nothing)
55-
Action(x::T) where T = Action{:unnamed, T}(:unnamed, x)
55+
Action(x::T) where T = Action{T}(:unnamed, x)
5656
Action(x::Symbol) = Action(x, nothing)
5757

5858
function Base.show(io::IO, action::Action{T}) where T
59-
print(io, "Action ", action.name)
59+
print(io, "Action")
60+
print(io, "(:$(action.name)")
6061
if isnothing(action.x)
61-
print(io, "()")
62+
print(io, ")")
6263
else
63-
print(io, "(", action.x, ")")
64+
print(io, ", ",action.x, ")")
6465
end
6566
end
6667

test/utils/LoopStateMachine.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,17 @@ end
5959
end
6060
@test results == [2, 4, 6]
6161
end
62+
63+
@testset "Show" begin
64+
@test sprint(print, Action(:continue)) == "Action(:continue)"
65+
@test sprint(print, Action(:break)) == "Action(:break)"
66+
@test sprint(print, Action(:return, 1)) == "Action(:return, 1)"
67+
@test sprint(print, Action(:full_return, 1)) == "Action(:full_return, 1)"
68+
end
69+
70+
@testset "Unnamed action" begin
71+
@test sprint(print, Action()) == "Action(:unnamed)"
72+
@test sprint(print, Action(1)) == "Action(:unnamed, 1)"
73+
@test sprint(print, Action(:x)) == "Action(:x)"
74+
end
75+

0 commit comments

Comments
 (0)