Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unbreak Julia 1.0 #110

Merged
merged 2 commits into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1.0' # 1.0 is only partially tested; in the next breaking release, add [compat] 'julia = "1.6"' and drop this
- '1.6'
- '1'
- 'nightly'
Expand Down
4 changes: 1 addition & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name = "AbstractTrees"
uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
version = "0.4.1"
authors = ["Keno Fischer <[email protected]>"]

[deps]
version = "0.4.2"

[compat]
julia = "1"
Expand Down
5 changes: 5 additions & 0 deletions src/AbstractTrees.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ include("iteration.jl")
include("builtins.jl")
include("printing.jl")

# Julia 1.0 support (delete when we no longer support it)
if !isdefined(Base, :isnothing)
isnothing(x) = x === nothing
end


#interface
export ParentLinks, StoredParents, ImplicitParents
Expand Down
2 changes: 1 addition & 1 deletion src/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function is not available.
Equivalence is established with the `equiv` function. Note that new methods should also define `equiv` or calls
may fall back to the default method.
"""
isdescendant(node1, node2; equiv=(≡)) = !equiv(node1, node2) && intree(node1, node2; equiv)
isdescendant(node1, node2; equiv=(≡)) = !equiv(node1, node2) && intree(node1, node2; equiv=equiv)


"""
Expand Down
4 changes: 2 additions & 2 deletions src/printing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ function print_tree(printnode::Function, io::IO, node;
end

print_tree(printnode, io, child;
maxdepth, indicate_truncation, charset, printkeys,
depth=depth+1, prefix=child_prefix
maxdepth=maxdepth, indicate_truncation=indicate_truncation, charset=charset,
printkeys=printkeys, depth=depth+1, prefix=child_prefix
)
end
end
Expand Down
1 change: 1 addition & 0 deletions test/examples.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Ensure that we can run all files in the examples directory with no errors.
# Note: fstree doesn't work on Julia 1.0

exampledir = joinpath(dirname(@__DIR__), "examples")
examples = readdir(exampledir)
Expand Down
3 changes: 3 additions & 0 deletions test/examples/binarytree.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using AbstractTrees

if !isdefined(Base, :isnothing) # Julia 1.0 support
using AbstractTrees: isnothing
end

mutable struct BinaryNode{T}
data::T
Expand Down
3 changes: 2 additions & 1 deletion test/examples/fstree.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ AbstractTrees.printnode(io::IO, d::Directory) = print(io, basename(d.path))
AbstractTrees.printnode(io::IO, f::File) = print(io, basename(f.path))

function mk_tree_test_dir(f, parentdir=tempdir(); prefix="jl_")
mktempdir(parentdir; prefix) do path
# While Julia 1.0 can parse this, `mktempdir` does not support the `prefix` kw
mktempdir(parentdir; prefix=prefix) do path
cd(path) do
open(io -> write(io, "test1"), "f1"; write=true)
mkdir("A")
Expand Down
6 changes: 4 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ using AbstractTrees, Test

@testset "Builtins" begin include("builtins.jl") end
@testset "Custom tree types" begin include("trees.jl") end
@testset "Printing" begin include("printing.jl") end

if Base.VERSION >= v"1.6"
# Printing tests use `findall` variants that are not supported on Julia 1.0
@testset "Printing" begin include("printing.jl") end
end
2 changes: 1 addition & 1 deletion test/trees.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ end
include(joinpath(@__DIR__,"examples","fstree.jl"))

@testset "FSNode" begin
mk_tree_test_dir() do path
Base.VERSION >= v"1.6" && mk_tree_test_dir() do path
tree = Directory(".")

ls = nodevalue.((collect ∘ Leaves)(tree))
Expand Down