Skip to content

Commit

Permalink
Fixing the issues in the tests (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
kmp5VT authored Dec 10, 2024
1 parent 8e4092e commit 6f2ed71
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 75 deletions.
4 changes: 4 additions & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
NDTensors = "23ae76d9-e61a-49c4-8f12-3f1a16adf9cf"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138"

[sources]
TypeParameterAccessors = {url = "https://github.com/ITensor/TypeParameterAccessors.jl"}
75 changes: 0 additions & 75 deletions test/test_basics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -249,79 +249,4 @@ using .NDTensorsTestUtils: devices_list
end
end

## TODO: These are broken, fix them. Also, split off into a
## seperate test file, and maybe make a package extension?
## using FillArrays: Fill, Zeros
## using UnallocatedArrays: UnallocatedFill, UnallocatedZeros
## using TypeParameterAccessors:
## Position, default_type_parameter, nparameters, set_type_parameter, type_parameter
## using Test: @test, @testset
##
## @testset "SetParameters" begin
## @testset "Testing $typ" for typ in (:Fill, :Zeros)
## t1 = default_type_parameter(typ, Position{1}())
## t2 = default_type_parameter(typ, Position{2}())
## t3 = default_type_parameter(typ, Position{3}())
## t4 = Any
## ft1 = typ{t1}
## ft2 = typ{t1,t2}
## ft3 = typ{t1,t2,t3}
##
## ## check 1 parameter specified
## ftn1 = set_type_parameter(ft1, Position{1}(), t4)
## ftn2 = set_type_parameter(ft1, Position{2}(), t4)
## ftn3 = set_type_parameter(ft1, Position{3}(), t4)
## @test ftn1 == typ{t4}
## @test ftn2 == typ{t1,t4}
## @test ftn3 == typ{t1,<:Any,t4}
##
## ## check 2 parameters specified
## ftn1 = set_type_parameter(ft2, Position{1}(), t4)
## ftn2 = set_type_parameter(ft2, Position{2}(), t4)
## ftn3 = set_type_parameter(ft2, Position{3}(), t4)
## @test ftn1 == typ{t4,t2}
## @test ftn2 == typ{t1,t4}
## @test ftn3 == typ{t1,t2,t4}
##
## ## check 3 parameters specified
## ftn1 = set_type_parameter(ft3, Position{1}(), t4)
## ftn2 = set_type_parameter(ft3, Position{2}(), t4)
## ftn3 = set_type_parameter(ft3, Position{3}(), t4)
## @test ftn1 == typ{t4,t2,t3}
## @test ftn2 == typ{t1,t4,t3}
## @test ftn3 == typ{t1,t2,t4}
##
## @test type_parameter(ft3, Position{1}()) == t1
## @test type_parameter(ft3, Position{2}()) == t2
## @test type_parameter(ft3, Position{3}()) == t3
##
## @test nparameters(ft3) == 3
## end
##
## @testset "Testing $typ" for typ in (:UnallocatedFill, :UnallocatedZeros)
## t1 = default_type_parameter(typ, Position{1}())
## t2 = default_type_parameter(typ, Position{2}())
## t3 = default_type_parameter(typ, Position{3}())
## t4 = default_type_parameter(typ, Position{4}())
## t5 = Any
## ft = typ{t1,t2,t3,t4}
##
## ## check 4 parameters specified
## ftn1 = set_type_parameter(ft, Position{1}(), t5)
## ftn2 = set_type_parameter(ft, Position{2}(), t5)
## ftn3 = set_type_parameter(ft, Position{3}(), t5)
## ftn4 = set_type_parameter(ft, Position{4}(), t5)
## @test ftn1 == typ{t5,t2,t3,t4}
## @test ftn2 == typ{t1,t5,t3,t4}
## @test ftn3 == typ{t1,t2,t5,t4}
## @test ftn4 == typ{t1,t2,t3,t5}
##
## @test type_parameter(ft, Position{1}()) == t1
## @test type_parameter(ft, Position{2}()) == t2
## @test type_parameter(ft, Position{3}()) == t3
## @test type_parameter(ft, Position{4}()) == t4
##
## @test nparameters(ft) == 4
## end
## end
end
77 changes: 77 additions & 0 deletions test/test_defaults.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@

## TODO: These are broken, fix them. Also, split off into a
## seperate test file, and maybe make a package extension?
@eval module $(gensym())
using FillArrays: Fill, Zeros
using UnallocatedArrays: UnallocatedFill, UnallocatedZeros
using TypeParameterAccessors:
Position, default_type_parameter, nparameters, set_type_parameter, type_parameter
using Test: @test, @testset

#@testset "SetParameters" begin
@testset "Testing $typ" for typ in (Fill, Zeros)
t1 = default_type_parameter(typ, Position{1}())
t2 = default_type_parameter(typ, Position{2}())
t3 = default_type_parameter(typ, Position{3}())
t4 = Any
ft1 = typ{t1}
ft2 = typ{t1,t2}
ft3 = typ{t1,t2,t3}

## check 1 parameter specified
ftn1 = set_type_parameter(ft1, Position{1}(), t4)
ftn2 = set_type_parameter(ft1, Position{2}(), t4)
ftn3 = set_type_parameter(ft1, Position{3}(), t4)
@test ftn1 == typ{t4}
@test ftn2 == typ{t1,t4}
@test ftn3 == typ{t1,<:Any,t4}

## check 2 parameters specified
ftn1 = set_type_parameter(ft2, Position{1}(), t4)
ftn2 = set_type_parameter(ft2, Position{2}(), t4)
ftn3 = set_type_parameter(ft2, Position{3}(), t4)
@test ftn1 == typ{t4,t2}
@test ftn2 == typ{t1,t4}
@test ftn3 == typ{t1,t2,t4}

## check 3 parameters specified
ftn1 = set_type_parameter(ft3, Position{1}(), t4)
ftn2 = set_type_parameter(ft3, Position{2}(), t4)
ftn3 = set_type_parameter(ft3, Position{3}(), t4)
@test ftn1 == typ{t4,t2,t3}
@test ftn2 == typ{t1,t4,t3}
@test ftn3 == typ{t1,t2,t4}

@test type_parameter(ft3, Position{1}()) == t1
@test type_parameter(ft3, Position{2}()) == t2
@test type_parameter(ft3, Position{3}()) == t3

@test nparameters(ft3) == 3
end

@testset "Testing $typ" for typ in (UnallocatedFill, UnallocatedZeros)
t1 = default_type_parameter(typ, Position{1}())
t2 = default_type_parameter(typ, Position{2}())
t3 = default_type_parameter(typ, Position{3}())
t4 = default_type_parameter(typ, Position{4}())
t5 = Any
ft = typ{t1,t2,t3,t4}

## check 4 parameters specified
ftn1 = set_type_parameter(ft, Position{1}(), t5)
ftn2 = set_type_parameter(ft, Position{2}(), t5)
ftn3 = set_type_parameter(ft, Position{3}(), t5)
ftn4 = set_type_parameter(ft, Position{4}(), t5)
@test ftn1 == typ{t5,t2,t3,t4}
@test ftn2 == typ{t1,t5,t3,t4}
@test ftn3 == typ{t1,t2,t5,t4}
@test ftn4 == typ{t1,t2,t3,t5}

@test type_parameter(ft, Position{1}()) == t1
@test type_parameter(ft, Position{2}()) == t2
@test type_parameter(ft, Position{3}()) == t3
@test type_parameter(ft, Position{4}()) == t4

@test nparameters(ft) == 4
end
end

0 comments on commit 6f2ed71

Please sign in to comment.