Skip to content

Commit f59e8f5

Browse files
committed
tests
1 parent 80d6b5a commit f59e8f5

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/Cobweb.jl

+2
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,11 @@ Base.push!(o::Node, x) = push!(children(o), x)
7777
Base.append!(o::Node, x) = append!(children(o), x)
7878
Base.deleteat!(o::Node, x) = deleteat!(children(o), x)
7979
Base.pop!(o::Node) = pop!(children(o))
80+
Base.popat!(o::Node, i) = popat!(children(o), i)
8081
Base.popfirst!(o::Node) = popfirst!(children(o))
8182
Base.splice!(o::Node, i::Integer) = splice!(children(o), i)
8283
Base.splice!(o::Node, i::Integer, x) = splice!(children(o), i, x)
84+
Base.empty!(o::Node) = empty!(children(o))
8385

8486

8587

test/runtests.jl

+22-1
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,32 @@ end
4848
@test get(node, :id2, 1) == 1
4949
get!(node, :id2, "myid2")
5050
@test propertynames(node) == [:id, :class, :id2]
51-
@test node[end] == "content"
51+
@test node[1] == node[end] == "content"
52+
# push!
5253
push!(node, h.span("child"))
5354
@test node[end] == h.span("child")
55+
# append!
5456
append!(node, [h.span("child2"), h.span("child3")])
5557
@test node[end] == h.span("child3")
58+
# empty!
59+
empty!(node)
60+
@test isempty(node)
61+
# pop!
62+
push!(node, "test")
63+
@test pop!(node) == "test"
64+
@test isempty(node)
65+
push!(node, "test")
66+
# popat!
67+
push!(node, "test")
68+
@test popat!(node, 1) == "test"
69+
# deleteat!
70+
deleteat!(node, 1)
71+
@test isempty(node)
72+
# splice!
73+
push!(node, "test")
74+
@test splice!(node, 1, ["new"]) == "test"
75+
@test splice!(node, 1) == "new"
76+
@test isempty(node)
5677
end
5778
#-----------------------------------------------------------------------------# indexing
5879
@testset "get/setindex" begin

0 commit comments

Comments
 (0)