Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
aplavin authored Feb 28, 2024
1 parent 2d772e9 commit 5f02896
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/test_functionlenses.jl
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ end
end

@testset "broadcast" begin
# in optic definiton
@test (@optic exp.(_)) === Base.BroadcastFunction(exp)
@test (@optic .-_) === Base.BroadcastFunction(-)
@test (@optic 1 .+ _) === Base.Fix1(Base.BroadcastFunction(+), 1)
Expand All @@ -209,9 +210,14 @@ end
test_getset_laws((@optic 1 .- _), [1, 2], [3., 4.], [5, 6])
test_getset_laws((@optic [10, 20] .* first.(_)), [[1,2], [1,2,3]], [3., 4.], [5, 6])

# in @set update operation
@test (@set A .= 1) == [1, 1, 1]
@test (@set A[1] .= 1) == [[1,1], [1,2,3], [1,2,3,4]]
@test (@set A[1] .= [10, 20]) == [[10,20], [1,2,3], [1,2,3,4]]

# broadcasting in both optic and set, with a user-defined function
@accessor f(x) = x+1
@test (@set f.(first.(A)) .= [10, 20]) == [[9,19], [1,2,3], [1,2,3,4]]
end

@testset "math" begin
Expand Down

0 comments on commit 5f02896

Please sign in to comment.