@@ -9,12 +9,12 @@ function with_test_repo(f)
99 repo = LibGit2. init (joinpath (@__DIR__ , " TestModule" ))
1010 LibGit2. add! (repo, " M.jl" )
1111 sig
= LibGit2
. Signature (
" zeptodoctor" ,
" [email protected] " ,
round (
time ()),
0 )
12- LibGit2. commit (repo, " M.jl" , committer = sig, author = sig)
12+ LibGit2. commit (repo, " M.jl" , committer= sig, author= sig)
1313 LibGit2. GitRemote (repo, " origin" , " https://github.com/JuliaDocs/NonExistent.jl.git" )
1414 try
1515 f ()
1616 finally
17- rm (joinpath (@__DIR__ , " TestModule" , " .git" ); force = true , recursive = true )
17+ rm (joinpath (@__DIR__ , " TestModule" , " .git" ); force= true , recursive= true )
1818 end
1919end
2020
5959 @test kwargs == [:y ]
6060 # Base.kwarg_decl will return a Tuple{} for some reason when called on a method
6161 # that does not have any arguments
62- m = which (M. j_1, (Any,Any)) # fetch the no-keyword method
62+ m = which (M. j_1, (Any, Any)) # fetch the no-keyword method
6363 if VERSION < v " 1.4.0-DEV.215"
6464 @test Base. kwarg_decl (m, typeof (get_mt (M. j_1). kwsorter)) == Tuple {} ()
6565 else
147147
148148 doc. data = Dict (
149149 :binding => Docs. Binding (M, :g ),
150- :typesig => Union{Tuple{}, Tuple{Any}},
150+ :typesig => Union{Tuple{},Tuple{Any}},
151151 :module => M,
152152 )
153153 DSE. format (SIGNATURES, buf, doc)
166166
167167 doc. data = Dict (
168168 :binding => Docs. Binding (M, :g ),
169- :typesig => Union{Tuple{}, Tuple{Any}, Tuple{Any, Any}, Tuple{Any, Any, Any}},
169+ :typesig => Union{Tuple{},Tuple{Any},Tuple{Any,Any},Tuple{Any,Any,Any}},
170170 :module => M,
171171 )
172172 DSE. format (SIGNATURES, buf, doc)
199199
200200 doc. data = Dict (
201201 :binding => Docs. Binding (M, :h_4 ),
202- :typesig => Union{Tuple{Any, Int, Any}},
202+ :typesig => Union{Tuple{Any,Int,Any}},
203203 :module => M,
204204 )
205205 DSE. format (SIGNATURES, buf, doc)
240240
241241 doc. data = Dict (
242242 :binding => Docs. Binding (M, :h ),
243- :typesig => Tuple{Int, Int, Int},
243+ :typesig => Tuple{Int,Int,Int},
244244 :module => M,
245245 )
246246 DSE. format (DSE. TYPEDSIGNATURES, buf, doc)
293293
294294 doc. data = Dict (
295295 :binding => Docs. Binding (M, :k_1 ),
296- :typesig => Union{Tuple{String}, Tuple{String, T}, Tuple{String, T, T}, Tuple{T}} where T <: Number ,
296+ :typesig => Union{Tuple{String},Tuple{String,T},Tuple{String,T, T},Tuple{T}} where T<: Number ,
297297 :module => M,
298298 )
299299 DSE. format (DSE. TYPEDSIGNATURES, buf, doc)
306306
307307 doc. data = Dict (
308308 :binding => Docs. Binding (M, :k_2 ),
309- :typesig => (Union{Tuple{String, U, T}, Tuple{T}, Tuple{U}} where T <: Number ) where U <: Complex ,
309+ :typesig => (Union{Tuple{String,U, T},Tuple{T},Tuple{U}} where T<: Number ) where U<: Complex ,
310310 :module => M,
311311 )
312312
318318
319319 doc. data = Dict (
320320 :binding => Docs. Binding (M, :k_3 ),
321- :typesig => (Union{Tuple{Any, T, U}, Tuple{U}, Tuple{T}} where U <: Any ) where T <: Any ,
321+ :typesig => (Union{Tuple{Any,T, U},Tuple{U},Tuple{T}} where U<: Any ) where T<: Any ,
322322 :module => M,
323323 )
324324 DSE. format (DSE. TYPEDSIGNATURES, buf, doc)
329329
330330 doc. data = Dict (
331331 :binding => Docs. Binding (M, :k_4 ),
332- :typesig => Union{Tuple{String}, Tuple{String, Int}},
332+ :typesig => Union{Tuple{String},Tuple{String,Int}},
333333 :module => M,
334334 )
335335 DSE. format (DSE. TYPEDSIGNATURES, buf, doc)
352352
353353 doc. data = Dict (
354354 :binding => Docs. Binding (M, :k_5 ),
355- :typesig => Union{Tuple{Type{T}, String}, Tuple{Type{T}, String, Union{Nothing, Function}}, Tuple{T}} where T <: Number ,
355+ :typesig => Union{Tuple{Type{T},String},Tuple{Type{T},String,Union{Nothing,Function}},Tuple{T}} where T<: Number ,
356356 :module => M,
357357 )
358358 DSE. format (DSE. TYPEDSIGNATURES, buf, doc)
371371
372372 doc. data = Dict (
373373 :binding => Docs. Binding (M, :k_6 ),
374- :typesig => Union{Tuple{Vector{T}}, Tuple{T}} where T <: Number ,
374+ :typesig => Union{Tuple{Vector{T}},Tuple{T}} where T<: Number ,
375375 :module => M,
376376 )
377377 DSE. format (DSE. TYPEDSIGNATURES, buf, doc)
389389
390390 doc. data = Dict (
391391 :binding => Docs. Binding (M, :k_7 ),
392- :typesig => Union{Tuple{Union{Nothing, T}}, Tuple{T}, Tuple{Union{Nothing, T}, T}} where T<: Integer ,
392+ :typesig => Union{Tuple{Union{Nothing,T}},Tuple{T},Tuple{Union{Nothing,T},T}} where T<: Integer ,
393393 :module => M,
394394 )
395395 DSE. format (DSE. TYPEDSIGNATURES, buf, doc)
430430
431431 doc. data = Dict (
432432 :binding => Docs. Binding (M, :k_11 ),
433- :typesig => Union{Tuple{Int, Vararg{Any}}},
433+ :typesig => Union{Tuple{Int,Vararg{Any}}},
434434 :module => M,
435435 )
436436 DSE. format (DSE. TYPEDSIGNATURES, buf, doc)
441441
442442 doc. data = Dict (
443443 :binding => Docs. Binding (M, :k_12 ),
444- :typesig => Union{Tuple{Int, Vararg{Real}}},
444+ :typesig => Union{Tuple{Int,Vararg{Real}}},
445445 :module => M,
446446 )
447447 DSE. format (DSE. TYPEDSIGNATURES, buf, doc)
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+ end
477+
458478 @testset " function names" begin
459479 doc. data = Dict (
460480 :binding => Docs. Binding (M, :f ),
@@ -559,22 +579,27 @@ end
559579 @test DSE. keywords (M. f, first (methods (M. f))) == Symbol[]
560580 let f = (() -> ()),
561581 m = first (methods (f))
582+
562583 @test DSE. keywords (f, m) == Symbol[]
563584 end
564585 let f = ((a) -> ()),
565586 m = first (methods (f))
587+
566588 @test DSE. keywords (f, m) == Symbol[]
567589 end
568- let f = ((; a = 1 ) -> ()),
590+ let f = ((; a= 1 ) -> ()),
569591 m = first (methods (f))
592+
570593 @test DSE. keywords (f, m) == [:a ]
571594 end
572- let f = ((; a = 1 , b = 2 ) -> ()),
595+ let f = ((; a= 1 , b= 2 ) -> ()),
573596 m = first (methods (f))
597+
574598 @test DSE. keywords (f, m) == [:a , :b ]
575599 end
576600 let f = ((; a... ) -> ()),
577601 m = first (methods (f))
602+
578603 @test DSE. keywords (f, m) == [Symbol (" a..." )]
579604 end
580605 # Tests for #42
@@ -601,10 +626,10 @@ end
601626 let m = first (methods ((a) -> ()))
602627 @test DSE. arguments (m) == [:a ]
603628 end
604- let m = first (methods ((; a = 1 ) -> ()))
629+ let m = first (methods ((; a= 1 ) -> ()))
605630 @test DSE. arguments (m) == Symbol[]
606631 end
607- let m = first (methods ((x; a = 1 , b = 2 ) -> ()))
632+ let m = first (methods ((x; a= 1 , b= 2 ) -> ()))
608633 @test DSE. arguments (m) == Symbol[:x ]
609634 end
610635 let m = first (methods ((; a... ) -> ()))
@@ -615,46 +640,53 @@ end
615640 let b = Docs. Binding (M, :T ),
616641 f = M. T,
617642 m = first (methods (f))
643+
618644 @test DSE. printmethod (b, f, m) == " T(a, b, c)"
619645 end
620646 let b = Docs. Binding (M, :K ),
621647 f = M. K,
622648 m = first (methods (f))
649+
623650 @test DSE. printmethod (b, f, m) == " K(; a)"
624651 end
625652 let b = Docs. Binding (M, :f ),
626653 f = M. f,
627654 m = first (methods (f))
655+
628656 @test DSE. printmethod (b, f, m) == " f(x)"
629657 end
630658 let b = Docs. Binding (Main, :f ),
631659 f = () -> (),
632660 m = first (methods (f))
661+
633662 @test DSE. printmethod (b, f, m) == " f()"
634663 end
635664 let b = Docs. Binding (Main, :f ),
636665 f = (a) -> (),
637666 m = first (methods (f))
667+
638668 @test DSE. printmethod (b, f, m) == " f(a)"
639669 end
640670 let b = Docs. Binding (Main, :f ),
641- f = (; a = 1 ) -> (),
671+ f = (; a= 1 ) -> (),
642672 m = first (methods (f))
673+
643674 @test DSE. printmethod (b, f, m) == " f(; a)"
644675 end
645676 let b = Docs. Binding (Main, :f ),
646- f = (; a = 1 , b = 2 ) -> (),
677+ f = (; a= 1 , b= 2 ) -> (),
647678 m = first (methods (f))
648679 # Keywords are not ordered, so check for both combinations.
649680 @test DSE. printmethod (b, f, m) in (" f(; a, b)" , " f(; b, a)" )
650681 end
651682 let b = Docs. Binding (Main, :f ),
652683 f = (; a... ) -> (),
653684 m = first (methods (f))
685+
654686 @test DSE. printmethod (b, f, m) == " f(; a...)"
655687 end
656688 let b = Docs. Binding (Main, :f ),
657- f = (; a = 1 , b = 2 , c... ) -> (),
689+ f = (; a= 1 , b= 2 , c... ) -> (),
658690 m = first (methods (f))
659691 # Keywords are not ordered, so check for both combinations.
660692 @test DSE. printmethod (b, f, m) in (" f(; a, b, c...)" , " f(; b, a, c...)" )
@@ -663,10 +695,10 @@ end
663695 @testset " getmethods" begin
664696 @test length (DSE. getmethods (M. f, Union{})) == 1
665697 @test length (DSE. getmethods (M. f, Tuple{})) == 0
666- @test length (DSE. getmethods (M. f, Union{Tuple{}, Tuple{Any}})) == 1
698+ @test length (DSE. getmethods (M. f, Union{Tuple{},Tuple{Any}})) == 1
667699 @test length (DSE. getmethods (M. h_3, Tuple{M. A{Int}})) == 1
668- @test length (DSE. getmethods (M. h_3, Tuple{Array{Int, 3 }})) == 1
669- @test length (DSE. getmethods (M. h_3, Tuple{Array{Int, 1 }})) == 0
700+ @test length (DSE. getmethods (M. h_3, Tuple{Array{Int,3 }})) == 1
701+ @test length (DSE. getmethods (M. h_3, Tuple{Array{Int,1 }})) == 0
670702 end
671703 @testset " methodgroups" begin
672704 @test length (DSE. methodgroups (M. f, Tuple{Any}, M)) == 1
@@ -687,10 +719,10 @@ end
687719 let groups = DSE. groupby (Int, Vector{Int}, collect (1 : 10 )) do each
688720 mod (each, 3 ), each
689721 end
690- @test groups == Pair{Int, Vector{Int}}[
691- 0 => [3 , 6 , 9 ],
692- 1 => [1 , 4 , 7 , 10 ],
693- 2 => [2 , 5 , 8 ],
722+ @test groups == Pair{Int,Vector{Int}}[
723+ 0 => [3 , 6 , 9 ],
724+ 1 => [1 , 4 , 7 , 10 ],
725+ 2 => [2 , 5 , 8 ],
694726 ]
695727 end
696728 end
711743 @testset " comparemethods" begin
712744 let f = first (methods (M. f)),
713745 g = first (methods (M. g))
746+
714747 @test ! DSE. comparemethods (f, f)
715748 @test DSE. comparemethods (f, g)
716749 @test ! DSE. comparemethods (g, f)
0 commit comments