Skip to content

Commit a91c808

Browse files
committed
test: use ReferenceTests
1 parent 8f1797d commit a91c808

File tree

8 files changed

+33
-44
lines changed

8 files changed

+33
-44
lines changed

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ julia = "1"
99
LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433"
1010
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
1111
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
12+
ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf"
1213
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
1314
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1415

1516
[targets]
16-
test = ["LibGit2", "Markdown", "Pkg", "REPL", "Test"]
17+
test = ["LibGit2", "Markdown", "Pkg", "REPL", "ReferenceTests", "Test"]

src/abbreviations.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,8 @@ const TYPEDSIGNATURES = TypedMethodSignatures(true)
365365
"""
366366
An alternative to [`TYPEDSIGNATURES`](@ref) that omits the return type.
367367
368-
The return type shown by [`TYPEDSIGNATURES`](@ref) is often `-> Any`, which is usually not
369-
correct. It is nicer to then just omit the type completely.
368+
The return type shown by [`TYPEDSIGNATURES`](@ref) is often `-> Any`, which is often not
369+
informative. It is nicer to then just omit the type completely.
370370
"""
371371
const TYPEDSIGNATURESNORETURN = TypedMethodSignatures(false)
372372

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
```julia
3+
g_2(x::String)
4+
5+
```
6+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
```julia
3+
h_1(x::Union{Array{T, 3}, Array{T, 4}} where T)
4+
5+
```
6+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
```julia
3+
h(x::Int64; ...)
4+
5+
```
6+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
```julia
3+
h(x::Int64, y::Int64, z::Int64; kwargs...)
4+
5+
```
6+

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ using Test
33
import Markdown
44
import LibGit2
55
import REPL
6+
import ReferenceTests: @test_reference
67

78
include("tests.jl")

test/tests.jl

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -463,17 +463,7 @@ end
463463
)
464464
DSE.format(DSE.TYPEDSIGNATURESNORETURN, buf, doc)
465465
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-
466+
@test_reference "references/typed_no_return/h_1.txt" str
477467

478468
doc.data = Dict(
479469
:binding => Docs.Binding(M, :g_2),
@@ -482,9 +472,7 @@ end
482472
)
483473
DSE.format(TYPEDSIGNATURESNORETURN, buf, doc)
484474
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)
475+
@test_reference "references/typed_no_return/g_2.txt" str
488476

489477
doc.data = Dict(
490478
:binding => Docs.Binding(M, :h),
@@ -493,13 +481,7 @@ end
493481
)
494482
DSE.format(DSE.TYPEDSIGNATURESNORETURN, buf, doc)
495483
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)
484+
@test_reference "references/typed_no_return/h_int_int_int.txt" str
503485

504486
doc.data = Dict(
505487
:binding => Docs.Binding(M, :h),
@@ -508,26 +490,7 @@ end
508490
)
509491
DSE.format(DSE.TYPEDSIGNATURESNORETURN, buf, doc)
510492
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-
493+
@test_reference "references/typed_no_return/h_int.txt" str
531494
end
532495

533496
@testset "function names" begin

0 commit comments

Comments
 (0)