Hi,
I’m having some trouble using structs inside @testsets:
julia> @testset "teststruct" begin
struct a end
a(b) = a()
end
teststruct: Error During Test at none:1
Got exception outside of a @test
syntax: Slot objects should not occur in an AST
Stacktrace:
[1] top-level scope at none:2
[2] top-level scope at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.1\Test\src\Test.jl:1083
[3] top-level scope at none:2
[4] eval at .\boot.jl:328 [inlined]
[5] repleval(::Module, ::Expr) at E:\Programs\julia\.julia\packages\Atom\E4PBh\src\repl.jl:135
[6] (::getfield(Atom, Symbol("##168#170")){Module})() at E:\Programs\julia\.julia\packages\Atom\E4PBh\src\repl.jl:157
[7] with_logstate(::getfield(Atom, Symbol("##168#170")){Module}, ::Base.CoreLogging.LogState) at .\logging.jl:395
[8] with_logger at .\logging.jl:491 [inlined]
[9] evalrepl(::Module, ::String) at E:\Programs\julia\.julia\packages\Atom\E4PBh\src\repl.jl:148
[10] top-level scope at E:\Programs\julia\.julia\packages\Atom\E4PBh\src\repl.jl:190
[11] eval(::Module, ::Any) at .\boot.jl:328
[12] eval_user_input(::Any, ::REPL.REPLBackend) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.1\REPL\src\REPL.jl:85
[13] run_backend(::REPL.REPLBackend) at E:\Programs\julia\.julia\packages\Revise\UtBAC\src\Revise.jl:943
[14] (::getfield(Revise, Symbol("##74#76")){REPL.REPLBackend})() at .\task.jl:259Test Summary: | Error Total
teststruct | 1 1
ERROR: Some tests did not pass: 0 passed, 0 failed, 1 errored, 0 broken.
Am I doing something wrong?
Inner constructors seem to work:
julia> @testset "teststruct" begin
struct a
a(b) = new()
end
end
Test Summary: |
teststruct | No tests
Test.DefaultTestSet("teststruct", Any[], 0, false)
It also works if I put the code at the top of a file which is included from runtests.jl, even if the file is included inside a @testset in runtests.jl which in many cases is far from ideal.
I just discovered that it works with inner constructors so if there are any major drawbacks with that approach I guess I’ve yet to discover them