Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect operate test set #242

Merged
merged 2 commits into from
Nov 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions test/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,32 @@ end
end

@testset "operate" begin
@testset "$(typeof(x))" for x in [2, big(3)]
@testset "$op" for op in [+, *, gcd, lcm]
@test MA.operate(op, x) !== x
@testset "$T" for T in (Int, BigInt, Rational{Int})
x = T(7)
@testset "1-ary $op" for op in [+, *, gcd, lcm]
a = op(x)
b = MA.operate(op, x)
@test a == b
if MA.mutability(T, op, T) == MA.IsMutable()
@test a !== b
end
end
ops = [+, *, MA.add_mul, MA.sub_mul, MA.add_dot, gcd, lcm]
@testset "$op" for op in ops
@test MA.operate(op, x, x, x, x) !== op(x, x, x, x)
@testset "4-ary $op" for op in ops
a = op(x, x, x, x)
b = MA.operate(op, x, x, x, x)
@test a == b
if MA.mutability(T, op, T, T, T, T) == MA.IsMutable()
@test a !== b
end
end
@testset "$op" for op in [-, /, div]
@test MA.operate(op, x, x) !== op(x, x)
@testset "2-ary $op" for op in [-, /, div]
a = op(x, x)
b = MA.operate(op, x, x)
@test a == b
if MA.mutability(T, op, T, T) == MA.IsMutable()
@test a !== b
end
end
end
end
Expand Down