Skip to content

Commit 5d9424a

Browse files
committed
properly namespace the show tests
1 parent 6d590f0 commit 5d9424a

File tree

2 files changed

+27
-25
lines changed

2 files changed

+27
-25
lines changed

test/symmetries/fusiontrees.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ using .TestSetup
2727
@constinferred Nothing iterate(it, s)
2828
@test f == @constinferred first(it)
2929
@testset "Fusion tree $Istr: printing" begin
30-
@test eval(Meta.parse(sprint(show, f))) == f
30+
@test eval(Meta.parse(sprint(show, f; context = (:module => @__MODULE__)))) == f
3131
end
3232
@testset "Fusion tree $Istr: constructor properties" begin
3333
u = one(I)

test/symmetries/spaces.jl

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ using TensorKit
44
@isdefined(TestSetup) || include("../setup.jl")
55
using .TestSetup
66

7+
parse_show(x) = Meta.parse(sprint(show, x; context = (:module => @__MODULE__)))
8+
79
@timedtestset "Fields" begin
810
@test isa(ℝ, Field)
911
@test isa(ℂ, Field)
10-
@test eval(Meta.parse(sprint(show, ℝ))) ==
11-
@test eval(Meta.parse(sprint(show, ℂ))) ==
12+
@test eval(parse_show(ℝ)) ==
13+
@test eval(parse_show(ℂ)) ==
1214
@test
1315
@test
1416
@test
@@ -49,8 +51,8 @@ end
4951
@timedtestset "ElementarySpace: CartesianSpace" begin
5052
d = 2
5153
V =^d
52-
@test eval(Meta.parse(sprint(show, V))) == V
53-
@test eval(Meta.parse(sprint(show, typeof(V)))) == typeof(V)
54+
@test eval(parse_show(V)) == V
55+
@test eval(parse_show(typeof(V))) == typeof(V)
5456
@test isa(V, VectorSpace)
5557
@test isa(V, ElementarySpace)
5658
@test isa(InnerProductStyle(V), HasInnerProduct)
@@ -93,9 +95,9 @@ end
9395
@timedtestset "ElementarySpace: ComplexSpace" begin
9496
d = 2
9597
V =^d
96-
@test eval(Meta.parse(sprint(show, V))) == V
97-
@test eval(Meta.parse(sprint(show, V'))) == V'
98-
@test eval(Meta.parse(sprint(show, typeof(V)))) == typeof(V)
98+
@test eval(parse_show(V)) == V
99+
@test eval(parse_show(V')) == V'
100+
@test eval(parse_show(typeof(V))) == typeof(V)
99101
@test isa(V, VectorSpace)
100102
@test isa(V, ElementarySpace)
101103
@test isa(InnerProductStyle(V), HasInnerProduct)
@@ -145,10 +147,10 @@ end
145147
@timedtestset "ElementarySpace: GeneralSpace" begin
146148
d = 2
147149
V = GeneralSpace{ℂ}(d)
148-
@test eval(Meta.parse(sprint(show, V))) == V
149-
@test eval(Meta.parse(sprint(show, dual(V)))) == dual(V)
150-
@test eval(Meta.parse(sprint(show, conj(V)))) == conj(V)
151-
@test eval(Meta.parse(sprint(show, typeof(V)))) == typeof(V)
150+
@test eval(parse_show(V)) == V
151+
@test eval(parse_show(dual(V))) == dual(V)
152+
@test eval(parse_show(conj(V))) == conj(V)
153+
@test eval(parse_show(typeof(V))) == typeof(V)
152154
@test !isdual(V)
153155
@test isdual(V')
154156
@test !isdual(conj(V))
@@ -179,8 +181,8 @@ end
179181
end
180182
V = GradedSpace(gen)
181183
@test eval(Meta.parse(TensorKit.type_repr(typeof(V)))) == typeof(V)
182-
@test eval(Meta.parse(sprint(show, V))) == V
183-
@test eval(Meta.parse(sprint(show, V'))) == V'
184+
@test eval(parse_show(V)) == V
185+
@test eval(parse_show(V')) == V'
184186
@test V' == GradedSpace(gen; dual = true)
185187
@test V == @constinferred GradedSpace(gen...)
186188
@test V' == @constinferred GradedSpace(gen...; dual = true)
@@ -201,8 +203,8 @@ end
201203
end
202204
@test @constinferred(hash(V)) == hash(deepcopy(V)) != hash(V')
203205
@test V == GradedSpace(reverse(collect(gen))...)
204-
@test eval(Meta.parse(sprint(show, V))) == V
205-
@test eval(Meta.parse(sprint(show, typeof(V)))) == typeof(V)
206+
@test eval(parse_show(V)) == V
207+
@test eval(parse_show(typeof(V))) == typeof(V)
206208
# space with no sectors
207209
@test dim(@constinferred(zero(V))) == 0
208210
# space with a single sector
@@ -212,7 +214,7 @@ end
212214
@test @constinferred(zero(V)) == GradedSpace(one(I) => 0)
213215
# randsector never returns trivial sector, so this cannot error
214216
@test_throws ArgumentError GradedSpace(one(I) => 1, randsector(I) => 0, one(I) => 3)
215-
@test eval(Meta.parse(sprint(show, W))) == W
217+
@test eval(parse_show(W)) == W
216218
@test isa(V, VectorSpace)
217219
@test isa(V, ElementarySpace)
218220
@test isa(InnerProductStyle(V), HasInnerProduct)
@@ -257,8 +259,8 @@ end
257259
@timedtestset "ProductSpace{ℂ}" begin
258260
V1, V2, V3, V4 =^1, ℂ^2, ℂ^3, ℂ^4
259261
P = @constinferred ProductSpace(V1, V2, V3, V4)
260-
@test eval(Meta.parse(sprint(show, P))) == P
261-
@test eval(Meta.parse(sprint(show, typeof(P)))) == typeof(P)
262+
@test eval(parse_show(P)) == P
263+
@test eval(parse_show(typeof(P))) == typeof(P)
262264
@test isa(P, VectorSpace)
263265
@test isa(P, CompositeSpace)
264266
@test spacetype(P) == ComplexSpace
@@ -285,11 +287,11 @@ end
285287
@test fuse(flip(V1), V2, flip(V3)) V1 V2 V3
286288
@test @constinferred((P)) == P
287289
@test @constinferred((V1)) == ProductSpace(V1)
288-
@test eval(Meta.parse(sprint(show, (V1)))) == (V1)
290+
@test eval(parse_show((V1))) == (V1)
289291
@test @constinferred(one(V1)) == @constinferred(one(typeof(V1))) ==
290292
@constinferred(one(P)) == @constinferred(one(typeof(P))) ==
291293
ProductSpace{ComplexSpace}(())
292-
@test eval(Meta.parse(sprint(show, one(P)))) == one(P)
294+
@test eval(parse_show(one(P))) == one(P)
293295
@test @constinferred((one(P), P)) == P
294296
@test @constinferred((P, one(P))) == P
295297
@test @constinferred((one(P), one(P))) == one(P)
@@ -324,8 +326,8 @@ end
324326
V1, V2, V3 = SU₂Space(0 => 3, 1 // 2 => 1), SU₂Space(0 => 2, 1 => 1),
325327
SU₂Space(1 // 2 => 1, 1 => 1)'
326328
P = @constinferred ProductSpace(V1, V2, V3)
327-
@test eval(Meta.parse(sprint(show, P))) == P
328-
@test eval(Meta.parse(sprint(show, typeof(P)))) == typeof(P)
329+
@test eval(parse_show(P)) == P
330+
@test eval(parse_show(typeof(P))) == typeof(P)
329331
@test isa(P, VectorSpace)
330332
@test isa(P, CompositeSpace)
331333
@test spacetype(P) == SU₂Space
@@ -403,8 +405,8 @@ end
403405
@test W == (V3 V4 V5 V1 V2)
404406
@test W == (V1 V2 V3 V4 V5)
405407
@test W' == (V1 V2 V3 V4 V5)
406-
@test eval(Meta.parse(sprint(show, W))) == W
407-
@test eval(Meta.parse(sprint(show, typeof(W)))) == typeof(W)
408+
@test eval(parse_show(W)) == W
409+
@test eval(parse_show(typeof(W))) == typeof(W)
408410
@test spacetype(W) == typeof(V1)
409411
@test sectortype(W) == sectortype(V1)
410412
@test W[1] == V1

0 commit comments

Comments
 (0)