From af680ed8befc205f8d3ddf46e66b3a54716f6004 Mon Sep 17 00:00:00 2001 From: Markus Hauru Date: Fri, 18 Oct 2024 16:58:43 +0100 Subject: [PATCH 1/5] Add a test for rulesoftype --- test/runtests.jl | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index fd344cb..9c67a67 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -65,6 +65,36 @@ using Test @test node_depth(rulenode, RuleNode(100)) == 0 end + @testset "rulesoftype" begin + #= 1 + 2 3 4 + 5 6 + 7 9 + 10 + =# + rulenode = RuleNode(1, + [ + RuleNode(2), + RuleNode(3), + RuleNode(4, + [ + RuleNode(5, + [RuleNode(7)] + ), + RuleNode(6, + [RuleNode(9, [RuleNode(10)])] + ) + ] + ) + ] + ) + @test rulesoftype(rulenode, Set((11, 12))) == Set{Int}() + @test rulesoftype(rulenode, Set((1, 3, 7, 9, 10, 15, 23))) == Set((1, 3, 7, 9, 10 )) + @test rulesoftype(rulenode, Set(1)) == Set(1) + @test rulesoftype(rulenode, Set{Int}()) == Set{Int}() + @test rulesoftype(RuleNode(1), Set((1, 2))) == Set(1) + end + @testset "rule sequence" begin #= 1 From 440e5a689cb75435caa7d84033b1356dfc84a100 Mon Sep 17 00:00:00 2001 From: Markus Hauru Date: Mon, 28 Oct 2024 08:59:42 +0000 Subject: [PATCH 2/5] Code formatting --- test/runtests.jl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 9c67a67..29e4ce9 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -72,24 +72,24 @@ using Test 7 9 10 =# - rulenode = RuleNode(1, + rulenode = RuleNode( + 1, [ RuleNode(2), RuleNode(3), - RuleNode(4, + RuleNode( + 4, [ - RuleNode(5, - [RuleNode(7)] - ), - RuleNode(6, - [RuleNode(9, [RuleNode(10)])] - ) + RuleNode(5, [RuleNode(7)]), + RuleNode( 6, [RuleNode(9, [RuleNode(10)])]), ] - ) + ), ] ) @test rulesoftype(rulenode, Set((11, 12))) == Set{Int}() - @test rulesoftype(rulenode, Set((1, 3, 7, 9, 10, 15, 23))) == Set((1, 3, 7, 9, 10 )) + arg = Set((1, 3, 7, 9, 10, 15, 23)) + expected = Set((1, 3, 7, 9, 10)) + @test rulesoftype(rulenode, arg) == expected @test rulesoftype(rulenode, Set(1)) == Set(1) @test rulesoftype(rulenode, Set{Int}()) == Set{Int}() @test rulesoftype(RuleNode(1), Set((1, 2))) == Set(1) From b54af27d347d227606a1d60085ad50de1153892e Mon Sep 17 00:00:00 2001 From: Markus Hauru Date: Mon, 28 Oct 2024 09:06:47 +0000 Subject: [PATCH 3/5] More code formatting --- test/runtests.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 29e4ce9..f37256a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -81,9 +81,9 @@ using Test 4, [ RuleNode(5, [RuleNode(7)]), - RuleNode( 6, [RuleNode(9, [RuleNode(10)])]), + RuleNode(6, [RuleNode(9, [RuleNode(10)])]) ] - ), + ) ] ) @test rulesoftype(rulenode, Set((11, 12))) == Set{Int}() From 582c257de05afc643741a1debe703184baeb58ff Mon Sep 17 00:00:00 2001 From: Markus Hauru Date: Tue, 29 Oct 2024 09:39:47 +0000 Subject: [PATCH 4/5] Apply suggestions from code review Co-authored-by: Reuben Gardos Reid <5456207+ReubenJ@users.noreply.github.com> --- test/runtests.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index f37256a..be323b4 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -87,9 +87,9 @@ using Test ] ) @test rulesoftype(rulenode, Set((11, 12))) == Set{Int}() - arg = Set((1, 3, 7, 9, 10, 15, 23)) + ruleset = Set((1, 3, 7, 9, 10, 15, 23)) expected = Set((1, 3, 7, 9, 10)) - @test rulesoftype(rulenode, arg) == expected + @test rulesoftype(rulenode, ruleset) == expected @test rulesoftype(rulenode, Set(1)) == Set(1) @test rulesoftype(rulenode, Set{Int}()) == Set{Int}() @test rulesoftype(RuleNode(1), Set((1, 2))) == Set(1) From 6924368fee495d7effa22bfa3a80205c6b95318d Mon Sep 17 00:00:00 2001 From: Markus Hauru Date: Tue, 29 Oct 2024 09:40:51 +0000 Subject: [PATCH 5/5] Add more suggestions from code review --- test/runtests.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index be323b4..b2c9335 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -86,12 +86,12 @@ using Test ) ] ) - @test rulesoftype(rulenode, Set((11, 12))) == Set{Int}() + @test isempty(rulesoftype(rulenode, Set((11, 12)))) ruleset = Set((1, 3, 7, 9, 10, 15, 23)) expected = Set((1, 3, 7, 9, 10)) @test rulesoftype(rulenode, ruleset) == expected @test rulesoftype(rulenode, Set(1)) == Set(1) - @test rulesoftype(rulenode, Set{Int}()) == Set{Int}() + @test isempty(rulesoftype(rulenode, Set{Int}())) @test rulesoftype(RuleNode(1), Set((1, 2))) == Set(1) end