From 6878e20e685114701c2c062c10971e13d396b080 Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Sat, 7 Mar 2026 11:37:03 -0500 Subject: [PATCH] Split off show-and-parse tests --- test/sectors.jl | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/test/sectors.jl b/test/sectors.jl index f02e8f86..24557caf 100644 --- a/test/sectors.jl +++ b/test/sectors.jl @@ -4,9 +4,6 @@ using TensorKitSectors: TensorKitSectors as TKS @testsuite "Basic properties" I -> begin s = (randsector(I), randsector(I), randsector(I)) - @test Base.eval(Main, Meta.parse(sprint(show, I))) == I - @test Base.eval(Main, Meta.parse(TensorKitSectors.type_repr(I))) == I - @test Base.eval(Main, Meta.parse(sprint(show, s[1]))) == s[1] @test @testinferred(hash(s[1])) == hash(deepcopy(s[1])) @test @testinferred(unit(s[1])) == @testinferred(unit(I)) @testinferred dual(s[1]) @@ -37,6 +34,18 @@ using TensorKitSectors: TensorKitSectors as TKS @testinferred(⊗(s..., s...)) end +@testsuite "Show and parse" I -> begin + # test in the parent module of where the test is defined + _module = parentmodule(@__MODULE__) + _eval(x) = Base.eval(_module, x) + _sprint(x) = sprint(show, x; context = (:module => _module)) + @test _eval(Meta.parse(_sprint(I))) == I + @test _eval(Meta.parse(TKS.type_repr(I))) == I + for a in smallset(I) + @test _eval(Meta.parse(_sprint(a))) == a + end +end + @testsuite "Value iterator" I -> begin @test eltype(values(I)) == I sprev = unit(I)