Skip to content

Commit 8365f34

Browse files
committed
Add test for TYPEDSIGNATURENORETURN abbreviation
The abbreviation should behave in the same way as TYPEDSIGNATURE but omit the return type.
1 parent 93cd69a commit 8365f34

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

test/tests.jl

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,81 @@ end
455455

456456
end
457457

458+
@testset "method signatures with types (no return type)" begin
459+
doc.data = Dict(
460+
:binding => Docs.Binding(M, :h_1),
461+
:typesig => Tuple{M.A},
462+
:module => M,
463+
)
464+
DSE.format(DSE.TYPEDSIGNATURESNORETURN, buf, doc)
465+
str = String(take!(buf))
466+
@test occursin("\n```julia\n", str)
467+
f = str -> replace(str, " " => "")
468+
str = f(str)
469+
if Sys.iswindows() && VERSION < v"1.8"
470+
@test occursin(f("h_1(x::Union{Array{T,4}, Array{T,3}} where T)"), str)
471+
else
472+
@test occursin(f("h_1(x::Union{Array{T,3}, Array{T,4}} where T)"), str)
473+
end
474+
@test !occursin("->", str)
475+
@test occursin("\n```\n", str)
476+
477+
478+
doc.data = Dict(
479+
:binding => Docs.Binding(M, :g_2),
480+
:typesig => Tuple{String},
481+
:module => M,
482+
)
483+
DSE.format(TYPEDSIGNATURESNORETURN, buf, doc)
484+
str = String(take!(buf))
485+
@test occursin("\n```julia\n", str)
486+
@test occursin("\ng_2(x::String)", str)
487+
@test occursin("\n```\n", str)
488+
489+
doc.data = Dict(
490+
:binding => Docs.Binding(M, :h),
491+
:typesig => Tuple{Int, Int, Int},
492+
:module => M,
493+
)
494+
DSE.format(DSE.TYPEDSIGNATURESNORETURN, buf, doc)
495+
str = String(take!(buf))
496+
@test occursin("\n```julia\n", str)
497+
if typeof(1) === Int64
498+
@test occursin("\nh(x::Int64, y::Int64, z::Int64; kwargs...)\n", str)
499+
else
500+
@test occursin("\nh(x::Int32, y::Int32, z::Int32; kwargs...)\n", str)
501+
end
502+
@test occursin("\n```\n", str)
503+
504+
doc.data = Dict(
505+
:binding => Docs.Binding(M, :h),
506+
:typesig => Tuple{Int},
507+
:module => M,
508+
)
509+
DSE.format(DSE.TYPEDSIGNATURESNORETURN, buf, doc)
510+
str = String(take!(buf))
511+
@test occursin("\n```julia\n", str)
512+
if typeof(1) === Int64
513+
# On 1.10+, automatically generated methods have keywords in the metadata,
514+
# hence the display difference between Julia versions.
515+
if VERSION >= v"1.10"
516+
@test occursin("\nh(x::Int64; ...)\n", str)
517+
else
518+
@test occursin("\nh(x::Int64)\n", str)
519+
end
520+
else
521+
# On 1.10+, automatically generated methods have keywords in the metadata,
522+
# hence the display difference between Julia versions.
523+
if VERSION >= v"1.10"
524+
@test occursin("\nh(x::Int32; ...)\n", str)
525+
else
526+
@test occursin("\nh(x::Int32)\n", str)
527+
end
528+
end
529+
@test occursin("\n```\n", str)
530+
531+
end
532+
458533
@testset "function names" begin
459534
doc.data = Dict(
460535
:binding => Docs.Binding(M, :f),

0 commit comments

Comments
 (0)