Skip to content

Commit

Permalink
Added a further test for optional type parmeters.
Browse files Browse the repository at this point in the history
  • Loading branch information
Luca Di Gaspero committed Jan 21, 2023
1 parent 175cc47 commit 2a1c335
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,27 @@ end
@test collect(test_type_parameters(Float64, 1)) == [1.0, 2.0, 3.0, 4.0]
end

@resumable function test_type_parameters_order(start::Int64, ::Type{T})::T where {T}
for i in start:start+3
@yield T(i)
end
end

@testset "test_type_parameters_order" begin
@test collect(test_type_parameters_order(1, Int64)) == [1, 2, 3, 4]
@test collect(test_type_parameters_order(1, Float64)) == [1.0, 2.0, 3.0, 4.0]
@test typeof(first(test_type_parameters_order(1, ComplexF32))) == ComplexF32
end

@resumable function test_type_parameters_optional(start::Int64; t::Type{T}=Type{Int64})::T where {T}
for i in start:start+3
@yield T(i)
end
end


@testset "test_type_parameters_optional" begin
@test collect(test_type_parameters_optional(1, t=Int64)) == [1, 2, 3, 4]
@test collect(test_type_parameters_optional(1, t=Float64)) == [1.0, 2.0, 3.0, 4.0]
@test typeof(first(test_type_parameters_optional(1, t=ComplexF32))) == ComplexF32
end

0 comments on commit 2a1c335

Please sign in to comment.