From 25c41662894d9cefe19ccb2e3c7cb7b3375120be Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Sun, 14 Jan 2024 18:00:41 -0500 Subject: [PATCH] add tests for undocumented symbols (#52723) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Following #52413 by @jariji and the discussion in #51174, this adds tests to ensure that there are no undocumented *(= lacking docstrings)* public symbols in any documented module. Many of the tests are broken — we have a lot of undocumented exports. In such cases I added both a `@test_broken` and a `@test` to ensure that there are no additional regressions added in the future. ~~(This PR may have to be updated when https://github.com/JuliaLang/julia/pull/52413#discussion_r1441068405 is fixed, i.e. when ~~#52727~~ #52743 is merged.)~~ Has been updated. --------- Co-authored-by: Lilith Orion Hafner --- base/docs/Docs.jl | 28 +++++++++++++++++++++++- base/libc.jl | 5 +++++ stdlib/Artifacts/test/runtests.jl | 6 +++++ stdlib/Base64/test/runtests.jl | 7 +++++- stdlib/CRC32c/test/runtests.jl | 4 ++++ stdlib/Dates/test/runtests.jl | 8 +++++++ stdlib/FileWatching/test/runtests.jl | 6 +++++ stdlib/Future/test/runtests.jl | 4 ++++ stdlib/InteractiveUtils/test/runtests.jl | 6 +++++ stdlib/LibGit2/test/runtests.jl | 7 +++++- stdlib/Libdl/test/runtests.jl | 6 +++++ stdlib/LinearAlgebra/test/runtests.jl | 7 ++++++ stdlib/Logging/test/runtests.jl | 6 +++++ stdlib/Markdown/test/runtests.jl | 4 ++++ stdlib/Mmap/test/runtests.jl | 4 ++++ stdlib/Printf/test/runtests.jl | 6 +++++ stdlib/Profile/test/runtests.jl | 6 +++++ stdlib/REPL/src/docview.jl | 20 ----------------- stdlib/REPL/test/repl.jl | 6 +++++ stdlib/Random/test/runtests.jl | 4 ++++ stdlib/Serialization/test/runtests.jl | 6 +++++ stdlib/SharedArrays/test/runtests.jl | 4 ++++ stdlib/Sockets/test/runtests.jl | 4 ++++ stdlib/TOML/test/runtests.jl | 6 +++++ stdlib/Test/test/runtests.jl | 4 ++++ stdlib/UUIDs/test/runtests.jl | 4 ++++ stdlib/Unicode/test/runtests.jl | 4 ++++ test/broadcast.jl | 6 +++++ test/checked.jl | 4 ++++ test/docs.jl | 6 +++++ test/filesystem.jl | 6 +++++ test/gc.jl | 4 ++++ test/iterators.jl | 4 ++++ test/math.jl | 4 ++++ test/meta.jl | 4 ++++ test/misc.jl | 10 +++++++++ test/ordering.jl | 6 +++++ test/sorting.jl | 6 +++++ test/stacktraces.jl | 4 ++++ test/sysinfo.jl | 6 +++++ test/threads.jl | 4 ++++ 41 files changed, 233 insertions(+), 23 deletions(-) diff --git a/base/docs/Docs.jl b/base/docs/Docs.jl index e5974d3280308..95724dc97bb73 100644 --- a/base/docs/Docs.jl +++ b/base/docs/Docs.jl @@ -650,11 +650,37 @@ function loaddocs(docs::Vector{Core.SimpleVector}) nothing end +# FIXME: formatdoc, parsedoc, apropos, and doc are defined here (but only doc is exported) +# for historical reasons (#25738), but are *implemented* in REPL/src/docview.jl, while +# apropos is *exported* by InteractiveUtils and doc is exported by Docs. Seems +# like a more sensible refactoring should be possible. + function formatdoc end function parsedoc end + +""" + apropos([io::IO=stdout], pattern::Union{AbstractString,Regex}) + +Search available docstrings for entries containing `pattern`. + +When `pattern` is a string, case is ignored. Results are printed to `io`. + +`apropos` can be called from the help mode in the REPL by wrapping the query in double quotes: +``` +help?> "pattern" +``` +""" function apropos end -function doc end +""" + Docs.doc(binding, sig) + +Return all documentation that matches both `binding` and `sig`. + +If `getdoc` returns a non-`nothing` result on the value of the binding, then a +dynamic docstring is returned instead of one based on the binding itself. +""" +function doc end """ Docs.hasdoc(mod::Module, sym::Symbol)::Bool diff --git a/base/libc.jl b/base/libc.jl index 1fcf763e4e124..359ca6a7f8c31 100644 --- a/base/libc.jl +++ b/base/libc.jl @@ -45,6 +45,11 @@ show(io::IO, fd::RawFD) = print(io, "RawFD(", bitcast(UInt32, fd), ')') # avoid # Wrapper for an OS file descriptor (for Windows) if Sys.iswindows() + @doc """ + WindowsRawSocket + + Primitive type which wraps the native Windows file `HANDLE`. + """ primitive type WindowsRawSocket sizeof(Ptr) * 8 end # On Windows file descriptors are HANDLE's and 64-bit on 64-bit Windows WindowsRawSocket(handle::Ptr{Cvoid}) = bitcast(WindowsRawSocket, handle) WindowsRawSocket(handle::WindowsRawSocket) = handle diff --git a/stdlib/Artifacts/test/runtests.jl b/stdlib/Artifacts/test/runtests.jl index db0d5d4c53ab1..2255930baf8e4 100644 --- a/stdlib/Artifacts/test/runtests.jl +++ b/stdlib/Artifacts/test/runtests.jl @@ -261,3 +261,9 @@ end @test length(Base.manifest_names) == 2n # there are two manifest names per project name @test length(Base.preferences_names) == n end + +@testset "Docstrings" begin + undoc = Docs.undocumented_names(Artifacts) + @test_broken isempty(undoc) + @test undoc == [:Artifacts] +end diff --git a/stdlib/Base64/test/runtests.jl b/stdlib/Base64/test/runtests.jl index 11d0a3cca4348..145576f6ea3f4 100644 --- a/stdlib/Base64/test/runtests.jl +++ b/stdlib/Base64/test/runtests.jl @@ -1,7 +1,8 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license using Test, Random -import Base64: +using Base64: + Base64, Base64EncodePipe, base64encode, Base64DecodePipe, @@ -142,3 +143,7 @@ end @test String(base64decode(splace(longEncodedText))) == longDecodedText end end + +@testset "Docstrings" begin + @test isempty(Docs.undocumented_names(Base64)) +end diff --git a/stdlib/CRC32c/test/runtests.jl b/stdlib/CRC32c/test/runtests.jl index 41a7ea2ab62fa..e1bd75d0e15f6 100644 --- a/stdlib/CRC32c/test/runtests.jl +++ b/stdlib/CRC32c/test/runtests.jl @@ -77,3 +77,7 @@ end crc32c_sw(io::IO, crc::UInt32=0x00000000) = crc32c_sw(io, typemax(Int64), crc) test_crc32c(crc32c) test_crc32c(crc32c_sw) + +@testset "Docstrings" begin + @test isempty(Docs.undocumented_names(CRC32c)) +end diff --git a/stdlib/Dates/test/runtests.jl b/stdlib/Dates/test/runtests.jl index de063135427a9..7ac46bd69139c 100644 --- a/stdlib/Dates/test/runtests.jl +++ b/stdlib/Dates/test/runtests.jl @@ -2,8 +2,16 @@ module DateTests +using Test, Dates + for file in readlines(joinpath(@__DIR__, "testgroups")) include(file * ".jl") end +@testset "Docstrings" begin + undoc = Docs.undocumented_names(Dates) + @test_broken isempty(undoc) + @test undoc == [:adjust] +end + end diff --git a/stdlib/FileWatching/test/runtests.jl b/stdlib/FileWatching/test/runtests.jl index 75b17b5f0e511..a02ed3931a349 100644 --- a/stdlib/FileWatching/test/runtests.jl +++ b/stdlib/FileWatching/test/runtests.jl @@ -447,4 +447,10 @@ rm(dir) include("pidfile.jl") end +@testset "Docstrings" begin + undoc = Docs.undocumented_names(FileWatching) + @test_broken isempty(undoc) + @test undoc == [:FDWatcher, :FileMonitor, :FolderMonitor, :PollingFileWatcher] +end + end # testset diff --git a/stdlib/Future/test/runtests.jl b/stdlib/Future/test/runtests.jl index 6deffe74d891c..6e02f17358ab3 100644 --- a/stdlib/Future/test/runtests.jl +++ b/stdlib/Future/test/runtests.jl @@ -2,3 +2,7 @@ using Test using Future + +@testset "Docstrings" begin + @test isempty(Docs.undocumented_names(Future)) +end diff --git a/stdlib/InteractiveUtils/test/runtests.jl b/stdlib/InteractiveUtils/test/runtests.jl index 795f267ff4520..cb0621516189a 100644 --- a/stdlib/InteractiveUtils/test/runtests.jl +++ b/stdlib/InteractiveUtils/test/runtests.jl @@ -724,3 +724,9 @@ end end @test Base.infer_effects(sin, (Int,)) == InteractiveUtils.@infer_effects sin(42) + +@testset "Docstrings" begin + undoc = Docs.undocumented_names(InteractiveUtils) + @test_broken isempty(undoc) + @test undoc == [:InteractiveUtils] +end diff --git a/stdlib/LibGit2/test/runtests.jl b/stdlib/LibGit2/test/runtests.jl index 88aea77f25671..4d2f4f9104c4e 100644 --- a/stdlib/LibGit2/test/runtests.jl +++ b/stdlib/LibGit2/test/runtests.jl @@ -1,6 +1,11 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Test +using Test, LibGit2 + @testset verbose=true "LibGit2 $test" for test in eachline(joinpath(@__DIR__, "testgroups")) include("$test.jl") end + +@testset "Docstrings" begin + @test isempty(Docs.undocumented_names(LibGit2)) +end diff --git a/stdlib/Libdl/test/runtests.jl b/stdlib/Libdl/test/runtests.jl index e500b68dec34b..cbff36c870fe7 100644 --- a/stdlib/Libdl/test/runtests.jl +++ b/stdlib/Libdl/test/runtests.jl @@ -329,3 +329,9 @@ end lazy_name_lazy_lib = LazyLibrary(libname) @test dlpath(lazy_name_lazy_lib) == realpath(string(libname)) end; end + +@testset "Docstrings" begin + undoc = Docs.undocumented_names(Libdl) + @test_broken isempty(undoc) + @test undoc == [:Libdl] +end diff --git a/stdlib/LinearAlgebra/test/runtests.jl b/stdlib/LinearAlgebra/test/runtests.jl index 29581313c18d5..55bc119756ce8 100644 --- a/stdlib/LinearAlgebra/test/runtests.jl +++ b/stdlib/LinearAlgebra/test/runtests.jl @@ -1,5 +1,12 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license +using Test, LinearAlgebra for file in readlines(joinpath(@__DIR__, "testgroups")) include(file * ".jl") end + +@testset "Docstrings" begin + undoc = Docs.undocumented_names(LinearAlgebra) + @test_broken isempty(undoc) + @test undoc == [:ColumnNorm, :LAPACKException, :NoPivot, :RankDeficientException, :RowMaximum, :RowNonZero, :copy_transpose!] +end diff --git a/stdlib/Logging/test/runtests.jl b/stdlib/Logging/test/runtests.jl index e7b3fbca2098d..e0fc6a0bc3770 100644 --- a/stdlib/Logging/test/runtests.jl +++ b/stdlib/Logging/test/runtests.jl @@ -300,4 +300,10 @@ end @test occursin("CustomLog2: hello", String(take!(buf))) end +@testset "Docstrings" begin + undoc = Docs.undocumented_names(Logging) + @test_broken isempty(undoc) + @test undoc == [:AboveMaxLevel, :BelowMinLevel] +end + end diff --git a/stdlib/Markdown/test/runtests.jl b/stdlib/Markdown/test/runtests.jl index 84f0868747567..116282a0bea3b 100644 --- a/stdlib/Markdown/test/runtests.jl +++ b/stdlib/Markdown/test/runtests.jl @@ -1293,3 +1293,7 @@ end # see issue #42139 @test md"<一轮红日初升>" |> html == """

<一轮红日初升>

\n""" end + +@testset "Docstrings" begin + @test isempty(Docs.undocumented_names(Markdown)) +end diff --git a/stdlib/Mmap/test/runtests.jl b/stdlib/Mmap/test/runtests.jl index 0b3cb0b9f1a42..ebd16a45ba0ed 100644 --- a/stdlib/Mmap/test/runtests.jl +++ b/stdlib/Mmap/test/runtests.jl @@ -339,3 +339,7 @@ open(file, "r+") do s finalize(A); A = nothing; GC.gc() end rm(file) + +@testset "Docstrings" begin + @test isempty(Docs.undocumented_names(Mmap)) +end diff --git a/stdlib/Printf/test/runtests.jl b/stdlib/Printf/test/runtests.jl index 71ec369af4ef7..a80affff37d11 100644 --- a/stdlib/Printf/test/runtests.jl +++ b/stdlib/Printf/test/runtests.jl @@ -1145,6 +1145,12 @@ end @test_throws Printf.InvalidFormatStringError Printf.Format("%z") end +@testset "Docstrings" begin + undoc = Docs.undocumented_names(Printf) + @test_broken isempty(undoc) + @test undoc == [:Printf] +end + # issue #52749 @test @sprintf("%.160g", 1.38e-23) == "1.380000000000000060010582465734078799297660966782642624395399644741944111814291318296454846858978271484375e-23" diff --git a/stdlib/Profile/test/runtests.jl b/stdlib/Profile/test/runtests.jl index d7358dc20e853..169e70bfa7f36 100644 --- a/stdlib/Profile/test/runtests.jl +++ b/stdlib/Profile/test/runtests.jl @@ -300,3 +300,9 @@ end end include("allocs.jl") + +@testset "Docstrings" begin + undoc = Docs.undocumented_names(Profile) + @test_broken isempty(undoc) + @test undoc == [:Allocs] +end diff --git a/stdlib/REPL/src/docview.jl b/stdlib/REPL/src/docview.jl index 41f3020447090..1d5bd12cdda58 100644 --- a/stdlib/REPL/src/docview.jl +++ b/stdlib/REPL/src/docview.jl @@ -198,14 +198,6 @@ function insert_internal_warning(other, internal_access::Set{Pair{Module,Symbol} other end -""" - Docs.doc(binding, sig) - -Return all documentation that matches both `binding` and `sig`. - -If `getdoc` returns a non-`nothing` result on the value of the binding, then a -dynamic docstring is returned instead of one based on the binding itself. -""" function doc(binding::Binding, sig::Type = Union{}) if defined(binding) result = getdoc(resolve(binding), sig) @@ -920,18 +912,6 @@ stripmd(x::Markdown.Footnote) = "$(stripmd(x.id)) $(stripmd(x.text))" stripmd(x::Markdown.Table) = join([join(map(stripmd, r), " ") for r in x.rows], " ") -""" - apropos([io::IO=stdout], pattern::Union{AbstractString,Regex}) - -Search available docstrings for entries containing `pattern`. - -When `pattern` is a string, case is ignored. Results are printed to `io`. - -`apropos` can be called from the help mode in the REPL by wrapping the query in double quotes: -``` -help?> "pattern" -``` -""" apropos(string) = apropos(stdout, string) apropos(io::IO, string) = apropos(io, Regex("\\Q$string", "i")) diff --git a/stdlib/REPL/test/repl.jl b/stdlib/REPL/test/repl.jl index 7896b589612e3..f16ac0e07689a 100644 --- a/stdlib/REPL/test/repl.jl +++ b/stdlib/REPL/test/repl.jl @@ -1749,3 +1749,9 @@ let io = IOBuffer() seek(io, 0) @test countlines(io) == 2 end + +@testset "Docstrings" begin + undoc = Docs.undocumented_names(REPL) + @test_broken isempty(undoc) + @test undoc == [:AbstractREPL, :BasicREPL, :LineEditREPL, :StreamREPL] +end diff --git a/stdlib/Random/test/runtests.jl b/stdlib/Random/test/runtests.jl index 61cee5c952c51..16a2f89753f3b 100644 --- a/stdlib/Random/test/runtests.jl +++ b/stdlib/Random/test/runtests.jl @@ -1232,3 +1232,7 @@ end @test xs isa Vector{Pair{Bool, Char}} @test length(xs) == 3 end + +@testset "Docstrings" begin + @test isempty(Docs.undocumented_names(Random)) +end diff --git a/stdlib/Serialization/test/runtests.jl b/stdlib/Serialization/test/runtests.jl index 46749d4375538..a7d5023e1ec51 100644 --- a/stdlib/Serialization/test/runtests.jl +++ b/stdlib/Serialization/test/runtests.jl @@ -655,3 +655,9 @@ end @test l2 == l1 @test l2.parts === () end + +@testset "Docstrings" begin + undoc = Docs.undocumented_names(Serialization) + @test_broken isempty(undoc) + @test undoc == [:AbstractSerializer, :Serializer] +end diff --git a/stdlib/SharedArrays/test/runtests.jl b/stdlib/SharedArrays/test/runtests.jl index 7f1bbb6891ce0..84dffafb3d92a 100644 --- a/stdlib/SharedArrays/test/runtests.jl +++ b/stdlib/SharedArrays/test/runtests.jl @@ -324,3 +324,7 @@ end @test SharedMatrix([0.1 0.2; 0.3 0.4]) == [0.1 0.2; 0.3 0.4] @test_throws MethodError SharedVector(rand(4,4)) @test_throws MethodError SharedMatrix(rand(4)) + +@testset "Docstrings" begin + @test isempty(Docs.undocumented_names(SharedArrays)) +end diff --git a/stdlib/Sockets/test/runtests.jl b/stdlib/Sockets/test/runtests.jl index 02a994460afbf..2a812388d8373 100644 --- a/stdlib/Sockets/test/runtests.jl +++ b/stdlib/Sockets/test/runtests.jl @@ -682,3 +682,7 @@ end close(sockets_watchdog_timer) + +@testset "Docstrings" begin + @test isempty(Docs.undocumented_names(Sockets)) +end diff --git a/stdlib/TOML/test/runtests.jl b/stdlib/TOML/test/runtests.jl index 7376fab914636..e471068f36e7f 100644 --- a/stdlib/TOML/test/runtests.jl +++ b/stdlib/TOML/test/runtests.jl @@ -25,3 +25,9 @@ include("print.jl") include("parse.jl") @inferred TOML.parse("foo = 3") + +@testset "Docstrings" begin + undoc = Docs.undocumented_names(TOML) + @test_broken isempty(undoc) + @test undoc == [:TOML] +end diff --git a/stdlib/Test/test/runtests.jl b/stdlib/Test/test/runtests.jl index 1f93db2b5ed72..4f1077835c632 100644 --- a/stdlib/Test/test/runtests.jl +++ b/stdlib/Test/test/runtests.jl @@ -1582,3 +1582,7 @@ let end end end + +@testset "Docstrings" begin + @test isempty(Docs.undocumented_names(Test)) +end diff --git a/stdlib/UUIDs/test/runtests.jl b/stdlib/UUIDs/test/runtests.jl index 1770b24b3abae..d2b9ee17f2e38 100644 --- a/stdlib/UUIDs/test/runtests.jl +++ b/stdlib/UUIDs/test/runtests.jl @@ -73,3 +73,7 @@ str = "22b4a8a1-e548-4eeb-9270-60426d66a48e" for r in rand(UInt128, 10^3) @test UUID(r) == UUID(string(UUID(r))) end + +@testset "Docstrings" begin + @test isempty(Docs.undocumented_names(UUIDs)) +end diff --git a/stdlib/Unicode/test/runtests.jl b/stdlib/Unicode/test/runtests.jl index 2ee7b88ae966b..7fa57508cffbf 100644 --- a/stdlib/Unicode/test/runtests.jl +++ b/stdlib/Unicode/test/runtests.jl @@ -534,3 +534,7 @@ isequal_normalized_naive(s1, s2; kws...) = normalize(s1; kws...) == normalize(s2 @test !isequal_normalized("x\u0334\u0335", "x\u0335\u0334") end end + +@testset "Docstrings" begin + @test isempty(Docs.undocumented_names(Unicode)) +end diff --git a/test/broadcast.jl b/test/broadcast.jl index 1e5752921bc93..2ae3d96b2a709 100644 --- a/test/broadcast.jl +++ b/test/broadcast.jl @@ -1176,6 +1176,12 @@ import Base.Broadcast: BroadcastStyle, DefaultArrayStyle f51129(v, x) = (1 .- (v ./ x) .^ 2) @test @inferred(f51129([13.0], 6.5)) == [-3.0] +@testset "Docstrings" begin + undoc = Docs.undocumented_names(Broadcast) + @test_broken isempty(undoc) + @test undoc == [:dotview] +end + @testset "broadcast for `AbstractArray` without `CartesianIndex` support" begin struct BVec52775 <: AbstractVector{Int} a::Vector{Int} diff --git a/test/checked.jl b/test/checked.jl index bacda3db75dec..bbc53ddb55ed2 100644 --- a/test/checked.jl +++ b/test/checked.jl @@ -358,3 +358,7 @@ end @test checked_mul(1, 2, 3, 4, 5, 6, 7) === 5040 @test checked_mul(1, 2, 3, 4, 5, 6, 7, 8) === 40320 end + +@testset "Docstrings" begin + @test isempty(Docs.undocumented_names(Base.Checked)) +end diff --git a/test/docs.jl b/test/docs.jl index 190bcaee6adf5..4eab0dd36361d 100644 --- a/test/docs.jl +++ b/test/docs.jl @@ -1556,3 +1556,9 @@ Base.@ccallable c51586_long()::Int = 3 @test docstrings_equal(@doc(c51586_short()), doc"ensure we can document ccallable functions") @test docstrings_equal(@doc(c51586_long()), doc"ensure we can document ccallable functions") + +@testset "Docs docstrings" begin + undoc = Docs.undocumented_names(Docs) + @test_broken isempty(undoc) + @test undoc == [Symbol("@var")] +end diff --git a/test/filesystem.jl b/test/filesystem.jl index 79beea9f66ac1..c9bab69c586b3 100644 --- a/test/filesystem.jl +++ b/test/filesystem.jl @@ -40,3 +40,9 @@ import Base.Filesystem: S_IRUSR, S_IRGRP, S_IROTH @test S_IRUSR & ~S_IRGRP == S_IRUSR @test typeof(S_IRUSR) == typeof(S_IRGRP) == typeof(S_IROTH) end + +@testset "Base.Filesystem docstrings" begin + undoc = Docs.undocumented_names(Base.Filesystem) + @test_broken isempty(undoc) + @test undoc == [:File, :Filesystem, :JL_O_APPEND, :JL_O_ASYNC, :JL_O_CLOEXEC, :JL_O_CREAT, :JL_O_DIRECT, :JL_O_DIRECTORY, :JL_O_DSYNC, :JL_O_EXCL, :JL_O_FSYNC, :JL_O_LARGEFILE, :JL_O_NDELAY, :JL_O_NOATIME, :JL_O_NOCTTY, :JL_O_NOFOLLOW, :JL_O_NONBLOCK, :JL_O_PATH, :JL_O_RANDOM, :JL_O_RDONLY, :JL_O_RDWR, :JL_O_RSYNC, :JL_O_SEQUENTIAL, :JL_O_SHORT_LIVED, :JL_O_SYNC, :JL_O_TEMPORARY, :JL_O_TMPFILE, :JL_O_TRUNC, :JL_O_WRONLY, :S_IRGRP, :S_IROTH, :S_IRUSR, :S_IRWXG, :S_IRWXO, :S_IRWXU, :S_IWGRP, :S_IWOTH, :S_IWUSR, :S_IXGRP, :S_IXOTH, :S_IXUSR, :cptree, :futime, :rename, :sendfile, :unlink] +end diff --git a/test/gc.jl b/test/gc.jl index 99b96a5ae1fd2..d5990582cc00a 100644 --- a/test/gc.jl +++ b/test/gc.jl @@ -33,3 +33,7 @@ end run_gctest("gc/chunks.jl") run_nonzero_page_utilization_test() end + +@testset "Base.GC docstrings" begin + @test isempty(Docs.undocumented_names(GC)) +end diff --git a/test/iterators.jl b/test/iterators.jl index 46e7c8b454335..74d7d61f0a496 100644 --- a/test/iterators.jl +++ b/test/iterators.jl @@ -1009,3 +1009,7 @@ end @testset "collect partition substring" begin @test collect(Iterators.partition(lstrip("01111", '0'), 2)) == ["11", "11"] end + +@testset "Iterators docstrings" begin + @test isempty(Docs.undocumented_names(Iterators)) +end diff --git a/test/math.jl b/test/math.jl index 248f99cebd987..f3c6dc5bb103f 100644 --- a/test/math.jl +++ b/test/math.jl @@ -1599,3 +1599,7 @@ end === Float64 @test tanpi(big(1//1)) == big(0.0) @test cospi(big(1//1)) == big(-1.0) end + +@testset "Docstrings" begin + @test isempty(Docs.undocumented_names(MathConstants)) +end diff --git a/test/meta.jl b/test/meta.jl index be0ecf0cdb827..5fb1ebc0d3647 100644 --- a/test/meta.jl +++ b/test/meta.jl @@ -277,3 +277,7 @@ ci = code_lowered(g, Tuple{Val{true}})[1] [], 0, 0, :propagate)[1] == Expr(:isdefined, GlobalRef(Base, :foo)) end + +@testset "Base.Meta docstrings" begin + @test isempty(Docs.undocumented_names(Meta)) +end diff --git a/test/misc.jl b/test/misc.jl index caa4a5fb599bf..03cf59acb59a3 100644 --- a/test/misc.jl +++ b/test/misc.jl @@ -1407,3 +1407,13 @@ end GC.gc(true); yield() @test in_fin[] end + +@testset "Base docstrings" begin + undoc = Docs.undocumented_names(Base) + @test_broken isempty(undoc) + @test undoc == [:BufferStream, :CanonicalIndexError, :CapturedException, :Filesystem, :IOServer, :InvalidStateException, :Order, :PipeEndpoint, :Sort, :TTY] +end + +@testset "Base.Libc docstrings" begin + @test isempty(Docs.undocumented_names(Libc)) +end diff --git a/test/ordering.jl b/test/ordering.jl index 972d48c17b1af..3b5385b99be68 100644 --- a/test/ordering.jl +++ b/test/ordering.jl @@ -51,3 +51,9 @@ struct SomeOtherOrder <: Base.Order.Ordering end @test ord(<, abs, false, Forward) === By(abs, Lt(<)) @test ord(<, abs, true, Forward) === ReverseOrdering(By(abs, Lt(<))) @test ord(<, abs, true, Reverse) === By(abs, Lt(<)) + +@testset "Base.Order docstrings" begin + undoc = Docs.undocumented_names(Base.Order) + @test_broken isempty(undoc) + @test undoc == [:DirectOrdering, :ForwardOrdering, :Order, :ordtype] +end diff --git a/test/sorting.jl b/test/sorting.jl index ad821e38efe55..d1875c9727a29 100644 --- a/test/sorting.jl +++ b/test/sorting.jl @@ -9,6 +9,12 @@ using Test isdefined(Main, :OffsetArrays) || @eval Main include("testhelpers/OffsetArrays.jl") using .Main.OffsetArrays +@testset "Base.Sort docstrings" begin + undoc = Docs.undocumented_names(Base.Sort) + @test_broken isempty(undoc) + @test undoc == [:Algorithm, :SMALL_ALGORITHM, :SMALL_THRESHOLD, :Sort] +end + @testset "Order" begin @test Forward == ForwardOrdering() @test ReverseOrdering(Forward) == ReverseOrdering() == Reverse diff --git a/test/stacktraces.jl b/test/stacktraces.jl index be035e31833d3..caea8158315ff 100644 --- a/test/stacktraces.jl +++ b/test/stacktraces.jl @@ -268,3 +268,7 @@ struct F49231{a,b,c,d,e,f,g} end str = sprint(Base.show_backtrace, st, context = (:limit=>true, :stacktrace_types_limited => Ref(false), :color=>true, :displaysize=>(50,132))) @test contains(str, "[2] \e[0m\e[1m(::$F49231{Vector, Val{…}, Vector{…}, NTuple{…}, $Int, $Int, $Int})\e[22m\e[0m\e[1m(\e[22m\e[90ma\e[39m::\e[0m$Int, \e[90mb\e[39m::\e[0m$Int, \e[90mc\e[39m::\e[0m$Int\e[0m\e[1m)\e[22m\n\e[90m") end + +@testset "Base.StackTraces docstrings" begin + @test isempty(Docs.undocumented_names(StackTraces)) +end diff --git a/test/sysinfo.jl b/test/sysinfo.jl index 8864e3a48efc7..4bdc9aeba48f2 100644 --- a/test/sysinfo.jl +++ b/test/sysinfo.jl @@ -54,3 +54,9 @@ end @test !isempty(Sys.username()) end end + +@testset "Base.Sys docstrings" begin + undoc = Docs.undocumented_names(Sys) + @test_broken isempty(undoc) + @test undoc == [:CPU_NAME, :JIT, :cpu_info, :cpu_summary] +end diff --git a/test/threads.jl b/test/threads.jl index ad09304bbd80d..307742a4c292b 100644 --- a/test/threads.jl +++ b/test/threads.jl @@ -337,3 +337,7 @@ end # There must be at least two: one for the root test task and one for the async task: @test fetch(@async(@ccall(jl_get_num_stack_mappings()::Cint))) >= 2 end + +@testset "Base.Threads docstrings" begin + @test isempty(Docs.undocumented_names(Threads)) +end