Skip to content

Commit

Permalink
Add better messages and tests
Browse files Browse the repository at this point in the history
Fix redirection of stderr
  • Loading branch information
ScottPJones committed Jul 14, 2015
1 parent eaef742 commit 46618cd
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 14 deletions.
51 changes: 38 additions & 13 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -537,18 +537,6 @@ function start_timer(t, d, r)
error("start_timer is deprecated. Use Timer(callback, delay, repeat) instead.")
end

# 11551
function utf16_is_surrogate(chr::UInt16)
depwarn("utf16_is_surrogate was undocumented and unexported, and has been removed",
:utf16_is_surrogate)
Base.is_surrogate_codeunit(chr)
end
function utf16_get_supplementary(lead::UInt16, trail::UInt16)
depwarn("utf16_get_supplementary was undocumented and unexported, and has been removed",
:utf16_get_supplementary)
Base.get_supplementary(lead, trail)
end

const UnionType = Union
export UnionType

Expand All @@ -561,6 +549,44 @@ end

export MathConst, @math_const

# 11551
function utf16_is_surrogate(chr::UInt16)
depwarn("""
Base.utf16_is_surrogate was undocumented and unexported,
and has been removed. Use Base.is_surrogate_codeunit(chr::Unsigned) instead,
however it is also undocumented and unexported, and may change in the future.
""",
symbol("utf16_is_surrogate"))
Base.is_surrogate_codeunit(chr)
end
function utf16_is_lead(chr::UInt16)
depwarn("""
Base.utf16_is_lead was undocumented and unexported,
and has been removed. Use Base.is_surrogate_lead(chr::Unsigned) instead,
however is is also undocumented and unexported, and may change in the future.
""",
symbol("utf16_is_lead"))
Base.is_surrogate_lead(chr)
end
function utf16_is_trail(chr::UInt16)
depwarn("""
Base.utf16_is_trail was undocumented and unexported,
and has been removed. Use Base.is_surrogate_trail(chr::Unsigned) instead,
however it is also undocumented and unexported, and may change in the future.
""",
symbol("utf16_is_trail"))
Base.is_surrogate_trail(chr)
end
function utf16_get_supplementary(lead::UInt16, trail::UInt16)
depwarn("""
Base.utf16_get_supplementary was undocumented and unexported,
and has been removed. Use Base.get_supplementary(lead::Unsigned, trail::Unsigned) instead,
however it is also undocumented and unexported, and may change in the future.
""",
symbol("utf16_get_supplementary"))
Base.get_supplementary(lead, trail)
end

# 11280, mmap

export msync
Expand Down Expand Up @@ -647,7 +673,6 @@ end
@deprecate mmap_bitarray{N}(::Type{Bool}, dims::NTuple{N,Integer}, s::IOStream, offset::FileOffset=position(s)) mmap(s, BitArray, dims, offset)
@deprecate mmap_bitarray{N}(dims::NTuple{N,Integer}, s::IOStream, offset=position(s)) mmap(s, BitArray, dims, offset)


# T[a:b] and T[a:s:b]
@noinline function getindex{T<:Union{Char,Number}}(::Type{T}, r::Range)
depwarn("T[a:b] concatenation is deprecated; use T[a:b;] instead", :getindex)
Expand Down
2 changes: 1 addition & 1 deletion test/choosetests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
"operators", "path", "ccall", "parse", "deprecated",
"bigint", "sorting", "statistics", "spawn", "backtrace",
"priorityqueue", "file", "mmap", "version", "resolve",
"pollfd", "mpfr", "broadcast", "complex", "socket",
Expand Down
19 changes: 19 additions & 0 deletions test/deprecated.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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)
else
olderr = STDERR
try
rd, wr = redirect_stderr()
@test Base.utf16_is_surrogate(0xdc00) == true
@test Base.utf16_is_lead(0xd800) == true
@test Base.utf16_is_trail(0xdc00) == true
@test Base.utf16_get_supplementary(0xd800, 0xdc00) == 0x10000
finally
redirect_stderr(olderr)
end
end

0 comments on commit 46618cd

Please sign in to comment.