Skip to content

Commit

Permalink
Compat.eachline with keep kwarg
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre committed May 14, 2018
1 parent 9ae1261 commit 6c5ef40
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ Currently, the `@compat` macro supports the following syntaxes:

* `Compat.readline` with `keep` keyword argument ([#25646])

* `Compat.eachline` with `keep` keyword argument ([#25646])

* `take!` method for `Task`s since some functions now return `Channel`s instead of `Task`s ([#19841])

* The `isabstract`, `parameter_upper_bound`, `typename` reflection methods were added in Julia 0.6. This package re-exports these from the `Compat.TypeUtils` submodule. On earlier versions of julia, that module contains the same functions, but operating on the pre-0.6 type system representation.
Expand Down
1 change: 1 addition & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ end
# not exported
# chomp parameter preserved for compatibility with earliear Compat versions
readline(s::IO=STDIN; chomp::Bool=true, keep::Bool=!chomp) = Base.readline(s; chomp=!keep)
eachline(s; chomp::Bool=true, keep::Bool=!chomp) = Base.eachline(s; chomp=!keep)
end

# https://github.com/JuliaLang/julia/pull/18727
Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,9 @@ end
@test Compat.readline(IOBuffer("Hello, World!\n")) == "Hello, World!"
@test Compat.readline(IOBuffer("x\n"), keep=false) == "x"
@test Compat.readline(IOBuffer("x\n"), keep=true) == "x\n"
@test collect(Compat.eachline(IOBuffer("x\ny"))) == ["x", "y"]
@test collect(Compat.eachline(IOBuffer("x\ny"), keep=false)) == ["x", "y"]
@test collect(Compat.eachline(IOBuffer("x\ny"), keep=true)) == ["x\n", "y"]

# PR 18727
let
Expand Down

0 comments on commit 6c5ef40

Please sign in to comment.