Skip to content

Commit

Permalink
Stronger tests (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tortar authored Sep 28, 2024
1 parent a497842 commit 6be608e
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ using Test
using HybridStructs

@hybrid struct A
x::Int
x::Int
end

abstract type AbstractB{X} end

@hybrid struct B{X} <: AbstractB{X}
x::X
y::Int
const z
B{X}(x, y) where X = new{X}(x, y, 1)
B{X}(x, y, z) where X = new{X}(x, y, z)
function B(x::X, y, z) where X
return new{X}(x, y, z)
end
@hybrid struct B{X,Y} <: AbstractB{X}
x::X
y::Y
const z
B{X,Y}(x, y) where {X,Y} = new{X,Y}(x, y, 1)
B{X,Y}(x, y, z) where {X,Y} = new{X,Y}(x, y, z)
function B(x::X, y::Y, z) where {X,Y}
return new{X,Y}(x, y, z)
end
end

@testset "HybridStructs.jl Tests" begin
Expand All @@ -37,8 +37,8 @@ end
@test AbstractB_Mut <: AbstractB

b1 = B_Immut(1, 2, :im)
b2 = B_Immut{Float64}(3, 2, 4.0)
b3 = B_Mut{Int}(3, 2, 4.0)
b2 = B_Immut{Float64, Int}(3, 2, 4.0)
b3 = B_Mut{Int, Int}(3, 2, 4.0)

@test b1.x === 1
@test b1 isa B_Immut{Int}
Expand Down

0 comments on commit 6be608e

Please sign in to comment.