Skip to content

Commit 3541c2d

Browse files
yuyichaostevengj
authored andcommitted
A few fixes for 0.6 (JuliaLang#290)
* `num` and `den` rename * `takebuf_array` rename * Fix `$` in the test
1 parent e3f2fc9 commit 3541c2d

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ Currently, the `@compat` macro supports the following syntaxes:
126126

127127
* `$` is now `xor` or `` [#18977](https://github.com/JuliaLang/julia/pull/18977).
128128

129+
* `num` and `den` are now `numerator` and `denominator` [#19246](https://github.com/JuliaLang/julia/pull/19246).
130+
131+
* `takebuf_array` is now a method of `take!`. `takebuf_string(io)` becomes `String(take!(io))` [#19088](https://github.com/JuliaLang/julia/pull/19088).
132+
129133
## New macros
130134

131135
* `@static` has been added [#16219](https://github.com/JuliaLang/julia/pull/16219).

src/Compat.jl

+12
Original file line numberDiff line numberDiff line change
@@ -1686,4 +1686,16 @@ if !isdefined(Base, :xor)
16861686
export xor,
16871687
end
16881688

1689+
# julia#19246
1690+
if !isdefined(Base, :numerator)
1691+
const numerator = num
1692+
const denominator = den
1693+
export numerator, denominator
1694+
end
1695+
1696+
# julia#19088
1697+
if VERSION < v"0.6.0-dev.1256"
1698+
Base.take!(io::Base.AbstractIOBuffer) = takebuf_array(io)
1699+
end
1700+
16891701
end # module

test/runtests.jl

+15-3
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ mktempdir() do dir
849849
verbose && println("$name write(::IOBuffer, ...)")
850850
@compat to = IOBuffer(UInt8[convert(UInt8, _) for _ in text], false, true)
851851
write(to, io())
852-
@test takebuf_string(to) == text
852+
@test String(take!(to)) == text
853853

854854
cleanup()
855855
end
@@ -1106,7 +1106,7 @@ end
11061106

11071107
for (Fun, func) in [(:AndFun, :&),
11081108
(:OrFun, :|),
1109-
(:XorFun, :$),
1109+
(:XorFun, :),
11101110
(:AddFun, :+),
11111111
(:DotAddFun, :.+),
11121112
(:SubFun, :-),
@@ -1250,7 +1250,7 @@ end
12501250

12511251
let io = IOBuffer(), s = "hello"
12521252
unsafe_write(io, pointer(s), length(s))
1253-
@test takebuf_string(io) == s
1253+
@test String(take!(io)) == s
12541254
end
12551255

12561256
@static if VERSION v"0.4"
@@ -1512,3 +1512,15 @@ end
15121512

15131513
@test xor(1,5) == 4
15141514
@test 1 5 == 4
1515+
1516+
# julia#19246
1517+
@test numerator(1//2) === 1
1518+
@test denominator(1//2) === 2
1519+
1520+
# julia#19088
1521+
let io = IOBuffer()
1522+
write(io, "aaa")
1523+
@test take!(io) == UInt8['a', 'a', 'a']
1524+
write(io, "bbb")
1525+
@test String(take!(io)) == "bbb"
1526+
end

0 commit comments

Comments
 (0)