From d7597798517fca90bead9c7d1b40b9084ec6340a Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Tue, 26 Sep 2017 18:33:17 -0400 Subject: [PATCH] move Test from Base to stdlib --- base/deprecated.jl | 97 +++++-------------- base/exports.jl | 1 - base/sysimg.jl | 2 +- doc/make.jl | 6 +- doc/src/stdlib/.gitignore | 1 + examples/embedding/embedding-test.jl | 2 +- examples/juliatypes.jl | 2 +- stdlib/DelimitedFiles/test/runtests.jl | 2 +- .../test.md => stdlib/Test/docs/src/index.md | 44 ++++----- base/test.jl => stdlib/Test/src/Test.jl | 75 +++++++++++++- test/test.jl => stdlib/Test/test/runtests.jl | 60 ++++++------ test/arrayops.jl | 6 +- test/asmvariant.jl | 2 +- test/backtrace.jl | 4 +- test/boundscheck_exec.jl | 2 +- test/broadcast.jl | 3 +- test/choosetests.jl | 2 +- test/cmdlineargs.jl | 2 +- test/codevalidation.jl | 2 +- test/compile.jl | 9 +- test/core.jl | 24 ++--- test/deprecation_exec.jl | 2 +- test/distributed_exec.jl | 4 +- test/enums.jl | 2 +- test/file.jl | 2 + test/float16.jl | 2 +- test/floatfuncs.jl | 2 +- test/inline.jl | 2 +- test/linalg/arnoldi.jl | 2 +- test/linalg/bidiag.jl | 2 +- test/linalg/bunchkaufman.jl | 2 +- test/linalg/cholesky.jl | 2 +- test/linalg/dense.jl | 2 +- test/linalg/diagonal.jl | 2 +- test/linalg/eigen.jl | 2 +- test/linalg/generic.jl | 2 +- test/linalg/givens.jl | 2 +- test/linalg/hessenberg.jl | 2 +- test/linalg/lapack.jl | 2 +- test/linalg/lq.jl | 2 +- test/linalg/lu.jl | 2 +- test/linalg/matmul.jl | 6 +- test/linalg/pinv.jl | 2 +- test/linalg/qr.jl | 2 +- test/linalg/schur.jl | 2 +- test/linalg/special.jl | 2 +- test/linalg/svd.jl | 2 +- test/linalg/symmetric.jl | 2 +- test/linalg/triangular.jl | 2 +- test/linalg/uniformscaling.jl | 2 +- test/llvmcall.jl | 8 +- test/loading.jl | 2 +- test/nullable.jl | 3 +- test/numbers.jl | 3 +- test/offsetarray.jl | 2 +- test/parse.jl | 6 +- test/perf/micro/perf.jl | 2 +- test/random.jl | 2 +- test/reflection.jl | 10 +- test/replcompletions.jl | 2 +- test/replutil.jl | 2 +- test/rounding.jl | 4 +- test/runtests.jl | 56 +++++------ test/serialize.jl | 4 +- test/show.jl | 4 +- test/stacktraces.jl | 2 +- test/staged.jl | 2 +- test/statistics.jl | 2 +- test/strings/util.jl | 2 +- test/subarray.jl | 2 +- test/subtype.jl | 2 +- test/test_exec.jl | 2 +- test/testdefs.jl | 12 ++- test/threads.jl | 4 +- test/workspace.jl | 4 +- 75 files changed, 297 insertions(+), 259 deletions(-) rename doc/src/stdlib/test.md => stdlib/Test/docs/src/index.md (89%) rename base/test.jl => stdlib/Test/src/Test.jl (95%) rename test/test.jl => stdlib/Test/test/runtests.jl (91%) diff --git a/base/deprecated.jl b/base/deprecated.jl index 36b21d454b420..abef0bce735ad 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -119,14 +119,18 @@ macro deprecate_binding(old, new, export_old=true) Expr(:call, :deprecate, __module__, Expr(:quote, old))) end -macro deprecate_moved(old, new, export_old=true) +macro deprecate_moved(old, new, export_old=true, default_package=false) eold = esc(old) return Expr(:toplevel, - :(function $eold(args...; kwargs...) - error($eold, " has been moved to the package ", $new, ".jl.\n", - "Run `Pkg.add(\"", $new, "\")` to install it, restart Julia,\n", - "and then run `using ", $new, "` to load it.") - end), + default_package ? :(function $eold(args...; kwargs...) + error($eold, " has been moved to the standard library package ", $new, ".\n", + "Restart Julia and then run `using ", $new, "` to load it.") + end) : + :(function $eold(args...; kwargs...) + error($eold, " has been moved to the package ", $new, ".jl.\n", + "Run `Pkg.add(\"", $new, "\")` to install it, restart Julia,\n", + "and then run `using ", $new, "` to load it.") + end), export_old ? Expr(:export, eold) : nothing, Expr(:call, :deprecate, __module__, Expr(:quote, old), 2)) end @@ -134,7 +138,7 @@ end # BEGIN 0.6-alpha deprecations (delete when 0.6 is released) @deprecate isambiguous(m1::Method, m2::Method, b::Bool) isambiguous(m1, m2, ambiguous_bottom=b) false -# TODO: delete allow_bottom keyword code in Base.Test.detect_ambiguities +# TODO: delete allow_bottom keyword code in Test.detect_ambiguities # END 0.6-alpha deprecations @@ -996,73 +1000,6 @@ iteratoreltype(::Type{Task}) = EltypeUnknown() isempty(::Task) = error("isempty not defined for Tasks") -@eval Base.Test begin - approx_full(x::AbstractArray) = x - approx_full(x::Number) = x - approx_full(x) = full(x) - - function test_approx_eq(va, vb, Eps, astr, bstr) - va = approx_full(va) - vb = approx_full(vb) - la, lb = length(linearindices(va)), length(linearindices(vb)) - if la != lb - error("lengths of ", astr, " and ", bstr, " do not match: ", - "\n ", astr, " (length $la) = ", va, - "\n ", bstr, " (length $lb) = ", vb) - end - diff = real(zero(eltype(va))) - for (xa, xb) = zip(va, vb) - if isfinite(xa) && isfinite(xb) - diff = max(diff, abs(xa-xb)) - elseif !isequal(xa,xb) - error("mismatch of non-finite elements: ", - "\n ", astr, " = ", va, - "\n ", bstr, " = ", vb) - end - end - - if !isnan(Eps) && !(diff <= Eps) - sdiff = string("|", astr, " - ", bstr, "| <= ", Eps) - error("assertion failed: ", sdiff, - "\n ", astr, " = ", va, - "\n ", bstr, " = ", vb, - "\n difference = ", diff, " > ", Eps) - end - end - - array_eps(a::AbstractArray{Complex{T}}) where {T} = eps(float(maximum(x->(isfinite(x) ? abs(x) : T(NaN)), a))) - array_eps(a) = eps(float(maximum(x->(isfinite(x) ? abs(x) : oftype(x,NaN)), a))) - - test_approx_eq(va, vb, astr, bstr) = - test_approx_eq(va, vb, 1E4*length(linearindices(va))*max(array_eps(va), array_eps(vb)), astr, bstr) - - """ - @test_approx_eq_eps(a, b, tol) - - Test two floating point numbers `a` and `b` for equality taking into account - a margin of tolerance given by `tol`. - """ - macro test_approx_eq_eps(a, b, c) - Base.depwarn(string("@test_approx_eq_eps is deprecated, use `@test ", a, " ≈ ", b, " atol=", c, "` instead"), - Symbol("@test_approx_eq_eps")) - :(test_approx_eq($(esc(a)), $(esc(b)), $(esc(c)), $(string(a)), $(string(b)))) - end - export @test_approx_eq_eps - - """ - @test_approx_eq(a, b) - - Deprecated. Test two floating point numbers `a` and `b` for equality taking into - account small numerical errors. - """ - macro test_approx_eq(a, b) - Base.depwarn(string("@test_approx_eq is deprecated, use `@test ", a, " ≈ ", b, "` instead"), - Symbol("@test_approx_eq")) - :(test_approx_eq($(esc(a)), $(esc(b)), $(string(a)), $(string(b)))) - end - export @test_approx_eq -end - # Deprecate Array(T, dims...) in favor of proper type constructors @deprecate Array(::Type{T}, d::NTuple{N,Int}) where {T,N} Array{T}(d) @deprecate Array(::Type{T}, d::Int...) where {T} Array{T}(d...) @@ -1429,6 +1366,18 @@ end using .DSP export conv, conv2, deconv, filt, filt!, xcorr +module Test +for f in [Symbol("@inferred"), Symbol("@test"), Symbol("@test_approx_eq"), + Symbol("@test_approx_eq_eps"), Symbol("@test_broken"), Symbol("@test_nowarn"), + Symbol("@test_skip"), Symbol("@test_throws"), Symbol("@test_warn"), + Symbol("@testset"), :GenericArray, :GenericDict, :GenericSet, :GenericString, + :detect_ambiguities, :detect_unbound_args] + @eval Base.@deprecate_moved $f "Test" true true +end +end +export Test +deprecate(@__MODULE__, :Test) + # PR #21709 @deprecate cov(x::AbstractVector, corrected::Bool) cov(x, corrected=corrected) @deprecate cov(x::AbstractMatrix, vardim::Int, corrected::Bool) cov(x, vardim, corrected=corrected) diff --git a/base/exports.jl b/base/exports.jl index 195c536e30d0d..62680eda16b59 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -9,7 +9,6 @@ export Profile, Dates, Sys, - Test, Libc, Libdl, Mmap, diff --git a/base/sysimg.jl b/base/sysimg.jl index 013ef3da83e6d..7609ab098fad2 100644 --- a/base/sysimg.jl +++ b/base/sysimg.jl @@ -364,7 +364,6 @@ include("deepcopy.jl") include("interactiveutil.jl") include("summarysize.jl") include("replutil.jl") -include("test.jl") include("i18n.jl") using .I18n @@ -456,6 +455,7 @@ Base.init_load_path(ccall(:jl_get_julia_home, Any, ())) # load some stdlib packages but don't put their names in Main Base.require(:DelimitedFiles) +Base.require(:Test) empty!(LOAD_PATH) diff --git a/doc/make.jl b/doc/make.jl index 5de0371d68068..2ba1dfd9a7201 100644 --- a/doc/make.jl +++ b/doc/make.jl @@ -19,8 +19,10 @@ end # make links for stdlib package docs if Sys.iswindows() cp("../stdlib/DelimitedFiles/docs/src/index.md", "src/stdlib/delimitedfiles.md") + cp("../stdlib/Test/docs/src/index.md", "src/stdlib/test.md") else symlink("../../../stdlib/DelimitedFiles/docs/src/index.md", "src/stdlib/delimitedfiles.md") + symlink("../../../stdlib/Test/docs/src/index.md", "src/stdlib/test.md") end const PAGES = [ @@ -124,11 +126,11 @@ const PAGES = [ ], ] -using DelimitedFiles +using DelimitedFiles, Test makedocs( build = joinpath(pwd(), "_build/html/en"), - modules = [Base, Core, BuildSysImg, DelimitedFiles], + modules = [Base, Core, BuildSysImg, DelimitedFiles, Test], clean = false, doctest = "doctest" in ARGS, linkcheck = "linkcheck" in ARGS, diff --git a/doc/src/stdlib/.gitignore b/doc/src/stdlib/.gitignore index 014a6f161ae01..39d3308169806 100644 --- a/doc/src/stdlib/.gitignore +++ b/doc/src/stdlib/.gitignore @@ -1 +1,2 @@ delimitedfiles.md +test.md diff --git a/examples/embedding/embedding-test.jl b/examples/embedding/embedding-test.jl index 11aaca5b5d258..8d6ed917ce3f5 100644 --- a/examples/embedding/embedding-test.jl +++ b/examples/embedding/embedding-test.jl @@ -1,7 +1,7 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license # tests the output of the embedding example is correct -using Base.Test +using Test if Sys.iswindows() # libjulia needs to be in the same directory as the embedding executable or in path diff --git a/examples/juliatypes.jl b/examples/juliatypes.jl index 09f6fc582947e..5b580f0392eb3 100644 --- a/examples/juliatypes.jl +++ b/examples/juliatypes.jl @@ -495,7 +495,7 @@ tndict[AbstractArray.name] = AbstractArrayT.T.T.name tndict[Array.name] = ArrayT.T.T.name tndict[Pair.name] = PairT.T.T.name -using Base.Test +using Test issub_strict(x,y) = issub(x,y) && !issub(y,x) diff --git a/stdlib/DelimitedFiles/test/runtests.jl b/stdlib/DelimitedFiles/test/runtests.jl index aa39df87b6371..f41bd7d0728fa 100644 --- a/stdlib/DelimitedFiles/test/runtests.jl +++ b/stdlib/DelimitedFiles/test/runtests.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test using DelimitedFiles isequaldlm(m1, m2, t) = isequal(m1, m2) && (eltype(m1) == eltype(m2) == t) diff --git a/doc/src/stdlib/test.md b/stdlib/Test/docs/src/index.md similarity index 89% rename from doc/src/stdlib/test.md rename to stdlib/Test/docs/src/index.md index 5f8415ee79b09..4c0dcc570fe68 100644 --- a/doc/src/stdlib/test.md +++ b/stdlib/Test/docs/src/index.md @@ -2,7 +2,7 @@ ```@meta DocTestSetup = quote - using Base.Test + using Test end ``` @@ -18,7 +18,7 @@ Base.runtests ## Basic Unit Tests -The `Base.Test` module provides simple *unit testing* functionality. Unit testing is a way to +The `Test` module provides simple *unit testing* functionality. Unit testing is a way to see if your code is correct by checking that the results are what you expect. It can be helpful to ensure your code still works after you make changes, and can be used when developing as a way of specifying the behaviors your code should have when complete. @@ -26,14 +26,14 @@ of specifying the behaviors your code should have when complete. Simple unit testing can be performed with the `@test` and `@test_throws` macros: ```@docs -Base.Test.@test -Base.Test.@test_throws +Test.@test +Test.@test_throws ``` For example, suppose we want to check our new function `foo(x)` works as expected: ```jldoctest testfoo -julia> using Base.Test +julia> using Test julia> foo(x) = length(x)^2 foo (generic function with 1 method) @@ -100,7 +100,7 @@ be run, and at the end of the test set a summary will be printed. If any of the or could not be evaluated due to an error, the test set will then throw a `TestSetException`. ```@docs -Base.Test.@testset +Test.@testset ``` We can put our tests for the `foo(x)` function in a test set: @@ -181,9 +181,9 @@ ERROR: There was an error during testing ``` ```@docs -Base.Test.@inferred -Base.Test.@test_warn -Base.Test.@test_nowarn +Test.@inferred +Test.@test_warn +Test.@test_nowarn ``` ## Broken Tests @@ -193,14 +193,14 @@ the test as `Broken` if the test continues to fail and alerts the user via an `E succeeds. ```@docs -Base.Test.@test_broken +Test.@test_broken ``` `@test_skip` is also available to skip a test without evaluation, but counting the skipped test in the test set reporting. The test will not run but gives a `Broken` `Result`. ```@docs -Base.Test.@test_skip +Test.@test_skip ``` ## Creating Custom `AbstractTestSet` Types @@ -210,32 +210,32 @@ methods. The subtype should have a one-argument constructor taking a description any options passed in as keyword arguments. ```@docs -Base.Test.record -Base.Test.finish +Test.record +Test.finish ``` -`Base.Test` takes responsibility for maintaining a stack of nested testsets as they are executed, +`Test` takes responsibility for maintaining a stack of nested testsets as they are executed, but any result accumulation is the responsibility of the `AbstractTestSet` subtype. You can access this stack with the `get_testset` and `get_testset_depth` methods. Note that these functions are not exported. ```@docs -Base.Test.get_testset -Base.Test.get_testset_depth +Test.get_testset +Test.get_testset_depth ``` -`Base.Test` also makes sure that nested `@testset` invocations use the same `AbstractTestSet` +`Test` also makes sure that nested `@testset` invocations use the same `AbstractTestSet` subtype as their parent unless it is set explicitly. It does not propagate any properties of the testset. Option inheritance behavior can be implemented by packages using the stack infrastructure -that `Base.Test` provides. +that `Test` provides. Defining a basic `AbstractTestSet` subtype might look like: ```julia -import Base.Test: record, finish -using Base.Test: AbstractTestSet, Result, Pass, Fail, Error -using Base.Test: get_testset_depth, get_testset -struct CustomTestSet <: Base.Test.AbstractTestSet +import Test: record, finish +using Test: AbstractTestSet, Result, Pass, Fail, Error +using Test: get_testset_depth, get_testset +struct CustomTestSet <: Test.AbstractTestSet description::AbstractString foo::Int results::Vector diff --git a/base/test.jl b/stdlib/Test/src/Test.jl similarity index 95% rename from base/test.jl rename to stdlib/Test/src/Test.jl index ba9138c8314bb..cca73159264be 100644 --- a/base/test.jl +++ b/stdlib/Test/src/Test.jl @@ -1,5 +1,7 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license +__precompile__(true) + """ Simple unit testing functionality: @@ -11,8 +13,6 @@ test set that throws on the first failure. Users can choose to wrap their tests in (possibly nested) test sets that will store results and summarize them at the end of the test set with `@testset`. """ -:Test # cf. #22288 - module Test export @test, @test_throws, @test_broken, @test_skip, @test_warn, @test_nowarn @@ -1113,7 +1113,7 @@ Returns the result of `f(x)` if the types match, and an `Error` `Result` if it finds different types. ```jldoctest -julia> using Base.Test +julia> using Test julia> f(a,b,c) = b > 1 ? 1 : 1.0 f (generic function with 1 method) @@ -1429,4 +1429,73 @@ Base.setindex!(a::GenericArray, x, i...) = a.a[i...] = x Base.similar(A::GenericArray, s::Integer...) = GenericArray(similar(A.a, s...)) +# 0.7 deprecations + +begin + approx_full(x::AbstractArray) = x + approx_full(x::Number) = x + approx_full(x) = full(x) + + function test_approx_eq(va, vb, Eps, astr, bstr) + va = approx_full(va) + vb = approx_full(vb) + la, lb = length(linearindices(va)), length(linearindices(vb)) + if la != lb + error("lengths of ", astr, " and ", bstr, " do not match: ", + "\n ", astr, " (length $la) = ", va, + "\n ", bstr, " (length $lb) = ", vb) + end + diff = real(zero(eltype(va))) + for (xa, xb) = zip(va, vb) + if isfinite(xa) && isfinite(xb) + diff = max(diff, abs(xa-xb)) + elseif !isequal(xa,xb) + error("mismatch of non-finite elements: ", + "\n ", astr, " = ", va, + "\n ", bstr, " = ", vb) + end + end + + if !isnan(Eps) && !(diff <= Eps) + sdiff = string("|", astr, " - ", bstr, "| <= ", Eps) + error("assertion failed: ", sdiff, + "\n ", astr, " = ", va, + "\n ", bstr, " = ", vb, + "\n difference = ", diff, " > ", Eps) + end + end + + array_eps(a::AbstractArray{Complex{T}}) where {T} = eps(float(maximum(x->(isfinite(x) ? abs(x) : T(NaN)), a))) + array_eps(a) = eps(float(maximum(x->(isfinite(x) ? abs(x) : oftype(x,NaN)), a))) + + test_approx_eq(va, vb, astr, bstr) = + test_approx_eq(va, vb, 1E4*length(linearindices(va))*max(array_eps(va), array_eps(vb)), astr, bstr) + + """ + @test_approx_eq_eps(a, b, tol) + + Test two floating point numbers `a` and `b` for equality taking into account + a margin of tolerance given by `tol`. + """ + macro test_approx_eq_eps(a, b, c) + Base.depwarn(string("@test_approx_eq_eps is deprecated, use `@test ", a, " ≈ ", b, " atol=", c, "` instead"), + Symbol("@test_approx_eq_eps")) + :(test_approx_eq($(esc(a)), $(esc(b)), $(esc(c)), $(string(a)), $(string(b)))) + end + export @test_approx_eq_eps + + """ + @test_approx_eq(a, b) + + Deprecated. Test two floating point numbers `a` and `b` for equality taking into + account small numerical errors. + """ + macro test_approx_eq(a, b) + Base.depwarn(string("@test_approx_eq is deprecated, use `@test ", a, " ≈ ", b, "` instead"), + Symbol("@test_approx_eq")) + :(test_approx_eq($(esc(a)), $(esc(b)), $(string(a)), $(string(b)))) + end + export @test_approx_eq +end + end # module diff --git a/test/test.jl b/stdlib/Test/test/runtests.jl similarity index 91% rename from test/test.jl rename to stdlib/Test/test/runtests.jl index 791cf1ecb1c34..a1d9d661110ce 100644 --- a/test/test.jl +++ b/stdlib/Test/test/runtests.jl @@ -1,5 +1,7 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license +using Test + # Test @test @test true @test 1 == 1 @@ -68,12 +70,12 @@ end "Thrown: ErrorException") # Test printing of Fail results -mutable struct NoThrowTestSet <: Base.Test.AbstractTestSet +mutable struct NoThrowTestSet <: Test.AbstractTestSet results::Vector NoThrowTestSet(desc) = new([]) end -Base.Test.record(ts::NoThrowTestSet, t::Base.Test.Result) = (push!(ts.results, t); t) -Base.Test.finish(ts::NoThrowTestSet) = ts.results +Test.record(ts::NoThrowTestSet, t::Test.Result) = (push!(ts.results, t); t) +Test.finish(ts::NoThrowTestSet) = ts.results let fails = @testset NoThrowTestSet begin # Fail - wrong exception @test_throws OverflowError error() @@ -107,7 +109,7 @@ let fails = @testset NoThrowTestSet begin @test ==(1, 1:2...) end for i in 1:length(fails) - 2 - @test isa(fails[i], Base.Test.Fail) + @test isa(fails[i], Test.Fail) end let str = sprint(show, fails[1]) @@ -187,7 +189,7 @@ let fails = @testset NoThrowTestSet begin end # Test printing of a TestSetException -let tse_str = sprint(show, Test.TestSetException(1, 2, 3, 4, Vector{Union{Base.Test.Error, Base.Test.Fail}}())) +let tse_str = sprint(show, Test.TestSetException(1, 2, 3, 4, Vector{Union{Test.Error, Test.Fail}}())) @test contains(tse_str, "1 passed") @test contains(tse_str, "2 failed") @test contains(tse_str, "3 errored") @@ -222,13 +224,13 @@ end ts = @testset "@testset should return the testset" begin @test true end - @test typeof(ts) == Base.Test.DefaultTestSet + @test typeof(ts) == Test.DefaultTestSet @test ts.n_passed == 1 tss = @testset "@testset/for should return an array of testsets: $i" for i in 1:3 @test true end @test length(tss) == 3 - @test typeof(tss[1]) == Base.Test.DefaultTestSet + @test typeof(tss[1]) == Test.DefaultTestSet @test tss[1].n_passed == 1 end @testset "accounting" begin @@ -299,7 +301,7 @@ end end @testset "ts results" begin @test isa(ts, Test.DefaultTestSet) - passes, fails, errors, broken, c_passes, c_fails, c_errors, c_broken = Base.Test.get_test_counts(ts) + passes, fails, errors, broken, c_passes, c_fails, c_errors, c_broken = Test.get_test_counts(ts) total_pass = passes + c_passes total_fail = fails + c_fails total_error = errors + c_errors @@ -310,7 +312,7 @@ end @test total_broken == 0 end ts.anynonpass = false - deleteat!(Base.Test.get_testset().results,1) + deleteat!(Test.get_testset().results,1) end @test .1+.1+.1 ≈ .3 @@ -319,14 +321,14 @@ end ts = @testset "@testset should return the testset" begin @test true end -@test typeof(ts) == Base.Test.DefaultTestSet +@test typeof(ts) == Test.DefaultTestSet @test ts.n_passed == 1 tss = @testset "@testset/for should return an array of testsets: $i" for i in 1:3 @test true end @test length(tss) == 3 -@test typeof(tss[1]) == Base.Test.DefaultTestSet +@test typeof(tss[1]) == Test.DefaultTestSet @test tss[1].n_passed == 1 # Issue #17908 (return) @@ -369,7 +371,7 @@ end @assert testset_depth17462 == Test.get_testset_depth() @assert length(tss17462) == 3 for ts17462 in tss17462 - @assert isa(ts17462, Base.Test.DefaultTestSet) + @assert isa(ts17462, Test.DefaultTestSet) end @test counter_17462_pre == 3 @test counter_17462_post == 1 @@ -384,17 +386,17 @@ ts = try catch nothing # Shouldn't get here end -@test ts isa Base.Test.DefaultTestSet +@test ts isa Test.DefaultTestSet # now we're done running tests with DefaultTestSet so we can go back to STDOUT redirect_stdout(OLD_STDOUT) redirect_stderr(OLD_STDERR) # import the methods needed for defining our own testset type -import Base.Test: record, finish -using Base.Test: get_testset_depth, get_testset -using Base.Test: AbstractTestSet, Result, Pass, Fail, Error -struct CustomTestSet <: Base.Test.AbstractTestSet +import Test: record, finish +using Test: get_testset_depth, get_testset +using Test: AbstractTestSet, Result, Pass, Fail, Error +struct CustomTestSet <: Test.AbstractTestSet description::AbstractString foo::Int results::Vector @@ -530,26 +532,28 @@ end @test_throws ErrorException @testset "$(error())" begin end -let io = IOBuffer() - # calls backtrace() from inside @test - @test (print(io, Base.Test.Error(:test_error, "woot", 5, backtrace())); 1) == 1 - let str = String(take!(io)) - # NOTE: This test depends on the code generated by @testset getting compiled, - # to get good backtraces. If it fails, check the implementation of `testset_beginend`. - @test contains(str, "test.jl") - @test !contains(str, "client.jl") +@testset "backtraces in test errors" begin + let io = IOBuffer() + # calls backtrace() from inside @test + @test (print(io, Test.Error(:test_error, "woot", 5, backtrace())); 1) == 1 + let str = String(take!(io)) + # NOTE: This test depends on the code generated by @testset getting compiled, + # to get good backtraces. If it fails, check the implementation of `testset_beginend`. + @test contains(str, "Test.jl") + @test_broken !contains(str, "client.jl") + end end end let io = IOBuffer() - exc = Test.TestSetException(1,2,3,4,Vector{Union{Base.Test.Error, Base.Test.Fail}}()) + exc = Test.TestSetException(1,2,3,4,Vector{Union{Test.Error, Test.Fail}}()) Base.showerror(io, exc, backtrace()) @test !contains(String(take!(io)), "backtrace()") end # 19750 let io = IOBuffer() - exc = Test.TestSetException(1,2,3,4,Vector{Union{Base.Test.Error, Base.Test.Fail}}()) + exc = Test.TestSetException(1,2,3,4,Vector{Union{Test.Error, Test.Fail}}()) Base.showerror(io, exc, backtrace()) @test !contains(String(take!(io)), "backtrace()") @@ -561,7 +565,7 @@ let io = IOBuffer() end msg = read(pipeline(ignorestatus(`$(Base.julia_cmd()) --startup-file=no --color=no -e ' -using Base.Test +using Test foo(x) = length(x)^2 diff --git a/test/arrayops.jl b/test/arrayops.jl index 70997260272ea..79dd9f788a62b 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -1731,7 +1731,7 @@ end end module RetTypeDecl - using Base.Test + using Test import Base: +, *, broadcast, convert struct MeterUnits{T,P} <: Number @@ -1975,7 +1975,7 @@ end module TestNLoops15895 using Base.Cartesian -using Base.Test +using Test # issue 15894 function f15894(d) @@ -2020,7 +2020,7 @@ end # issue 17254 module AutoRetType -using Base.Test +using Test struct Foo end for op in (:+, :*, :÷, :%, :<<, :>>, :-, :/, :\, ://, :^) diff --git a/test/asmvariant.jl b/test/asmvariant.jl index 27209997511c8..5c75776bbb6e2 100644 --- a/test/asmvariant.jl +++ b/test/asmvariant.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test ix86 = r"i[356]86" diff --git a/test/backtrace.jl b/test/backtrace.jl index 3a3c12da924a1..f7e03d9f744fb 100644 --- a/test/backtrace.jl +++ b/test/backtrace.jl @@ -15,7 +15,7 @@ end # Test location information for inlined code (ref issues #1334 #12544) module test_inline_bt -using Base.Test +using Test function get_bt_frames(functionname, bt) for i = 1:length(bt) @@ -104,7 +104,7 @@ end module BackTraceTesting -using Base.Test +using Test @inline bt2() = backtrace() @inline bt1() = bt2() diff --git a/test/boundscheck_exec.jl b/test/boundscheck_exec.jl index 35e61536ddb2d..ee8413bd4e5b9 100644 --- a/test/boundscheck_exec.jl +++ b/test/boundscheck_exec.jl @@ -2,7 +2,7 @@ module TestBoundsCheck -using Base.Test +using Test @enum BCOption bc_default bc_on bc_off bc_opt = BCOption(Base.JLOptions().check_bounds) diff --git a/test/broadcast.jl b/test/broadcast.jl index a8bb7e00b3744..e88f5a0403d1d 100644 --- a/test/broadcast.jl +++ b/test/broadcast.jl @@ -4,7 +4,8 @@ module TestBroadcastInternals using Base.Broadcast: broadcast_indices, check_broadcast_indices, check_broadcast_shape, newindex, _bcs -using Base: Test, OneTo +using Base: OneTo +using Test @test @inferred(_bcs((3,5), (3,5))) == (3,5) @test @inferred(_bcs((3,1), (3,5))) == (3,5) diff --git a/test/choosetests.jl b/test/choosetests.jl index af9d5df891367..c769fe9d44dca 100644 --- a/test/choosetests.jl +++ b/test/choosetests.jl @@ -35,7 +35,7 @@ function choosetests(choices = []) "floatapprox", "stdlib", "reflection", "regex", "float16", "combinatorics", "sysinfo", "env", "rounding", "ranges", "mod2pi", "euler", "show", "lineedit", "replcompletions", "repl", - "replutil", "sets", "test", "goto", "llvmcall", "llvmcall2", "grisu", + "replutil", "sets", "goto", "llvmcall", "llvmcall2", "grisu", "nullable", "meta", "stacktraces", "profile", "libgit2", "docs", "markdown", "base64", "serialize", "misc", "threads", "enums", "cmdlineargs", "i18n", "workspace", "libdl", "int", diff --git a/test/cmdlineargs.jl b/test/cmdlineargs.jl index 7d4684d10a344..8220001ca127c 100644 --- a/test/cmdlineargs.jl +++ b/test/cmdlineargs.jl @@ -468,7 +468,7 @@ let exename = `$(Base.julia_cmd()) --startup-file=no` for (mac, flag, pfix, msg) in [("@test_nowarn", ``, "_1", ""), ("@test_warn", `--warn-overwrite=yes`, "_2", "\"WARNING: Method definition\"")] str = """ - using Base.Test + using Test try # issue #18725 $mac $msg @eval Main begin diff --git a/test/codevalidation.jl b/test/codevalidation.jl index 5b342b8c60dba..511585f5477c2 100644 --- a/test/codevalidation.jl +++ b/test/codevalidation.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test function f22938(a, b, x...) d = 1 diff --git a/test/compile.jl b/test/compile.jl index 8fa1829c24426..c517a3af95e0d 100644 --- a/test/compile.jl +++ b/test/compile.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test import Base: root_module @@ -60,6 +60,7 @@ try using $FooBase_module, $FooBase_module.typeA import $Foo2_module: $Foo2_module, override import $FooBase_module.hash + import Test struct typeB y::typeA @@ -91,7 +92,7 @@ try (::Task)(::UInt8, ::UInt16, ::UInt32) = 2 # issue 16471 (capturing references to a kwfunc) - Base.Test.@test_throws ErrorException Core.kwfunc(Base.nothing) + Test.@test_throws ErrorException Core.kwfunc(Base.nothing) Base.nothing(::UInt8, ::UInt16, ::UInt32; x = 52) = x const nothingkw = Core.kwfunc(Base.nothing) @@ -140,7 +141,7 @@ try end g() = override(1.0) - Base.Test.@test g() === 2.0 # compile this + Test.@test g() === 2.0 # compile this end """) @test_throws ErrorException Core.kwfunc(Base.nothing) # make sure `nothing` didn't have a kwfunc (which would invalidate the attempted test) @@ -208,7 +209,7 @@ try modules, deps1 = Base.cache_dependencies(cachefile) @test modules == merge(Dict(s => Base.module_uuid(getfield(Foo, s)) for s in - [:Base, :Core, Foo2_module, FooBase_module, :Main]), + [:Base, :Core, Foo2_module, FooBase_module, :Main, :Test]), # plus modules included in the system image Dict(s => Base.module_uuid(Base.root_module(s)) for s in [:DelimitedFiles])) diff --git a/test/core.jl b/test/core.jl index 6848237d8e07e..d5701879c43ae 100644 --- a/test/core.jl +++ b/test/core.jl @@ -2273,7 +2273,7 @@ end #issue #9835 module M9835 - using Base.Test + using Test mutable struct A end; mutable struct B end f() = (isa(A(), A) ? A : B)() @test isa(f(), A) @@ -3193,7 +3193,7 @@ end @test_throws TypeError MyType8010_ghost([3.0;4.0]) module TestNewTypeError -using Base.Test +using Test struct A end @@ -3697,7 +3697,7 @@ end # issue #13229 module I13229 -using Base.Test +using Test if !startswith(string(Sys.ARCH), "arm") global z = 0 @timed @profile for i = 1:5 @@ -3874,7 +3874,7 @@ let end module TestSharedArrayResize -using Base.Test +using Test # Attempting to change the shape of a shared array should unshare it and # not modify the original data function test_shared_array_resize(::Type{T}) where T @@ -3914,7 +3914,7 @@ test_shared_array_resize(Any) end module TestArrayNUL -using Base.Test +using Test function check_nul(a::Vector{UInt8}) b = ccall(:jl_array_cconvert_cstring, Ref{Vector{UInt8}}, (Vector{UInt8},), a) @@ -3992,7 +3992,7 @@ end # issue #14113 module A14113 - using Base.Test + using Test # show that making several thousand methods (and lots of AST constants) # doesn't cause any serious issues (for example, for the serializer) # although to keep runtime on the order of several seconds for this test, @@ -4036,7 +4036,7 @@ end # PR #16011 Make sure dead code elimination doesn't delete push and pop # of metadata module TestDeadElim16011 -using Base.Test +using Test function count_expr_push(ex::Expr, head::Symbol, counter) if ex.head === head @@ -4132,7 +4132,7 @@ end # with verifier on (but should still pass on release build). module TestSSA16244 -using Base.Test +using Test @noinline k(a) = a # unreachable branch due to `ccall(:jl_throw)` @@ -4744,7 +4744,7 @@ end @test let_noBox()() == 21 module TestModuleAssignment -using Base.Test +using Test @eval $(GlobalRef(TestModuleAssignment, :x)) = 1 @test x == 1 @eval $(GlobalRef(TestModuleAssignment, :x)) = 2 @@ -4780,7 +4780,7 @@ module SOE mutable struct Sgnd <: Signed v::Int end -using Base.Test +using Test @test_throws ErrorException abs(Sgnd(1)) #12007 io = IOBuffer() @test_throws ErrorException show(io, Sgnd(1)) #12007 @@ -5291,7 +5291,7 @@ end # issue 18933 module GlobalDef18933 - using Base.Test + using Test import Base.sqrt # test that global declaration vs assignment operates correctly in local scope f() = (global sin; nothing) @@ -5334,7 +5334,7 @@ end module UnionOptimizations -using Base.Test +using Test const boxedunions = [Union{}, Union{String, Void}] const unboxedunions = [Union{Int8, Void}, Union{Int8, Float16, Void}, diff --git a/test/deprecation_exec.jl b/test/deprecation_exec.jl index a747f30dde1a1..a0faf398d09e1 100644 --- a/test/deprecation_exec.jl +++ b/test/deprecation_exec.jl @@ -1,4 +1,4 @@ -using Base.Test +using Test module DeprecationTests # to test @deprecate f() = true diff --git a/test/distributed_exec.jl b/test/distributed_exec.jl index 35413a0c7173b..4f4d6ab2d960b 100644 --- a/test/distributed_exec.jl +++ b/test/distributed_exec.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test include("testenv.jl") # Test a few "remote" invocations when no workers are present @@ -13,6 +13,8 @@ include("testenv.jl") addprocs_with_testenv(4) @test nprocs() == 5 +@everywhere using Test + id_me = myid() id_other = filter(x -> x != id_me, procs())[rand(1:(nprocs()-1))] diff --git a/test/enums.jl b/test/enums.jl index 6ded32a9a19eb..a4cd797ce9035 100644 --- a/test/enums.jl +++ b/test/enums.jl @@ -3,7 +3,7 @@ # For curmod_* include("testenv.jl") -using Base.Test +using Test @test_throws MethodError convert(Enum, 1.0) diff --git a/test/file.jl b/test/file.jl index b247ee58d25c1..587470fb6899f 100644 --- a/test/file.jl +++ b/test/file.jl @@ -1123,6 +1123,7 @@ function test_13559() run(`mkfifo $fn`) # use subprocess to write 127 bytes to FIFO writer_cmds = """ + using Test x = open($(repr(fn)), "w") for i in 1:120 write(x, 0xaa) @@ -1159,6 +1160,7 @@ if !Sys.iswindows() run(`mkfifo $fn`) script = """ + using Test x = open($(repr(fn)), "w") write(x, 0x42) flush(x) diff --git a/test/float16.jl b/test/float16.jl index 0e71d0d0f8371..10c2f934dedbb 100644 --- a/test/float16.jl +++ b/test/float16.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test f = Float16(2.) g = Float16(1.) diff --git a/test/floatfuncs.jl b/test/floatfuncs.jl index ec22bb51fe1cf..f5f0f7472935a 100644 --- a/test/floatfuncs.jl +++ b/test/floatfuncs.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test # test the basic floating point functions diff --git a/test/inline.jl b/test/inline.jl index 769ea452d8a17..0c3b187ee93bb 100644 --- a/test/inline.jl +++ b/test/inline.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test """ Helper to walk the AST and call a function on every node. diff --git a/test/linalg/arnoldi.jl b/test/linalg/arnoldi.jl index 6b8a6e5e3a205..9bdca177b049b 100644 --- a/test/linalg/arnoldi.jl +++ b/test/linalg/arnoldi.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test @testset "eigs" begin srand(1234) diff --git a/test/linalg/bidiag.jl b/test/linalg/bidiag.jl index ee447448298d6..166babb7074f9 100644 --- a/test/linalg/bidiag.jl +++ b/test/linalg/bidiag.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test import Base.LinAlg: BlasReal, BlasFloat n = 10 #Size of test matrix diff --git a/test/linalg/bunchkaufman.jl b/test/linalg/bunchkaufman.jl index 30847c6705f31..6ec78f5eaba8c 100644 --- a/test/linalg/bunchkaufman.jl +++ b/test/linalg/bunchkaufman.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test using Base.LinAlg: BlasComplex, BlasFloat, BlasReal, QRPivoted diff --git a/test/linalg/cholesky.jl b/test/linalg/cholesky.jl index 87daa3a457f7b..cc78e88c3d41a 100644 --- a/test/linalg/cholesky.jl +++ b/test/linalg/cholesky.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test using Base.LinAlg: BlasComplex, BlasFloat, BlasReal, QRPivoted, PosDefException diff --git a/test/linalg/dense.jl b/test/linalg/dense.jl index ac4442e04b231..3413b0140feeb 100644 --- a/test/linalg/dense.jl +++ b/test/linalg/dense.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test @testset "Check that non-floats are correctly promoted" begin @test [1 0 0; 0 1 0]\[1,1] ≈ [1;1;0] diff --git a/test/linalg/diagonal.jl b/test/linalg/diagonal.jl index 6b8a0cae10aeb..fd3d1bbfd9c1b 100644 --- a/test/linalg/diagonal.jl +++ b/test/linalg/diagonal.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test import Base.LinAlg: BlasFloat, BlasComplex, SingularException, A_rdiv_B!, A_rdiv_Bt!, A_rdiv_Bc! diff --git a/test/linalg/eigen.jl b/test/linalg/eigen.jl index edfa42c7e7991..de4245a5020e7 100644 --- a/test/linalg/eigen.jl +++ b/test/linalg/eigen.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test using Base.LinAlg: BlasComplex, BlasFloat, BlasReal, QRPivoted diff --git a/test/linalg/generic.jl b/test/linalg/generic.jl index 9e45abcb23fc0..c79b63ed7e235 100644 --- a/test/linalg/generic.jl +++ b/test/linalg/generic.jl @@ -1,7 +1,7 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license import Base: -, *, /, \ -using Base.Test +using Test # A custom Quaternion type with minimal defined interface and methods. # Used to test scale and scale! methods to show non-commutativity. diff --git a/test/linalg/givens.jl b/test/linalg/givens.jl index c13ddd2fcbb3b..92f3216ca002b 100644 --- a/test/linalg/givens.jl +++ b/test/linalg/givens.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test # Test givens rotations @testset for elty in (Float32, Float64, Complex64, Complex128) diff --git a/test/linalg/hessenberg.jl b/test/linalg/hessenberg.jl index aca74a74199ef..d4ab0dab4d87f 100644 --- a/test/linalg/hessenberg.jl +++ b/test/linalg/hessenberg.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test using Base.LinAlg: BlasComplex, BlasFloat, BlasReal, QRPivoted diff --git a/test/linalg/lapack.jl b/test/linalg/lapack.jl index 78119dffa6e02..d54de1d2f342a 100644 --- a/test/linalg/lapack.jl +++ b/test/linalg/lapack.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test import Base.LinAlg.BlasInt diff --git a/test/linalg/lq.jl b/test/linalg/lq.jl index 199bda483fc43..632c5b6a79e1a 100644 --- a/test/linalg/lq.jl +++ b/test/linalg/lq.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test using Base.LinAlg: BlasComplex, BlasFloat, BlasReal diff --git a/test/linalg/lu.jl b/test/linalg/lu.jl index 09cfeb230aaf0..ae241576d7dea 100644 --- a/test/linalg/lu.jl +++ b/test/linalg/lu.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test import Base.LinAlg.BlasInt, Base.LinAlg.BlasFloat n = 10 diff --git a/test/linalg/matmul.jl b/test/linalg/matmul.jl index 3b8f6d18257e9..ce2815d2a695f 100644 --- a/test/linalg/matmul.jl +++ b/test/linalg/matmul.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test ## Test Julia fallbacks to BLAS routines @@ -64,7 +64,7 @@ end # Generic integer matrix multiplication # Generic AbstractArrays module MyArray15367 - using Base.Test + using Test struct MyArray{T,N} <: AbstractArray{T,N} data::Array{T,N} end @@ -366,7 +366,7 @@ end # #18218 module TestPR18218 - using Base.Test + using Test import Base.*, Base.+, Base.zero struct TypeA x::Int diff --git a/test/linalg/pinv.jl b/test/linalg/pinv.jl index 0cb26aa7f5648..d8ada553a82d0 100644 --- a/test/linalg/pinv.jl +++ b/test/linalg/pinv.jl @@ -4,7 +4,7 @@ # Test the pseudo-inverse # -using Base.Test +using Test srand(12345) diff --git a/test/linalg/qr.jl b/test/linalg/qr.jl index 25728ee0c8572..780e61a0d1a9b 100644 --- a/test/linalg/qr.jl +++ b/test/linalg/qr.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test using Base.LinAlg: BlasComplex, BlasFloat, BlasReal, QRPivoted diff --git a/test/linalg/schur.jl b/test/linalg/schur.jl index 53350074e2245..5a6fef0f7aa27 100644 --- a/test/linalg/schur.jl +++ b/test/linalg/schur.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test using Base.LinAlg: BlasComplex, BlasFloat, BlasReal, QRPivoted diff --git a/test/linalg/special.jl b/test/linalg/special.jl index 3b5d81cb6387f..991cea0604b1e 100644 --- a/test/linalg/special.jl +++ b/test/linalg/special.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test n= 10 #Size of matrix to test srand(1) diff --git a/test/linalg/svd.jl b/test/linalg/svd.jl index 592049d8c5b8f..ea03c9e45a006 100644 --- a/test/linalg/svd.jl +++ b/test/linalg/svd.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test using Base.LinAlg: BlasComplex, BlasFloat, BlasReal, QRPivoted diff --git a/test/linalg/symmetric.jl b/test/linalg/symmetric.jl index e1347d5caba2c..ea085e2c36720 100644 --- a/test/linalg/symmetric.jl +++ b/test/linalg/symmetric.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test srand(101) diff --git a/test/linalg/triangular.jl b/test/linalg/triangular.jl index 27fc05d824db7..a7988772cf8c5 100644 --- a/test/linalg/triangular.jl +++ b/test/linalg/triangular.jl @@ -1,7 +1,7 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license debug = false -using Base.Test +using Test using Base.LinAlg: BlasFloat, errorbounds, full!, naivesub!, transpose!, UnitUpperTriangular, UnitLowerTriangular, A_rdiv_B!, A_rdiv_Bt!, A_rdiv_Bc! debug && println("Triangular matrices") diff --git a/test/linalg/uniformscaling.jl b/test/linalg/uniformscaling.jl index ea77f54553b09..b310a7c83b5ed 100644 --- a/test/linalg/uniformscaling.jl +++ b/test/linalg/uniformscaling.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test srand(123) diff --git a/test/llvmcall.jl b/test/llvmcall.jl index 302d3950e75e2..70e5f7bbedb6e 100644 --- a/test/llvmcall.jl +++ b/test/llvmcall.jl @@ -49,7 +49,7 @@ end # Test whether llvmcall escapes the function name correctly baremodule PlusTest using Base.llvmcall - using Base.Test + using Test using Base function +(x::Int32, y::Int32) @@ -155,7 +155,8 @@ end call_jl_errno() module ObjLoadTest - using Base: Test, llvmcall, @ccallable + using Base: llvmcall, @ccallable + using Test didcall = false @ccallable Void function jl_the_callback() global didcall @@ -193,7 +194,8 @@ else end module CcallableRetTypeTest - using Base: Test, llvmcall, @ccallable + using Base: llvmcall, @ccallable + using Test @ccallable function jl_test_returns_float()::Float64 return 42 end diff --git a/test/loading.jl b/test/loading.jl index fc405732f5dc5..4c4809765b6ed 100644 --- a/test/loading.jl +++ b/test/loading.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test # Tests for @__LINE__ inside and outside of macros @test (@__LINE__) == 6 diff --git a/test/nullable.jl b/test/nullable.jl index 4148b44045033..fcc180ccc907a 100644 --- a/test/nullable.jl +++ b/test/nullable.jl @@ -115,12 +115,13 @@ for (i, T) in enumerate(types) end module NullableTestEnum +import Test # For curmod_* include("testenv.jl") io = IOBuffer() @enum TestEnum a b show(io, Nullable(a)) -Base.Test.@test String(take!(io)) == "Nullable{$(curmod_prefix)TestEnum}(a)" +Test.@test String(take!(io)) == "Nullable{$(curmod_prefix)TestEnum}(a)" end # showcompact(io::IO, x::Nullable) diff --git a/test/numbers.jl b/test/numbers.jl index 701de7ff697ef..668e7edf8595f 100644 --- a/test/numbers.jl +++ b/test/numbers.jl @@ -2929,9 +2929,10 @@ Base.literal_pow(::typeof(^), ::PR20530, ::Val{p}) where {p} = 2 @test PR20889(2)^3 == 5 end module M20889 # do we get the expected behavior without importing Base.^? + using Test struct PR20889; x; end ^(t::PR20889, b) = t.x + b - Base.Test.@test PR20889(2)^3 == 5 + Test.@test PR20889(2)^3 == 5 end @testset "iszero & isone" begin diff --git a/test/offsetarray.jl b/test/offsetarray.jl index 62010e73f3d63..b9f92895c6ccd 100644 --- a/test/offsetarray.jl +++ b/test/offsetarray.jl @@ -435,7 +435,7 @@ end # let # StackOverflowError if no appropriate method has been defined # (#18107) module SimilarUR - using Base.Test + using Test struct MyURange <: AbstractUnitRange{Int} start::Int stop::Int diff --git a/test/parse.jl b/test/parse.jl index 013953bdece01..62a3f786684a0 100644 --- a/test/parse.jl +++ b/test/parse.jl @@ -862,7 +862,7 @@ end # Issue #16578 (Lowering) mismatch between push_loc and pop_loc module TestMeta_16578 -using Base.Test +using Test function get_expr_list(ex::CodeInfo) return ex.code::Array{Any,1} end @@ -1101,7 +1101,7 @@ end # issue #20653 @test_throws UndefVarError Base.call(::Int) = 1 module Test20653 -using Base.Test +using Test struct A end call(::A) = 1 @@ -1212,7 +1212,7 @@ end # comment 298107224 on pull #21607 module Test21607 - using Base.Test + using Test const Any = Integer # check that X <: Core.Any, not Integer diff --git a/test/perf/micro/perf.jl b/test/perf/micro/perf.jl index c688694363741..02acef17c1679 100644 --- a/test/perf/micro/perf.jl +++ b/test/perf/micro/perf.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test include("../perfutil.jl") diff --git a/test/random.jl b/test/random.jl index ea56a529158c9..5851567a64aca 100644 --- a/test/random.jl +++ b/test/random.jl @@ -382,7 +382,7 @@ for rng in ([], [MersenneTwister(0)], [RandomDevice()]) end for C in [1:0, Dict(), Set(), IntSet(), Int[], GenericDict(Dict()), GenericSet(Set()), - "", Base.Test.GenericString("")] + "", Test.GenericString("")] @test_throws ArgumentError rand(rng..., C) @test_throws ArgumentError rand(rng..., C, 5) end diff --git a/test/reflection.jl b/test/reflection.jl index 752dda5fc51c7..a5ddc865d47c3 100644 --- a/test/reflection.jl +++ b/test/reflection.jl @@ -5,7 +5,7 @@ # sufficient to catch segfault bugs. module ReflectionTest -using Base.Test +using Test function test_ast_reflection(freflect, f, types) @test !isempty(freflect(f, types)) @@ -55,7 +55,7 @@ end # module ReflectionTest # code_warntype module WarnType -using Base.Test +using Test function warntype_hastag(f, types, tag) iob = IOBuffer() @@ -197,7 +197,7 @@ not_const = 1 include("testenv.jl") module TestMod7648 -using Base.Test +using Test import Base.convert import ..curmod_name, ..curmod export a9475, foo9475, c7648, foo7648, foo7648_nomethods, Foo7648 @@ -210,7 +210,7 @@ function foo7648_nomethods end mutable struct Foo7648 end module TestModSub9475 - using Base.Test + using Test using ..TestMod7648 import ..curmod_name export a9475, foo9475 @@ -277,7 +277,7 @@ end @test_throws ArgumentError("argument is not a generic function") Base.return_types(===, Tuple{Int, Int}) module TestingExported -using Base.Test +using Test include("testenv.jl") # for curmod_str import Base.isexported global this_is_not_defined diff --git a/test/replcompletions.jl b/test/replcompletions.jl index 68d03c92e2704..0f19d2384f241 100644 --- a/test/replcompletions.jl +++ b/test/replcompletions.jl @@ -183,7 +183,7 @@ let s = "Base.return_types(getin" end # issue #23193: after `using`, identifiers can be prefixed by module names -let s = "using Base.Test, Base.Random" +let s = "using Test, Base.Random" c, r = test_complete(s) @test !("RandomDevice" in c) end diff --git a/test/replutil.jl b/test/replutil.jl index 2389a7ffcd389..56d2dd492dbf8 100644 --- a/test/replutil.jl +++ b/test/replutil.jl @@ -229,7 +229,7 @@ end module __tmp_replutil -using Base.Test +using Test import ..@except_str global + +() = nothing diff --git a/test/rounding.jl b/test/rounding.jl index 513aaa19960ae..247223943a2af 100644 --- a/test/rounding.jl +++ b/test/rounding.jl @@ -1,7 +1,9 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license # Small sanity tests to ensure changing the rounding of float functions work -using Base: Test, MathConstants +using Base.MathConstants + +using Test @testset "Float64 checks" begin # a + b returns a number exactly between prevfloat(1.) and 1., so its diff --git a/test/runtests.jl b/test/runtests.jl index cda2c103313b5..7a49b8697096d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test include("choosetests.jl") include("testenv.jl") @@ -133,63 +133,63 @@ cd(dirname(@__FILE__)) do Errored, and execution continues until the summary at the end of the test run, where the test file is printed out as the "failed expression". =# - o_ts = Base.Test.DefaultTestSet("Overall") - Base.Test.push_testset(o_ts) + o_ts = Test.DefaultTestSet("Overall") + Test.push_testset(o_ts) for res in results - if isa(res[2][1], Base.Test.DefaultTestSet) - Base.Test.push_testset(res[2][1]) - Base.Test.record(o_ts, res[2][1]) - Base.Test.pop_testset() + if isa(res[2][1], Test.DefaultTestSet) + Test.push_testset(res[2][1]) + Test.record(o_ts, res[2][1]) + Test.pop_testset() elseif isa(res[2][1], Tuple{Int,Int}) - fake = Base.Test.DefaultTestSet(res[1]) + fake = Test.DefaultTestSet(res[1]) for i in 1:res[2][1][1] - Base.Test.record(fake, Base.Test.Pass(:test, nothing, nothing, nothing)) + Test.record(fake, Test.Pass(:test, nothing, nothing, nothing)) end for i in 1:res[2][1][2] - Base.Test.record(fake, Base.Test.Broken(:test, nothing)) + Test.record(fake, Test.Broken(:test, nothing)) end - Base.Test.push_testset(fake) - Base.Test.record(o_ts, fake) - Base.Test.pop_testset() - elseif isa(res[2][1], RemoteException) && isa(res[2][1].captured.ex, Base.Test.TestSetException) + Test.push_testset(fake) + Test.record(o_ts, fake) + Test.pop_testset() + elseif isa(res[2][1], RemoteException) && isa(res[2][1].captured.ex, Test.TestSetException) println("Worker $(res[2][1].pid) failed running test $(res[1]):") Base.showerror(STDOUT,res[2][1].captured) - fake = Base.Test.DefaultTestSet(res[1]) + fake = Test.DefaultTestSet(res[1]) for i in 1:res[2][1].captured.ex.pass - Base.Test.record(fake, Base.Test.Pass(:test, nothing, nothing, nothing)) + Test.record(fake, Test.Pass(:test, nothing, nothing, nothing)) end for i in 1:res[2][1].captured.ex.broken - Base.Test.record(fake, Base.Test.Broken(:test, nothing)) + Test.record(fake, Test.Broken(:test, nothing)) end for t in res[2][1].captured.ex.errors_and_fails - Base.Test.record(fake, t) + Test.record(fake, t) end - Base.Test.push_testset(fake) - Base.Test.record(o_ts, fake) - Base.Test.pop_testset() + Test.push_testset(fake) + Test.record(o_ts, fake) + Test.pop_testset() elseif isa(res[2][1], Exception) # If this test raised an exception that is not a remote testset exception, # i.e. not a RemoteException capturing a TestSetException that means # the test runner itself had some problem, so we may have hit a segfault, # deserialization errors or something similar. Record this testset as Errored. - fake = Base.Test.DefaultTestSet(res[1]) - Base.Test.record(fake, Base.Test.Error(:test_error, res[1], res[2][1], [])) - Base.Test.push_testset(fake) - Base.Test.record(o_ts, fake) - Base.Test.pop_testset() + fake = Test.DefaultTestSet(res[1]) + Test.record(fake, Test.Error(:test_error, res[1], res[2][1], [])) + Test.push_testset(fake) + Test.record(o_ts, fake) + Test.pop_testset() else error(string("Unknown result type : ", typeof(res))) end end println() - Base.Test.print_test_results(o_ts,1) + Test.print_test_results(o_ts,1) if !o_ts.anynonpass println(" \033[32;1mSUCCESS\033[0m") else println(" \033[31;1mFAILURE\033[0m\n") skipped > 0 && println("$skipped test", skipped > 1 ? "s were" : " was", " skipped due to failure.\n") - Base.Test.print_test_errors(o_ts) + Test.print_test_errors(o_ts) throw(Test.FallbackTestSetException("Test run finished with errors")) end end diff --git a/test/serialize.jl b/test/serialize.jl index 0be4923142896..a9d0fc9ca14a2 100644 --- a/test/serialize.jl +++ b/test/serialize.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test # Check that serializer hasn't gone out-of-frame @test Serializer.sertag(Symbol) == 1 @@ -401,7 +401,7 @@ end # issue #13452 module Test13452 -using Base.Test +using Test module Shell export foo diff --git a/test/show.jl b/test/show.jl index f466136719b53..8db3ce1da392b 100644 --- a/test/show.jl +++ b/test/show.jl @@ -743,8 +743,8 @@ end let repr = sprint(dump, sin) @test repr == "sin (function of type typeof(sin))\n" end -let repr = sprint(dump, Base.Test) - @test repr == "Module Base.Test\n" +let repr = sprint(dump, Test) + @test repr == "Module Test\n" end let a = Array{Any}(10000) a[2] = "elemA" diff --git a/test/stacktraces.jl b/test/stacktraces.jl index ee93ab6b79d7f..55b5ea1f1678c 100644 --- a/test/stacktraces.jl +++ b/test/stacktraces.jl @@ -81,7 +81,7 @@ let ct = current_task() end module inlined_test -using Base.Test +using Test @inline g(x) = (y = throw("a"); y) # the inliner does not insert the proper markers when inlining a single expression @inline h(x) = (y = g(x); y) # this test could be extended to check for that if we switch to linear representation f(x) = (y = h(x); y) diff --git a/test/staged.jl b/test/staged.jl index 05cb9f0b39e3e..7bcd41a478ced 100644 --- a/test/staged.jl +++ b/test/staged.jl @@ -138,7 +138,7 @@ end # @generated functions that throw (shouldn't segfault or throw) module TestGeneratedThrow - using Base.Test + using Test @generated function bar(x) error("I'm not happy with type $x") diff --git a/test/statistics.jl b/test/statistics.jl index b7af59cbefe1e..6d1f95297dd59 100644 --- a/test/statistics.jl +++ b/test/statistics.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test # middle diff --git a/test/strings/util.jl b/test/strings/util.jl index f921f74b209a3..79918bd76aabd 100644 --- a/test/strings/util.jl +++ b/test/strings/util.jl @@ -217,7 +217,7 @@ end # test replace with a count for String and GenericString # check that replace is a no-op if count==0 - for s in ["aaa", Base.Test.GenericString("aaa")] + for s in ["aaa", Test.GenericString("aaa")] # @test replace("aaa", 'a', 'z', 0) == "aaa" # enable when undeprecated @test replace(s, 'a', 'z', 1) == "zaa" @test replace(s, 'a', 'z', 2) == "zza" diff --git a/test/subarray.jl b/test/subarray.jl index 890a25e3fd417..980e83a35dfe1 100644 --- a/test/subarray.jl +++ b/test/subarray.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test ######## Utilities ########### diff --git a/test/subtype.jl b/test/subtype.jl index fd6fb3b9b5147..0eb27151bfd09 100644 --- a/test/subtype.jl +++ b/test/subtype.jl @@ -1,7 +1,7 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license using Base.Bottom -using Base.Test +using Test macro UnionAll(var, expr) Expr(:where, esc(expr), esc(var)) diff --git a/test/test_exec.jl b/test/test_exec.jl index 529f9f63ea493..182fda1abab63 100644 --- a/test/test_exec.jl +++ b/test/test_exec.jl @@ -1,5 +1,5 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test # Check that the fallback test set throws immediately @test 1 == 2 diff --git a/test/testdefs.jl b/test/testdefs.jl index bc214dab6fcf4..02b2f2c3cc10d 100644 --- a/test/testdefs.jl +++ b/test/testdefs.jl @@ -1,8 +1,10 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license +using Test + function runtests(name, isolate=true) - old_print_setting = Base.Test.TESTSET_PRINT_ENABLE[] - Base.Test.TESTSET_PRINT_ENABLE[] = false + old_print_setting = Test.TESTSET_PRINT_ENABLE[] + Test.TESTSET_PRINT_ENABLE[] = false try if isolate # Simple enough to type and random enough so that no one will hard @@ -12,7 +14,7 @@ function runtests(name, isolate=true) else m = Main end - @eval(m, using Base.Test) + @eval(m, using Test) ex = quote @timed @testset $"$name" begin include($"$name.jl") @@ -21,7 +23,7 @@ function runtests(name, isolate=true) res_and_time_data = eval(m, ex) rss = Sys.maxrss() #res_and_time_data[1] is the testset - passes,fails,error,broken,c_passes,c_fails,c_errors,c_broken = Base.Test.get_test_counts(res_and_time_data[1]) + passes,fails,error,broken,c_passes,c_fails,c_errors,c_broken = Test.get_test_counts(res_and_time_data[1]) if res_and_time_data[1].anynonpass == false res_and_time_data = ( (passes+c_passes,broken+c_broken), @@ -32,7 +34,7 @@ function runtests(name, isolate=true) end vcat(collect(res_and_time_data), rss) finally - Base.Test.TESTSET_PRINT_ENABLE[] = old_print_setting + Test.TESTSET_PRINT_ENABLE[] = old_print_setting end end diff --git a/test/threads.jl b/test/threads.jl index af29f80e74257..278fa9181c445 100644 --- a/test/threads.jl +++ b/test/threads.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test using Base.Threads # threading constructs @@ -159,7 +159,7 @@ end end module M14726_2 -using Base.Test +using Test using Base.Threads @threads for i in 1:100 # Make sure current module is the same as the one on the thread that diff --git a/test/workspace.jl b/test/workspace.jl index b65f09df63a0e..4b8c8bf18273f 100644 --- a/test/workspace.jl +++ b/test/workspace.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license -using Base.Test +using Test script = """ # Issue #11948 @@ -48,7 +48,7 @@ mktempdir() do dir end """) write(joinpath(dir, "testdriver.jl"), """ - using Base.Test + using Test insert!(LOAD_PATH, 1, $(repr(dir))) insert!(Base.LOAD_CACHE_PATH, 1, $(repr(dir))) @test !isdefined(Main, :f22101)