Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ReubenJ committed Nov 26, 2024
1 parent f6cea02 commit e3a5874
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
6 changes: 0 additions & 6 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,3 @@ AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
[compat]
AbstractTrees = "0.4.5"
julia = "^1.8"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
4 changes: 4 additions & 0 deletions src/HerbCore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@ export
have_same_shape, AbstractConstraint,
AbstractGrammar

# AbstractTrees interface
children,
nodevalue

end # module HerbCore
3 changes: 3 additions & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
10 changes: 10 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
using AbstractTrees: children, nodevalue, treeheight
using HerbCore
using Test

@testset "HerbCore.jl" verbose=true begin
@testset "AbstractTrees Interface" begin
@show typeof(nodevalue(RuleNode(1)))
@test nodevalue(RuleNode(1)) == 1
@test isempty(children(RuleNode(1)))
@test length(children(RuleNode(1, [RuleNode(2), RuleNode(2)]))) == 2
@test treeheight(RuleNode(1)) == 0
@test treeheight(RuleNode(1, [RuleNode(2), RuleNode(2)])) == 1
end

@testset "RuleNode tests" begin
@testset "Equality tests" begin
@test RuleNode(1) == RuleNode(1)
Expand Down

0 comments on commit e3a5874

Please sign in to comment.