diff --git a/base/deprecated.jl b/base/deprecated.jl index 8d5b220ef0f82..18ee71a6c1525 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -539,6 +539,55 @@ end export MathConst, @math_const +# 11551 + +macro unexportedwarn(old, new) + meta = Expr(:meta, :noinline) + if isa(old,Symbol) + oldname = Expr(:quote, old) + newname = Expr(:quote, new) + Expr(:toplevel, + :(function $old(args...) + $meta + depwarn(string("Base.", $oldname, " was undocumented and unexported,\n", + "and has been removed. Use ", $newname, " instead,\n", + "however it is also undocumented and unexported, and may change in the future."), + $oldname) + $new(args...) + end)) + elseif isa(old,Expr) && old.head == :call + oldcall = sprint(io->show_unquoted(io,old)) + newcall = sprint(io->show_unquoted(io,new)) + oldsym = if isa(old.args[1],Symbol) + old.args[1] + elseif isa(old.args[1],Expr) && old.args[1].head == :curly + old.args[1].args[1] + else + error("invalid usage of @unexportedwarn") + end + oldname = Expr(:quote, oldsym) + Expr(:toplevel, + :($(esc(old)) = begin + $meta + depwarn(string("Base.", $oldcall, " was undocumented and unexported,\n", + "and has been removed. Use ", $newcall, " instead,\n", + "however it is also undocumented and unexported, and may change in the future."), + $oldname) + $(esc(new)) + end)) + else + error("invalid usage of @unexportedwarn") + end +end + +@unexportedwarn utf16_is_surrogate(ch::Uint16) Base.is_surrogate_codeunit(ch) +@unexportedwarn utf16_is_lead(ch::UInt16) Base.is_surrogate_lead(ch) +@unexportedwarn utf16_is_trail(ch::UInt16) Base.is_surrogate_trail(ch) +@unexportedwarn utf16_get_supplementary(lead::UInt16, trail::UInt16) Base.get_supplementary(lead, trail) + +@unexportedwarn is_utf8_start(ch::UInt8) !Base.is_valid_continuation(ch) +@unexportedwarn is_utf8_continuation(ch::UInt8) Base.is_valid_continuation(ch) + # 11280, mmap export msync diff --git a/test/choosetests.jl b/test/choosetests.jl index 2a2eecfcbe248..1766fd75ac415 100644 --- a/test/choosetests.jl +++ b/test/choosetests.jl @@ -21,7 +21,7 @@ function choosetests(choices = []) "arrayops", "tuple", "subarray", "reduce", "reducedim", "random", "abstractarray", "intfuncs", "simdloop", "blas", "sparse", "bitarray", "copy", "math", "fastmath", "functional", - "operators", "path", "ccall", "parse", "loading", + "operators", "path", "ccall", "parse", "loading", "deprecated", "bigint", "sorting", "statistics", "spawn", "backtrace", "priorityqueue", "file", "mmap", "version", "resolve", "pollfd", "mpfr", "broadcast", "complex", "socket", diff --git a/test/deprecated.jl b/test/deprecated.jl new file mode 100644 index 0000000000000..ec6cc147079aa --- /dev/null +++ b/test/deprecated.jl @@ -0,0 +1,23 @@ +# This file is a part of Julia. License is MIT: http://julialang.org/license + +if (Base.JLOptions()).depwarn > 1 + @test_throws ErrorException Base.utf16_is_surrogate(0xdc00) + @test_throws ErrorException Base.utf16_is_lead(0xd800) + @test_throws ErrorException Base.utf16_is_trail(0xdc00) + @test_throws ErrorException Base.utf16_get_supplementary(0xd800, 0xdc00) + @test_throws ErrorException Base.is_utf8_start(0x40) + @test_throws ErrorException Base.is_utf8_continuation(0x90) +else + olderr = STDERR + try + rd, wr = redirect_stderr() + @test Base.utf16_is_surrogate(0xdc00) + @test Base.utf16_is_lead(0xd800) + @test Base.utf16_is_trail(0xdc00) + @test Base.utf16_get_supplementary(0xd800, 0xdc00) == 0x10000 + @test Base.is_utf8_start(0x40) + @test Base.is_utf8_continuation(0x90) + finally + redirect_stderr(olderr) + end +end