diff options
author | 2023-05-26 22:24:40 +0200 | |
---|---|---|
committer | 2023-05-26 22:24:40 +0200 | |
commit | d2348a15846ad861fc58b018f50a502a288bfcec (patch) | |
tree | 3a03b9eb35e9f90fd7f0e669ed00bf3aa8636982 /subprojects/store-query/src/test/java | |
parent | feat: count and aggregation literal reduction (diff) | |
download | refinery-d2348a15846ad861fc58b018f50a502a288bfcec.tar.gz refinery-d2348a15846ad861fc58b018f50a502a288bfcec.tar.zst refinery-d2348a15846ad861fc58b018f50a502a288bfcec.zip |
refactor: simplified Dnf parameter directions
Diffstat (limited to 'subprojects/store-query/src/test/java')
2 files changed, 15 insertions, 10 deletions
diff --git a/subprojects/store-query/src/test/java/tools/refinery/store/query/dnf/DnfBuilderLiteralEliminationTest.java b/subprojects/store-query/src/test/java/tools/refinery/store/query/dnf/DnfBuilderLiteralEliminationTest.java index 4edea401..687b06db 100644 --- a/subprojects/store-query/src/test/java/tools/refinery/store/query/dnf/DnfBuilderLiteralEliminationTest.java +++ b/subprojects/store-query/src/test/java/tools/refinery/store/query/dnf/DnfBuilderLiteralEliminationTest.java | |||
@@ -10,6 +10,7 @@ import org.junit.jupiter.params.ParameterizedTest; | |||
10 | import org.junit.jupiter.params.provider.CsvSource; | 10 | import org.junit.jupiter.params.provider.CsvSource; |
11 | import tools.refinery.store.query.literal.BooleanLiteral; | 11 | import tools.refinery.store.query.literal.BooleanLiteral; |
12 | import tools.refinery.store.query.term.NodeVariable; | 12 | import tools.refinery.store.query.term.NodeVariable; |
13 | import tools.refinery.store.query.term.ParameterDirection; | ||
13 | import tools.refinery.store.query.term.Variable; | 14 | import tools.refinery.store.query.term.Variable; |
14 | import tools.refinery.store.query.term.bool.BoolTerms; | 15 | import tools.refinery.store.query.term.bool.BoolTerms; |
15 | import tools.refinery.store.query.view.KeyOnlyView; | 16 | import tools.refinery.store.query.view.KeyOnlyView; |
@@ -28,7 +29,7 @@ class DnfBuilderLiteralEliminationTest { | |||
28 | private final SymbolView<Boolean> friendView = new KeyOnlyView<>(friend); | 29 | private final SymbolView<Boolean> friendView = new KeyOnlyView<>(friend); |
29 | private final NodeVariable p = Variable.of("p"); | 30 | private final NodeVariable p = Variable.of("p"); |
30 | private final NodeVariable q = Variable.of("q"); | 31 | private final NodeVariable q = Variable.of("q"); |
31 | private final Dnf trueDnf = Dnf.builder().parameter(p).clause().build(); | 32 | private final Dnf trueDnf = Dnf.builder().parameter(p, ParameterDirection.IN).clause().build(); |
32 | private final Dnf falseDnf = Dnf.builder().parameter(p).build(); | 33 | private final Dnf falseDnf = Dnf.builder().parameter(p).build(); |
33 | 34 | ||
34 | @Test | 35 | @Test |
@@ -84,11 +85,11 @@ class DnfBuilderLiteralEliminationTest { | |||
84 | @Test | 85 | @Test |
85 | void alwaysTrueTest() { | 86 | void alwaysTrueTest() { |
86 | var actual = Dnf.builder() | 87 | var actual = Dnf.builder() |
87 | .parameters(p, q) | 88 | .parameters(List.of(p, q), ParameterDirection.IN) |
88 | .clause(friendView.call(p, q)) | 89 | .clause(friendView.call(p, q)) |
89 | .clause(BooleanLiteral.TRUE) | 90 | .clause(BooleanLiteral.TRUE) |
90 | .build(); | 91 | .build(); |
91 | var expected = Dnf.builder().parameters(p, q).clause().build(); | 92 | var expected = Dnf.builder().parameters(List.of(p, q), ParameterDirection.IN).clause().build(); |
92 | 93 | ||
93 | assertThat(actual, structurallyEqualTo(expected)); | 94 | assertThat(actual, structurallyEqualTo(expected)); |
94 | } | 95 | } |
@@ -130,11 +131,11 @@ class DnfBuilderLiteralEliminationTest { | |||
130 | @Test | 131 | @Test |
131 | void alwaysTrueDnfTest() { | 132 | void alwaysTrueDnfTest() { |
132 | var actual = Dnf.builder() | 133 | var actual = Dnf.builder() |
133 | .parameters(p, q) | 134 | .parameters(List.of(p, q), ParameterDirection.IN) |
134 | .clause(friendView.call(p, q)) | 135 | .clause(friendView.call(p, q)) |
135 | .clause(trueDnf.call(q)) | 136 | .clause(trueDnf.call(q)) |
136 | .build(); | 137 | .build(); |
137 | var expected = Dnf.builder().parameters(p, q).clause().build(); | 138 | var expected = Dnf.builder().parameters(List.of(p, q), ParameterDirection.IN).clause().build(); |
138 | 139 | ||
139 | assertThat(actual, structurallyEqualTo(expected)); | 140 | assertThat(actual, structurallyEqualTo(expected)); |
140 | } | 141 | } |
@@ -176,11 +177,11 @@ class DnfBuilderLiteralEliminationTest { | |||
176 | @Test | 177 | @Test |
177 | void alwaysNotFalseDnfTest() { | 178 | void alwaysNotFalseDnfTest() { |
178 | var actual = Dnf.builder() | 179 | var actual = Dnf.builder() |
179 | .parameters(p, q) | 180 | .parameters(List.of(p, q), ParameterDirection.IN) |
180 | .clause(friendView.call(p, q)) | 181 | .clause(friendView.call(p, q)) |
181 | .clause(not(falseDnf.call(q))) | 182 | .clause(not(falseDnf.call(q))) |
182 | .build(); | 183 | .build(); |
183 | var expected = Dnf.builder().parameters(p, q).clause().build(); | 184 | var expected = Dnf.builder().parameters(List.of(p, q), ParameterDirection.IN).clause().build(); |
184 | 185 | ||
185 | assertThat(actual, structurallyEqualTo(expected)); | 186 | assertThat(actual, structurallyEqualTo(expected)); |
186 | } | 187 | } |
diff --git a/subprojects/store-query/src/test/java/tools/refinery/store/query/dnf/DnfToDefinitionStringTest.java b/subprojects/store-query/src/test/java/tools/refinery/store/query/dnf/DnfToDefinitionStringTest.java index 2e93d78a..63310a78 100644 --- a/subprojects/store-query/src/test/java/tools/refinery/store/query/dnf/DnfToDefinitionStringTest.java +++ b/subprojects/store-query/src/test/java/tools/refinery/store/query/dnf/DnfToDefinitionStringTest.java | |||
@@ -6,6 +6,7 @@ | |||
6 | package tools.refinery.store.query.dnf; | 6 | package tools.refinery.store.query.dnf; |
7 | 7 | ||
8 | import org.junit.jupiter.api.Test; | 8 | import org.junit.jupiter.api.Test; |
9 | import tools.refinery.store.query.term.ParameterDirection; | ||
9 | import tools.refinery.store.query.term.Variable; | 10 | import tools.refinery.store.query.term.Variable; |
10 | import tools.refinery.store.query.view.KeyOnlyView; | 11 | import tools.refinery.store.query.view.KeyOnlyView; |
11 | import tools.refinery.store.representation.Symbol; | 12 | import tools.refinery.store.representation.Symbol; |
@@ -39,7 +40,7 @@ class DnfToDefinitionStringTest { | |||
39 | @Test | 40 | @Test |
40 | void emptyClauseTest() { | 41 | void emptyClauseTest() { |
41 | var p = Variable.of("p"); | 42 | var p = Variable.of("p"); |
42 | var dnf = Dnf.builder("Example").parameter(p).clause().build(); | 43 | var dnf = Dnf.builder("Example").parameter(p, ParameterDirection.IN).clause().build(); |
43 | 44 | ||
44 | assertThat(dnf.toDefinitionString(), is(""" | 45 | assertThat(dnf.toDefinitionString(), is(""" |
45 | pred Example(@In p) <-> | 46 | pred Example(@In p) <-> |
@@ -67,10 +68,13 @@ class DnfToDefinitionStringTest { | |||
67 | var q = Variable.of("q"); | 68 | var q = Variable.of("q"); |
68 | var friend = new Symbol<>("friend", 2, Boolean.class, false); | 69 | var friend = new Symbol<>("friend", 2, Boolean.class, false); |
69 | var friendView = new KeyOnlyView<>(friend); | 70 | var friendView = new KeyOnlyView<>(friend); |
70 | var dnf = Dnf.builder("Example").parameter(p).clause(not(friendView.call(p, q))).build(); | 71 | var dnf = Dnf.builder("Example") |
72 | .parameter(p, ParameterDirection.IN) | ||
73 | .clause(not(friendView.call(p, q))) | ||
74 | .build(); | ||
71 | 75 | ||
72 | assertThat(dnf.toDefinitionString(), is(""" | 76 | assertThat(dnf.toDefinitionString(), is(""" |
73 | pred Example(p) <-> | 77 | pred Example(@In p) <-> |
74 | !(@RelationView("key") friend(p, q)). | 78 | !(@RelationView("key") friend(p, q)). |
75 | """)); | 79 | """)); |
76 | } | 80 | } |