For OSCAR, we use "testset templates" to provide generic conformance for various "interfaces" based on Test.
These currently come in the form of a function that takes an object to be tested, and which then internally produces a @testset carrying out the test. The idea is that other packages then can use these conformance tests on their own implementations of those interfaces/protocols.
Here is a severely stripped down example:
function test_Ring_interface(R::AbstractAlgebra.Ring)
T = elem_type(R)
@testset "Ring interface for $(R) of type $(typeof(R))" begin
@test T <: RingElement
# ... more tests come here
end
end
Unfortunately, with ReTest, this doesn't seem to be supported? Trying to use ReTest with the above resulted in this:
...
nested task error: TaskFailedException
nested task error: UndefVarError: R not defined
Stacktrace:
[1] macro expansion
@ ~/.julia/packages/ReTest/WnRIG/src/testset.jl:505 [inlined]
[2] macro expansion
@ ~/Projekte/OSCAR/AbstractAlgebra.jl/test/Rings-conformance-tests.jl:205 [inlined]
[3] top-level scope
@ ~/.julia/packages/ReTest/WnRIG/src/ReTest.jl:517
[4] eval
@ ./boot.jl:360 [inlined]
...
I.e. it isn't capturing the surrounding context.
Is there any chance this could be fixed? If so, how complicated do you think it would be / where would one have to start?
I am also open to alternative suggestions for implementing such conformance tests; but the current approach is quite nice in that it is easy to grok what it does.
For OSCAR, we use "testset templates" to provide generic conformance for various "interfaces" based on
Test.These currently come in the form of a function that takes an object to be tested, and which then internally produces a
@testsetcarrying out the test. The idea is that other packages then can use these conformance tests on their own implementations of those interfaces/protocols.Here is a severely stripped down example:
Unfortunately, with
ReTest, this doesn't seem to be supported? Trying to useReTestwith the above resulted in this:I.e. it isn't capturing the surrounding context.
Is there any chance this could be fixed? If so, how complicated do you think it would be / where would one have to start?
I am also open to alternative suggestions for implementing such conformance tests; but the current approach is quite nice in that it is easy to grok what it does.