Skip to content

Commit

Permalink
A few fixes for 0.6
Browse files Browse the repository at this point in the history
* `num` and `den` rename
* `takebuf_array` rename
* Fix `$` in the test
  • Loading branch information
yuyichao committed Nov 26, 2016
1 parent e3f2fc9 commit c3e42bc
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ Currently, the `@compat` macro supports the following syntaxes:

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

* `num` and `den` are now `numerator` and `denominator` [#19246](https://github.com/JuliaLang/julia/pull/19246).

* `takebuf_array` is now a method of `take!`. `takebuf_string(io)` becomes `String(take!(io))` [#19088](https://github.com/JuliaLang/julia/pull/19088).

## New macros

* `@static` has been added [#16219](https://github.com/JuliaLang/julia/pull/16219).
Expand Down
12 changes: 12 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1686,4 +1686,16 @@ if !isdefined(Base, :xor)
export xor,
end

# julia#19246
if !isdefined(Base, :numerator)
const numerator = num
const denominator = den
export numerator, denominator
end

# julia#19088
if VERSION < v"0.6.0-dev.1256"
Base.take!(io::Base.AbstractIOBuffer) = takebuf_array(io)
end

end # module
18 changes: 15 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ mktempdir() do dir
verbose && println("$name write(::IOBuffer, ...)")
@compat to = IOBuffer(UInt8[convert(UInt8, _) for _ in text], false, true)
write(to, io())
@test takebuf_string(to) == text
@test String(take!(to)) == text

cleanup()
end
Expand Down Expand Up @@ -1106,7 +1106,7 @@ end

for (Fun, func) in [(:AndFun, :&),
(:OrFun, :|),
(:XorFun, :$),
(:XorFun, :),
(:AddFun, :+),
(:DotAddFun, :.+),
(:SubFun, :-),
Expand Down Expand Up @@ -1250,7 +1250,7 @@ end

let io = IOBuffer(), s = "hello"
unsafe_write(io, pointer(s), length(s))
@test takebuf_string(io) == s
@test String(take!(io)) == s
end

@static if VERSION v"0.4"
Expand Down Expand Up @@ -1512,3 +1512,15 @@ end

@test xor(1,5) == 4
@test 1 5 == 4

# julia#19246
@test numerator(1//2) === 1
@test denominator(1//2) === 2

# julia#19088
let io = IOBuffer()
write(io, "aaa")
@test take!(io) == UInt8['a', 'a', 'a']
write(io, "bbb")
@test String(take!(io)) == "bbb"
end

0 comments on commit c3e42bc

Please sign in to comment.