Skip to content

Commit

Permalink
tests: improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
aplavin committed Mar 3, 2024
1 parent d509019 commit 66aa453
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
6 changes: 2 additions & 4 deletions test/perf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,14 @@ end
println("Right associative composition: $b_right")

@test b_default.allocs == 0
if VERSION >= v"1.10-"
@test_broken b_right.allocs == 0
elseif VERSION >= v"1.7"
if VERSION >= v"1.7"
@test b_right.allocs == 0
else
@test_broken right.allocs == 0
@test b_right.time > 2b_default.time
end
@test b_left.allocs == 0
@test b_left.time b_default.time rtol=0.8
@test b_right.time b_default.time rtol=0.8
end

end
16 changes: 3 additions & 13 deletions test/test_core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -220,19 +220,9 @@ end
((@optic _.b.a.b[end]), 4.0),
((@optic _.b.a.b[end÷2+1]), 4.0),
]
if VERSION < v"1.7" || VERSION >= v"1.10-"
@inferred lens(obj)
@inferred set(obj, lens, val)
@inferred modify(identity, obj, lens)
else
@inferred lens(obj)
@inferred set(obj, lens, val)
@test_broken begin
# https://github.com/JuliaLang/julia/issues/43296
@inferred modify(identity, obj, lens)
true
end
end
@inferred lens(obj)
@inferred set(obj, lens, val)
@inferred modify(identity, obj, lens)
end
end

Expand Down
8 changes: 8 additions & 0 deletions test/test_functionlenses.jl
Original file line number Diff line number Diff line change
Expand Up @@ -391,4 +391,12 @@ end
test_getset_laws(o2, x, 2, -3)
end

@testset "non-callable" begin
struct MyF end
Accessors.set(x, ::MyF, y) = y + 1
Accessors.modify(f, x, ::MyF) = f(x)
@test set(1, (@o _ + 2 |> MyF()), 3) == 2
@test modify(x -> 10x, 1, (@o _ + 2 |> MyF())) == 28
end

end # module

0 comments on commit 66aa453

Please sign in to comment.