Skip to content

Commit 2d73774

Browse files
committed
Add better messages and tests
Fix redirection of stderr
1 parent 77cb47b commit 2d73774

File tree

3 files changed

+59
-13
lines changed

3 files changed

+59
-13
lines changed

base/deprecated.jl

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -538,18 +538,6 @@ function start_timer(t, d, r)
538538
error("start_timer is deprecated. Use Timer(callback, delay, repeat) instead.")
539539
end
540540

541-
# 11551
542-
function utf16_is_surrogate(chr::UInt16)
543-
depwarn("utf16_is_surrogate was undocumented and unexported, and has been removed",
544-
:utf16_is_surrogate)
545-
Base.is_surrogate_codeunit(chr)
546-
end
547-
function utf16_get_supplementary(lead::UInt16, trail::UInt16)
548-
depwarn("utf16_get_supplementary was undocumented and unexported, and has been removed",
549-
:utf16_get_supplementary)
550-
Base.get_supplementary(lead, trail)
551-
end
552-
553541
const UnionType = Union
554542
export UnionType
555543

@@ -562,6 +550,44 @@ end
562550

563551
export MathConst, @math_const
564552

553+
# 11551
554+
function utf16_is_surrogate(chr::UInt16)
555+
depwarn("""
556+
Base.utf16_is_surrogate was undocumented and unexported,
557+
and has been removed. Use Base.is_surrogate_codeunit(chr::Unsigned) instead,
558+
however it is also undocumented and unexported, and may change in the future.
559+
""",
560+
symbol("utf16_is_surrogate"))
561+
Base.is_surrogate_codeunit(chr)
562+
end
563+
function utf16_is_lead(chr::UInt16)
564+
depwarn("""
565+
Base.utf16_is_lead was undocumented and unexported,
566+
and has been removed. Use Base.is_surrogate_lead(chr::Unsigned) instead,
567+
however is is also undocumented and unexported, and may change in the future.
568+
""",
569+
symbol("utf16_is_lead"))
570+
Base.is_surrogate_lead(chr)
571+
end
572+
function utf16_is_trail(chr::UInt16)
573+
depwarn("""
574+
Base.utf16_is_trail was undocumented and unexported,
575+
and has been removed. Use Base.is_surrogate_trail(chr::Unsigned) instead,
576+
however it is also undocumented and unexported, and may change in the future.
577+
""",
578+
symbol("utf16_is_trail"))
579+
Base.is_surrogate_trail(chr)
580+
end
581+
function utf16_get_supplementary(lead::UInt16, trail::UInt16)
582+
depwarn("""
583+
Base.utf16_get_supplementary was undocumented and unexported,
584+
and has been removed. Use Base.get_supplementary(lead::Unsigned, trail::Unsigned) instead,
585+
however it is also undocumented and unexported, and may change in the future.
586+
""",
587+
symbol("utf16_get_supplementary"))
588+
Base.get_supplementary(lead, trail)
589+
end
590+
565591
# 11280, mmap
566592

567593
export msync
@@ -647,3 +673,4 @@ end
647673

648674
@deprecate mmap_bitarray{N}(::Type{Bool}, dims::NTuple{N,Integer}, s::IOStream, offset::FileOffset=position(s)) mmap(s, BitArray, dims, offset)
649675
@deprecate mmap_bitarray{N}(dims::NTuple{N,Integer}, s::IOStream, offset=position(s)) mmap(s, BitArray, dims, offset)
676+

test/choosetests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function choosetests(choices = [])
2020
"arrayops", "tuple", "subarray", "reduce", "reducedim", "random",
2121
"abstractarray", "intfuncs", "simdloop", "blas", "sparse",
2222
"bitarray", "copy", "math", "fastmath", "functional",
23-
"operators", "path", "ccall", "unicode",
23+
"operators", "path", "ccall", "unicode", "deprecated",
2424
"bigint", "sorting", "statistics", "spawn", "backtrace",
2525
"priorityqueue", "file", "mmap", "version", "resolve",
2626
"pollfd", "mpfr", "broadcast", "complex", "socket",

test/deprecated.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# This file is a part of Julia. License is MIT: http://julialang.org/license
2+
3+
if (Base.JLOptions()).depwarn > 1
4+
@test_throws ErrorException Base.utf16_is_surrogate(0xdc00)
5+
@test_throws ErrorException Base.utf16_is_lead(0xd800)
6+
@test_throws ErrorException Base.utf16_is_trail(0xdc00)
7+
@test_throws ErrorException Base.utf16_get_supplementary(0xd800, 0xdc00)
8+
else
9+
olderr = STDERR
10+
try
11+
rd, wr = redirect_stderr()
12+
@test Base.utf16_is_surrogate(0xdc00) == true
13+
@test Base.utf16_is_lead(0xd800) == true
14+
@test Base.utf16_is_trail(0xdc00) == true
15+
@test Base.utf16_get_supplementary(0xd800, 0xdc00) == 0x10000
16+
finally
17+
redirect_stderr(olderr)
18+
end
19+
end

0 commit comments

Comments
 (0)