diff --git a/src/utils.jl b/src/utils.jl index 9815847..d83ed1b 100755 --- a/src/utils.jl +++ b/src/utils.jl @@ -15,8 +15,10 @@ function get_args(func_def::Dict) kwarg_list = Vector{Symbol}() for arg in (func_def[:args]...,) arg_def = splitarg(arg) - push!(arg_list, arg_def[1]) - arg_dict[arg_def[1]] = arg_def[3] ? Any : arg_dict[arg_def[1]] = arg_def[2] + if arg_def[1] != nothing + push!(arg_list, arg_def[1]) + arg_dict[arg_def[1]] = arg_def[3] ? Any : arg_dict[arg_def[1]] = arg_def[2] + end end for arg in (func_def[:kwargs]...,) arg_def = splitarg(arg) diff --git a/test/runtests.jl b/test/runtests.jl index e954c02..1a950e1 100755 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -140,4 +140,46 @@ end @testset "test_continue" begin @test collect(test_continue()) == [1, 3, 4, 5, 6, 7, 8, 9, 10] @test collect(test_continue_double()) == [1, 3, 1, 3] -end \ No newline at end of file +end + +@resumable function test_type_parameters(::Type{Int64}, start::Int64) + for i in start:start+3 + @yield i + end +end + +@resumable function test_type_parameters(::Type{Float64}, start::Int64) + for i in start:start+3 + @yield float(i) + end +end + +@testset "test_type_parameters" begin + @test collect(test_type_parameters(Int64, 1)) == [1, 2, 3, 4] + @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