Skip to content

Commit bb39276

Browse files
committed
more mod tests
1 parent 0effa2a commit bb39276

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

test/test_extensions.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ VERSION >= v"1.9-" && @testset "IntervalSets" begin
6666
@test 2 === @set 2 |> mod(_, 20..23) = 20
6767
@test 33 === @set 32 |> mod(_, 20..23) = 21
6868
test_getset_laws(@optic(mod(_, 5..8)), 20, 6, 5)
69+
70+
@test_throws Exception mod(3, 1..0)
71+
@test_throws Exception @set mod($3, 1..0) = 1
72+
@test_throws Exception @set mod($3, 1..5) = 10
6973
end
7074

7175
@testset "StaticArrays" begin

test/test_functionlenses.jl

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,25 @@ end
257257
# invertible lenses below: no need for extensive testing, simply forwarded to InverseFunctions
258258
inv, +, exp, sqrt, @optic(2 + _), @optic(_ * 3), @optic(log(2, _)),
259259
# non-invertible lenses, indirectly forwarded to InverseFunctions
260-
@optic(mod(_, 21)), @optic(fld(_, 3)), @optic(rem(_, 21)), @optic(div(_, 3)), @optic(mod(_, 1:22)),
260+
@optic(mod(_, 21)), @optic(fld(_, 3)), @optic(rem(_, 21)), @optic(div(_, 3)),
261261
]
262262
x = 5
263263
test_getset_laws(o, x, 10, 20; cmp=isapprox)
264264
@inferred set(x, o, 10)
265265
end
266+
267+
@testset for (rng, x, y) in [
268+
(0:3, 2, 1),
269+
(0:3, 32, 1),
270+
(20:23, 2, 20),
271+
(20:23, 32, 21),
272+
(5:8, 20, 6),
273+
]
274+
test_getset_laws((@o mod(_, rng)), x, y, y+1)
275+
end
276+
@test_throws Exception mod(3, 1:0)
277+
@test_throws Exception @set mod($3, 1:0) = 1
278+
@test_throws Exception @set mod($3, 1:5) = 10
266279

267280
x = 3 + 4im
268281
@test @set(abs(-2u"m") = 1u"m") === -1u"m"

0 commit comments

Comments
 (0)