Skip to content

Commit c2e8ca1

Browse files
committed
setup some testing
1 parent 58ee5e0 commit c2e8ca1

File tree

5 files changed

+89
-64
lines changed

5 files changed

+89
-64
lines changed

Project.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,20 @@ JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
99
TensorKitSectors = "13a9c161-d5da-41f0-bcbd-e1a08ae0647f"
1010

1111
[compat]
12+
Aqua = "0.8.9"
1213
Artifacts = "1.11.0"
1314
JSON3 = "1.14.1"
15+
SafeTestsets = "0.1"
1416
TensorKitSectors = "0.1.2"
17+
Test = "1.10"
18+
TestExtras = "0.3"
1519
julia = "1.10"
20+
21+
[extras]
22+
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
23+
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
24+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
25+
TestExtras = "5ed8adda-3752-4e41-b88a-e8b09835ee3a"
26+
27+
[targets]
28+
test = ["Aqua", "SafeTestsets", "Test", "TestExtras"]

test/Project.toml

Lines changed: 0 additions & 11 deletions
This file was deleted.

test/basics/test_A4.jl

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using MultiTensorKit
2+
using TensorKitSectors
3+
using Test, TestExtras
4+
5+
I = A4Object
6+
7+
@testset "Basic type properties" begin
8+
Istr = TensorKitSectors.type_repr(I)
9+
@test eval(Meta.parse(sprint(show, I))) == I
10+
@test eval(Meta.parse(TensorKitSectors.type_repr(I))) == I
11+
end
12+
13+
@testset "Fusion Category $i" for i in 1:12
14+
objects = A4Object.(i, i, MultiTensorKit._get_dual_cache(I)[i][2])
15+
16+
@testset "Basic properties" begin
17+
s = rand(objects, 3)
18+
@test eval(Meta.parse(sprint(show, s[1]))) == s[1]
19+
@test @constinferred(hash(s[1])) == hash(deepcopy(s[1]))
20+
@test isone(@constinferred(one(s[1])))
21+
@constinferred dual(s[1])
22+
@constinferred dim(s[1])
23+
@constinferred frobeniusschur(s[1])
24+
@constinferred Bsymbol(s...)
25+
@constinferred Fsymbol(s..., s...)
26+
end
27+
28+
@testset "Unitarity of F-move" begin
29+
for a in objects, b in objects, c in objects
30+
for d in (a, b, c)
31+
es = collect(intersect((a, b), map(dual, (c, dual(d)))))
32+
fs = collect(intersect((b, c), map(dual, (dual(d), a))))
33+
Fblocks = Vector{Any}()
34+
for e in es
35+
for f in fs
36+
Fs = Fsymbol(a, b, c, d, e, f)
37+
push!(Fblocks,
38+
reshape(Fs,
39+
(size(Fs, 1) * size(Fs, 2),
40+
size(Fs, 3) * size(Fs, 4))))
41+
end
42+
end
43+
F = hvcat(length(fs), Fblocks...)
44+
@test isapprox(F' * F, one(F); atol=1e-12, rtol=1e-12)
45+
end
46+
end
47+
end
48+
49+
@testset "Pentagon equation" begin
50+
for a in objects, b in objects, c in objects, d in objects
51+
@test pentagon_equation(a, b, c, d; atol=1e-12, rtol=1e-12)
52+
end
53+
end
54+
end

test/basics/test_basics.jl

Lines changed: 0 additions & 6 deletions
This file was deleted.

test/runtests.jl

Lines changed: 22 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,38 @@
11
using SafeTestsets: @safetestset
2-
using Suppressor: Suppressor
32

43
# check for filtered groups
54
# either via `--group=ALL` or through ENV["GROUP"]
65
const pat = r"(?:--group=)(\w+)"
76
arg_id = findfirst(contains(pat), ARGS)
8-
const GROUP = uppercase(
9-
if isnothing(arg_id)
10-
get(ENV, "GROUP", "ALL")
11-
else
12-
only(match(pat, ARGS[arg_id]).captures)
13-
end,
14-
)
7+
const GROUP = uppercase(if isnothing(arg_id)
8+
get(ENV, "GROUP", "ALL")
9+
else
10+
only(match(pat, ARGS[arg_id]).captures)
11+
end)
1512

1613
"match files of the form `test_*.jl`, but exclude `*setup*.jl`"
17-
istestfile(fn) =
18-
endswith(fn, ".jl") && startswith(basename(fn), "test_") && !contains(fn, "setup")
19-
"match files of the form `*.jl`, but exclude `*_notest.jl` and `*setup*.jl`"
20-
isexamplefile(fn) =
21-
endswith(fn, ".jl") && !endswith(fn, "_notest.jl") && !contains(fn, "setup")
14+
istestfile(fn) = endswith(fn, ".jl") && startswith(basename(fn), "test_") &&
15+
!contains(fn, "setup")
2216

2317
@time begin
24-
# tests in groups based on folder structure
25-
for testgroup in filter(isdir, readdir(@__DIR__))
26-
if GROUP == "ALL" || GROUP == uppercase(testgroup)
27-
groupdir = joinpath(@__DIR__, testgroup)
28-
for file in filter(istestfile, readdir(groupdir))
29-
filename = joinpath(groupdir, file)
30-
@eval @safetestset $file begin
31-
include($filename)
18+
# tests in groups based on folder structure
19+
for testgroup in filter(isdir, readdir(@__DIR__))
20+
if GROUP == "ALL" || GROUP == uppercase(testgroup)
21+
groupdir = joinpath(@__DIR__, testgroup)
22+
for file in filter(istestfile, readdir(groupdir))
23+
filename = joinpath(groupdir, file)
24+
@eval @safetestset $file begin
25+
include($filename)
26+
end
27+
end
3228
end
33-
end
34-
end
35-
end
36-
37-
# single files in top folder
38-
for file in filter(istestfile, readdir(@__DIR__))
39-
(file == basename(@__FILE__)) && continue # exclude this file to avoid infinite recursion
40-
@eval @safetestset $file begin
41-
include($file)
4229
end
43-
end
4430

45-
# test examples
46-
examplepath = joinpath(@__DIR__, "..", "examples")
47-
for (root, _, files) in walkdir(examplepath)
48-
contains(chopprefix(root, @__DIR__), "setup") && continue
49-
for file in filter(isexamplefile, files)
50-
filename = joinpath(root, file)
51-
@eval begin
52-
@safetestset $file begin
53-
$(Expr(
54-
:macrocall,
55-
GlobalRef(Suppressor, Symbol("@suppress")),
56-
LineNumberNode(@__LINE__, @__FILE__),
57-
:(include($filename)),
58-
))
31+
# single files in top folder
32+
for file in filter(istestfile, readdir(@__DIR__))
33+
(file == basename(@__FILE__)) && continue # exclude this file to avoid infinite recursion
34+
@eval @safetestset $file begin
35+
include($file)
5936
end
60-
end
6137
end
62-
end
6338
end

0 commit comments

Comments
 (0)