Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Jun 6, 2021
1 parent a9e7ec8 commit 7d84bc0
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions test/test_queries.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
using Accessors, ConstructionBase, BenchmarkTools

optic = Accessors.Query(x -> x isa Int)
obj = (7, (a=17.0, b=2.0f0), ("3", 4, 5))
optic = Accessors.Query(; select=x -> x isa Float64, ignore=x -> x isa Tuple)
obj = (7, (a=17.0, b=2.0f0), ("3", 4, 5.0), (x=6.0,), )
vals = (1.0, 2.0, 3.0, 4.0)

@btime $optic($obj)
@btime set($obj, $optic, $vals)
@btime Accessors.set($obj, $optic, $vals)
# Compiles away
@btime modify(x -> 2x, $vals, $optic)
@btime Accessors.modify(x -> 2x, $vals, $optic)


unstable_optic = Accessors.Query(x -> x isa Number && x > 2)

# This is slow
@btime set($x, $unstable_optic, $y)

# This still compiles away
@btime modify(x -> 2x, $vals, $unstable_optic)

unstable_optic = Accessors.Query(x -> x isa Number && x > 4)
@btime Accessors.set($obj, $unstable_optic, $vals)
@btime Accessors.modify(x -> 2x, $obj, $unstable_optic)

0 comments on commit 7d84bc0

Please sign in to comment.