ConstructionBase.jl
ConstructionBase.jl copied to clipboard
add testing helpers
Some helpers to test constructof laws would be nice, similar to what we have in Accessors (https://github.com/JuliaObjects/Accessors.jl/blob/master/ext/AccessorsTestExt.jl). Basically,
function test_constructorof_laws(obj, args; cmp=(==))
ctor = constructorof(typeof(obj))
reconstructed = ctor(getfields(obj)...)
@test cmp(obj, reconstructed)
@test typeof(obj) == typeof(reconstructed)
@test getfields(ctor(args...)) == args
end
Best to put into a Test extension, so this should wait until https://github.com/JuliaObjects/ConstructionBase.jl/pull/86 -related issues get resolved.