aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/language
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2022-10-30 19:27:34 -0400
committerLibravatar Kristóf Marussy <kristof@marussy.com>2022-11-05 19:41:17 +0100
commit960af83c7c1cb871da03b9ac4ec6f44c94e78a1d (patch)
tree7d37ee007ee2d3b031d62ca892920d326758f438 /subprojects/language
parentrefactor: DNF query builder (diff)
downloadrefinery-960af83c7c1cb871da03b9ac4ec6f44c94e78a1d.tar.gz
refinery-960af83c7c1cb871da03b9ac4ec6f44c94e78a1d.tar.zst
refinery-960af83c7c1cb871da03b9ac4ec6f44c94e78a1d.zip
refactor: DNF atoms
Restore count != capability. Still needs semantics and tests for count atoms over partial models.
Diffstat (limited to 'subprojects/language')
-rw-r--r--subprojects/language/src/main/java/tools/refinery/language/Problem.xtext2
-rw-r--r--subprojects/language/src/main/java/tools/refinery/language/utils/RelationInfo.java27
-rw-r--r--subprojects/language/src/main/java/tools/refinery/language/utils/SymbolCollector.java49
-rw-r--r--subprojects/language/src/test/java/tools/refinery/language/tests/utils/SymbolCollectorTest.java47
4 files changed, 76 insertions, 49 deletions
diff --git a/subprojects/language/src/main/java/tools/refinery/language/Problem.xtext b/subprojects/language/src/main/java/tools/refinery/language/Problem.xtext
index f514e96c..2a8429a3 100644
--- a/subprojects/language/src/main/java/tools/refinery/language/Problem.xtext
+++ b/subprojects/language/src/main/java/tools/refinery/language/Problem.xtext
@@ -72,7 +72,7 @@ NegativeLiteral:
72 modality=Modality? "!" atom=Atom; 72 modality=Modality? "!" atom=Atom;
73 73
74enum ComparisonOp: 74enum ComparisonOp:
75 LESS="<" | LESS_EQ="<=" | GREATER=">" | GREATER_EQ=">=" | EQ="=="; 75 LESS="<" | LESS_EQ="<=" | GREATER=">" | GREATER_EQ=">=" | EQ="==" | NOT_EQ="!=";
76 76
77CountLiteral: 77CountLiteral:
78 modality=Modality? "count" atom=Atom op=ComparisonOp threshold=INT; 78 modality=Modality? "count" atom=Atom op=ComparisonOp threshold=INT;
diff --git a/subprojects/language/src/main/java/tools/refinery/language/utils/RelationInfo.java b/subprojects/language/src/main/java/tools/refinery/language/utils/RelationInfo.java
index ae56e3a5..2253d257 100644
--- a/subprojects/language/src/main/java/tools/refinery/language/utils/RelationInfo.java
+++ b/subprojects/language/src/main/java/tools/refinery/language/utils/RelationInfo.java
@@ -1,27 +1,24 @@
1package tools.refinery.language.utils; 1package tools.refinery.language.utils;
2 2
3import tools.refinery.language.model.problem.*;
4
3import java.util.ArrayList; 5import java.util.ArrayList;
4import java.util.Collection; 6import java.util.Collection;
5import java.util.List; 7import java.util.List;
6 8
7import tools.refinery.language.model.problem.Assertion; 9public record RelationInfo(String name, ContainmentRole containmentRole, List<Parameter> parameters,
8import tools.refinery.language.model.problem.Conjunction; 10 Multiplicity multiplicity, Relation opposite, Collection<Conjunction> bodies,
9import tools.refinery.language.model.problem.Multiplicity; 11 Collection<Assertion> assertions, Collection<TypeScope> typeScopes) {
10import tools.refinery.language.model.problem.Parameter; 12 public RelationInfo(String name, ContainmentRole containmentRole, List<Parameter> parameters,
11import tools.refinery.language.model.problem.PredicateKind; 13 Multiplicity multiplicity, Relation opposite, Collection<Conjunction> bodies) {
12import tools.refinery.language.model.problem.Relation; 14 this(name, containmentRole, parameters, multiplicity, opposite, bodies, new ArrayList<>(), new ArrayList<>());
13import tools.refinery.language.model.problem.TypeScope;
14
15public record RelationInfo(String name, PredicateKind kind, List<Parameter> parameters, Multiplicity multiplicity,
16 Relation opposite, Collection<Conjunction> bodies, Collection<Assertion> defaultAssertions,
17 Collection<Assertion> assertions, Collection<TypeScope> typeScopes) {
18 public RelationInfo(String name, PredicateKind kind, List<Parameter> parameters, Multiplicity multiplicity,
19 Relation opposite, Collection<Conjunction> bodies) {
20 this(name, kind, parameters, multiplicity, opposite, bodies, new ArrayList<>(), new ArrayList<>(),
21 new ArrayList<>());
22 } 15 }
23 16
24 public boolean hasDefinition() { 17 public boolean hasDefinition() {
25 return bodies != null && !bodies.isEmpty(); 18 return bodies != null && !bodies.isEmpty();
26 } 19 }
20
21 public int arity() {
22 return parameters.size();
23 }
27} 24}
diff --git a/subprojects/language/src/main/java/tools/refinery/language/utils/SymbolCollector.java b/subprojects/language/src/main/java/tools/refinery/language/utils/SymbolCollector.java
index a386db7f..210e96ab 100644
--- a/subprojects/language/src/main/java/tools/refinery/language/utils/SymbolCollector.java
+++ b/subprojects/language/src/main/java/tools/refinery/language/utils/SymbolCollector.java
@@ -19,10 +19,12 @@ class SymbolCollector {
19 private IQualifiedNameConverter qualifiedNameConverter; 19 private IQualifiedNameConverter qualifiedNameConverter;
20 20
21 @Inject 21 @Inject
22 ProblemDesugarer desugarer; 22 private ProblemDesugarer desugarer;
23 23
24 private BuiltinSymbols builtinSymbols; 24 private BuiltinSymbols builtinSymbols;
25
25 private final Map<Node, NodeInfo> nodes = new LinkedHashMap<>(); 26 private final Map<Node, NodeInfo> nodes = new LinkedHashMap<>();
27
26 private final Map<Relation, RelationInfo> relations = new LinkedHashMap<>(); 28 private final Map<Relation, RelationInfo> relations = new LinkedHashMap<>();
27 29
28 public CollectedSymbols collectSymbols(Problem problem) { 30 public CollectedSymbols collectSymbols(Problem problem) {
@@ -54,9 +56,10 @@ class SymbolCollector {
54 } 56 }
55 57
56 private void collectPredicate(PredicateDefinition predicateDefinition) { 58 private void collectPredicate(PredicateDefinition predicateDefinition) {
59 var predicateKind = predicateDefinition.getKind();
57 var info = new RelationInfo(getQualifiedNameString(predicateDefinition), 60 var info = new RelationInfo(getQualifiedNameString(predicateDefinition),
58 predicateDefinition.getKind(), 61 ContainmentRole.fromPredicateKind(predicateKind), predicateDefinition.getParameters(), null, null,
59 predicateDefinition.getParameters(), null, null, predicateDefinition.getBodies()); 62 predicateDefinition.getBodies());
60 relations.put(predicateDefinition, info); 63 relations.put(predicateDefinition, info);
61 } 64 }
62 65
@@ -65,10 +68,10 @@ class SymbolCollector {
65 // contained, including data types. 68 // contained, including data types.
66 var contained = 69 var contained =
67 classDeclaration != builtinSymbols.node() && classDeclaration != builtinSymbols.domain(); 70 classDeclaration != builtinSymbols.node() && classDeclaration != builtinSymbols.domain();
68 var classKind = contained ? PredicateKind.CONTAINED : PredicateKind.DEFAULT; 71 var containmentRole = contained ? ContainmentRole.CONTAINED : ContainmentRole.NONE;
69 var instanceParameter = ProblemFactory.eINSTANCE.createParameter(); 72 var instanceParameter = ProblemFactory.eINSTANCE.createParameter();
70 instanceParameter.setName("instance"); 73 instanceParameter.setName("instance");
71 var classInfo = new RelationInfo(getQualifiedNameString(classDeclaration), classKind, 74 var classInfo = new RelationInfo(getQualifiedNameString(classDeclaration), containmentRole,
72 List.of(instanceParameter), null, null, List.of()); 75 List.of(instanceParameter), null, null, List.of());
73 relations.put(classDeclaration, classInfo); 76 relations.put(classDeclaration, classInfo);
74 collectReferences(classDeclaration); 77 collectReferences(classDeclaration);
@@ -76,9 +79,9 @@ class SymbolCollector {
76 79
77 private void collectReferences(ClassDeclaration classDeclaration) { 80 private void collectReferences(ClassDeclaration classDeclaration) {
78 for (var referenceDeclaration : classDeclaration.getReferenceDeclarations()) { 81 for (var referenceDeclaration : classDeclaration.getReferenceDeclarations()) {
79 var referenceKind = desugarer.isContainmentReference(referenceDeclaration) ? 82 var referenceRole = desugarer.isContainmentReference(referenceDeclaration) ?
80 PredicateKind.CONTAINMENT : 83 ContainmentRole.CONTAINMENT :
81 PredicateKind.DEFAULT; 84 ContainmentRole.NONE;
82 var sourceParameter = ProblemFactory.eINSTANCE.createParameter(); 85 var sourceParameter = ProblemFactory.eINSTANCE.createParameter();
83 sourceParameter.setName("source"); 86 sourceParameter.setName("source");
84 sourceParameter.setParameterType(classDeclaration); 87 sourceParameter.setParameterType(classDeclaration);
@@ -91,7 +94,7 @@ class SymbolCollector {
91 multiplicity = exactMultiplicity; 94 multiplicity = exactMultiplicity;
92 } 95 }
93 targetParameter.setParameterType(referenceDeclaration.getReferenceType()); 96 targetParameter.setParameterType(referenceDeclaration.getReferenceType());
94 var referenceInfo = new RelationInfo(getQualifiedNameString(referenceDeclaration), referenceKind, 97 var referenceInfo = new RelationInfo(getQualifiedNameString(referenceDeclaration), referenceRole,
95 List.of(sourceParameter, targetParameter), multiplicity, referenceDeclaration.getOpposite(), 98 List.of(sourceParameter, targetParameter), multiplicity, referenceDeclaration.getOpposite(),
96 List.of()); 99 List.of());
97 this.relations.put(referenceDeclaration, referenceInfo); 100 this.relations.put(referenceDeclaration, referenceInfo);
@@ -101,7 +104,7 @@ class SymbolCollector {
101 private void collectEnum(EnumDeclaration enumDeclaration) { 104 private void collectEnum(EnumDeclaration enumDeclaration) {
102 var instanceParameter = ProblemFactory.eINSTANCE.createParameter(); 105 var instanceParameter = ProblemFactory.eINSTANCE.createParameter();
103 instanceParameter.setName("instance"); 106 instanceParameter.setName("instance");
104 var info = new RelationInfo(getQualifiedNameString(enumDeclaration), PredicateKind.DEFAULT, 107 var info = new RelationInfo(getQualifiedNameString(enumDeclaration), ContainmentRole.NONE,
105 List.of(instanceParameter), null, null, List.of()); 108 List.of(instanceParameter), null, null, List.of());
106 this.relations.put(enumDeclaration, info); 109 this.relations.put(enumDeclaration, info);
107 } 110 }
@@ -172,6 +175,8 @@ class SymbolCollector {
172 collectAssertion(assertion); 175 collectAssertion(assertion);
173 } else if (statement instanceof NodeValueAssertion nodeValueAssertion) { 176 } else if (statement instanceof NodeValueAssertion nodeValueAssertion) {
174 collectNodeValueAssertion(nodeValueAssertion); 177 collectNodeValueAssertion(nodeValueAssertion);
178 } else if (statement instanceof PredicateDefinition predicateDefinition) {
179 collectPredicateAssertion(predicateDefinition);
175 } else if (statement instanceof ClassDeclaration classDeclaration) { 180 } else if (statement instanceof ClassDeclaration classDeclaration) {
176 collectClassAssertion(classDeclaration); 181 collectClassAssertion(classDeclaration);
177 } else if (statement instanceof EnumDeclaration enumDeclaration) { 182 } else if (statement instanceof EnumDeclaration enumDeclaration) {
@@ -190,11 +195,7 @@ class SymbolCollector {
190 // Problem during editing. The errors can still be detected by the Problem validator. 195 // Problem during editing. The errors can still be detected by the Problem validator.
191 return; 196 return;
192 } 197 }
193 if (assertion.isDefault()) { 198 relationInfo.assertions().add(assertion);
194 relationInfo.defaultAssertions().add(assertion);
195 } else {
196 relationInfo.assertions().add(assertion);
197 }
198 for (var argument : assertion.getArguments()) { 199 for (var argument : assertion.getArguments()) {
199 if (argument instanceof ConstantAssertionArgument constantAssertionArgument) { 200 if (argument instanceof ConstantAssertionArgument constantAssertionArgument) {
200 var constantNode = constantAssertionArgument.getNode(); 201 var constantNode = constantAssertionArgument.getNode();
@@ -239,6 +240,14 @@ class SymbolCollector {
239 addAssertion(dataType, LogicValue.TRUE, node); 240 addAssertion(dataType, LogicValue.TRUE, node);
240 } 241 }
241 242
243 private void collectPredicateAssertion(PredicateDefinition predicateDefinition) {
244 if (predicateDefinition.getKind() != PredicateKind.ERROR) {
245 return;
246 }
247 int arity = predicateDefinition.getParameters().size();
248 addAssertion(predicateDefinition, LogicValue.FALSE, new Node[arity]);
249 }
250
242 private void collectClassAssertion(ClassDeclaration classDeclaration) { 251 private void collectClassAssertion(ClassDeclaration classDeclaration) {
243 var node = classDeclaration.getNewNode(); 252 var node = classDeclaration.getNewNode();
244 if (node == null) { 253 if (node == null) {
@@ -259,8 +268,14 @@ class SymbolCollector {
259 var assertion = ProblemFactory.eINSTANCE.createAssertion(); 268 var assertion = ProblemFactory.eINSTANCE.createAssertion();
260 assertion.setRelation(relation); 269 assertion.setRelation(relation);
261 for (var node : nodes) { 270 for (var node : nodes) {
262 var argument = ProblemFactory.eINSTANCE.createNodeAssertionArgument(); 271 AssertionArgument argument;
263 argument.setNode(node); 272 if (node == null) {
273 argument = ProblemFactory.eINSTANCE.createWildcardAssertionArgument();
274 } else {
275 var nodeArgument = ProblemFactory.eINSTANCE.createNodeAssertionArgument();
276 nodeArgument.setNode(node);
277 argument = nodeArgument;
278 }
264 assertion.getArguments().add(argument); 279 assertion.getArguments().add(argument);
265 } 280 }
266 assertion.setValue(logicValue); 281 assertion.setValue(logicValue);
diff --git a/subprojects/language/src/test/java/tools/refinery/language/tests/utils/SymbolCollectorTest.java b/subprojects/language/src/test/java/tools/refinery/language/tests/utils/SymbolCollectorTest.java
index e2e3218c..a05f3335 100644
--- a/subprojects/language/src/test/java/tools/refinery/language/tests/utils/SymbolCollectorTest.java
+++ b/subprojects/language/src/test/java/tools/refinery/language/tests/utils/SymbolCollectorTest.java
@@ -12,6 +12,7 @@ import org.junit.jupiter.params.provider.MethodSource;
12import tools.refinery.language.model.problem.*; 12import tools.refinery.language.model.problem.*;
13import tools.refinery.language.model.tests.utils.ProblemParseHelper; 13import tools.refinery.language.model.tests.utils.ProblemParseHelper;
14import tools.refinery.language.tests.ProblemInjectorProvider; 14import tools.refinery.language.tests.ProblemInjectorProvider;
15import tools.refinery.language.utils.ContainmentRole;
15import tools.refinery.language.utils.ProblemDesugarer; 16import tools.refinery.language.utils.ProblemDesugarer;
16 17
17import java.util.stream.Stream; 18import java.util.stream.Stream;
@@ -61,7 +62,7 @@ class SymbolCollectorTest {
61 assertThat(collectedSymbols.relations(), hasKey(classDeclaration)); 62 assertThat(collectedSymbols.relations(), hasKey(classDeclaration));
62 var classInfo = collectedSymbols.relations().get(classDeclaration); 63 var classInfo = collectedSymbols.relations().get(classDeclaration);
63 assertThat(classInfo.parameters(), hasSize(1)); 64 assertThat(classInfo.parameters(), hasSize(1));
64 assertThat(classInfo.kind(), is(PredicateKind.CONTAINED)); 65 assertThat(classInfo.containmentRole(), is(ContainmentRole.CONTAINED));
65 assertThat(classInfo.hasDefinition(), is(false)); 66 assertThat(classInfo.hasDefinition(), is(false));
66 var newNode = classDeclaration.getNewNode(); 67 var newNode = classDeclaration.getNewNode();
67 assertThat(collectedSymbols.nodes(), hasKey(newNode)); 68 assertThat(collectedSymbols.nodes(), hasKey(newNode));
@@ -96,11 +97,11 @@ class SymbolCollectorTest {
96 var barInfo = collectedSymbols.relations().get(barReference); 97 var barInfo = collectedSymbols.relations().get(barReference);
97 var quuxReference = fooClass.reference("quux"); 98 var quuxReference = fooClass.reference("quux");
98 var quuxInfo = collectedSymbols.relations().get(quuxReference); 99 var quuxInfo = collectedSymbols.relations().get(quuxReference);
99 assertThat(barInfo.kind(), is(PredicateKind.DEFAULT)); 100 assertThat(barInfo.containmentRole(), is(ContainmentRole.NONE));
100 assertThat(barInfo.opposite(), is(quuxReference)); 101 assertThat(barInfo.opposite(), is(quuxReference));
101 assertThat(barInfo.multiplicity(), is(instanceOf(UnboundedMultiplicity.class))); 102 assertThat(barInfo.multiplicity(), is(instanceOf(UnboundedMultiplicity.class)));
102 assertThat(barInfo.hasDefinition(), is(false)); 103 assertThat(barInfo.hasDefinition(), is(false));
103 assertThat(quuxInfo.kind(), is(PredicateKind.DEFAULT)); 104 assertThat(quuxInfo.containmentRole(), is(ContainmentRole.NONE));
104 assertThat(quuxInfo.opposite(), is(barReference)); 105 assertThat(quuxInfo.opposite(), is(barReference));
105 assertThat(quuxInfo.multiplicity(), is(instanceOf(ExactMultiplicity.class))); 106 assertThat(quuxInfo.multiplicity(), is(instanceOf(ExactMultiplicity.class)));
106 assertThat(quuxInfo.multiplicity(), hasProperty("exactValue", is(1))); 107 assertThat(quuxInfo.multiplicity(), hasProperty("exactValue", is(1)));
@@ -115,8 +116,8 @@ class SymbolCollectorTest {
115 } 116 }
116 """); 117 """);
117 var collectedSymbols = desugarer.collectSymbols(problem.get()); 118 var collectedSymbols = desugarer.collectSymbols(problem.get());
118 assertThat(collectedSymbols.relations().get(problem.findClass("Foo").reference("bar")).kind(), 119 assertThat(collectedSymbols.relations().get(problem.findClass("Foo").reference("bar")).containmentRole(),
119 is(PredicateKind.CONTAINMENT)); 120 is(ContainmentRole.CONTAINMENT));
120 } 121 }
121 122
122 @Test 123 @Test
@@ -127,8 +128,8 @@ class SymbolCollectorTest {
127 } 128 }
128 """); 129 """);
129 var collectedSymbols = desugarer.collectSymbols(problem.get()); 130 var collectedSymbols = desugarer.collectSymbols(problem.get());
130 assertThat(collectedSymbols.relations().get(problem.findClass("Foo").reference("bar")).kind(), 131 assertThat(collectedSymbols.relations().get(problem.findClass("Foo").reference("bar")).containmentRole(),
131 is(PredicateKind.CONTAINMENT)); 132 is(ContainmentRole.CONTAINMENT));
132 } 133 }
133 134
134 @Test 135 @Test
@@ -141,27 +142,27 @@ class SymbolCollectorTest {
141 var collectedSymbols = desugarer.collectSymbols(problem.get()); 142 var collectedSymbols = desugarer.collectSymbols(problem.get());
142 var enumDeclaration = problem.findEnum("Foo"); 143 var enumDeclaration = problem.findEnum("Foo");
143 var enumInfo = collectedSymbols.relations().get(enumDeclaration.get()); 144 var enumInfo = collectedSymbols.relations().get(enumDeclaration.get());
144 assertThat(enumInfo.kind(), is(PredicateKind.DEFAULT)); 145 assertThat(enumInfo.containmentRole(), is(ContainmentRole.NONE));
145 assertThat(enumInfo.assertions(), assertsNode(enumDeclaration.literal("bar"), LogicValue.TRUE)); 146 assertThat(enumInfo.assertions(), assertsNode(enumDeclaration.literal("bar"), LogicValue.TRUE));
146 assertThat(enumInfo.assertions(), assertsNode(enumDeclaration.literal("quux"), LogicValue.TRUE)); 147 assertThat(enumInfo.assertions(), assertsNode(enumDeclaration.literal("quux"), LogicValue.TRUE));
147 } 148 }
148 149
149 @ParameterizedTest 150 @ParameterizedTest
150 @MethodSource 151 @MethodSource
151 void predicateTest(String keyword, PredicateKind kind) { 152 void predicateTest(String keyword, ContainmentRole containmentRole) {
152 var problem = parseHelper.parse(keyword + " foo(node x) <-> domain(x); data(x)."); 153 var problem = parseHelper.parse(keyword + " foo(node x) <-> domain(x); data(x).");
153 var collectedSymbols = desugarer.collectSymbols(problem.get()); 154 var collectedSymbols = desugarer.collectSymbols(problem.get());
154 var predicateInfo = collectedSymbols.relations().get(problem.pred("foo").get()); 155 var predicateInfo = collectedSymbols.relations().get(problem.pred("foo").get());
155 assertThat(predicateInfo.kind(), is(kind)); 156 assertThat(predicateInfo.containmentRole(), is(containmentRole));
156 assertThat(predicateInfo.parameters(), hasSize(1)); 157 assertThat(predicateInfo.parameters(), hasSize(1));
157 assertThat(predicateInfo.bodies(), hasSize(2)); 158 assertThat(predicateInfo.bodies(), hasSize(2));
158 assertThat(predicateInfo.hasDefinition(), is(true)); 159 assertThat(predicateInfo.hasDefinition(), is(true));
159 } 160 }
160 161
161 static Stream<Arguments> predicateTest() { 162 static Stream<Arguments> predicateTest() {
162 return Stream.of(Arguments.of("pred", PredicateKind.DEFAULT), Arguments.of("error", PredicateKind.ERROR), 163 return Stream.of(Arguments.of("pred", ContainmentRole.NONE), Arguments.of("error", ContainmentRole.NONE),
163 Arguments.of("contained", PredicateKind.CONTAINED), Arguments.of("containment", 164 Arguments.of("contained", ContainmentRole.CONTAINED), Arguments.of("containment",
164 PredicateKind.CONTAINMENT)); 165 ContainmentRole.CONTAINMENT));
165 } 166 }
166 167
167 @ParameterizedTest 168 @ParameterizedTest
@@ -184,7 +185,7 @@ class SymbolCollectorTest {
184 default foo(a): %s. 185 default foo(a): %s.
185 """.formatted(keyword)); 186 """.formatted(keyword));
186 var collectedSymbols = desugarer.collectSymbols(problem.get()); 187 var collectedSymbols = desugarer.collectSymbols(problem.get());
187 assertThat(collectedSymbols.relations().get(problem.pred("foo").get()).defaultAssertions(), 188 assertThat(collectedSymbols.relations().get(problem.pred("foo").get()).assertions(),
188 assertsNode(problem.node("a"), value)); 189 assertsNode(problem.node("a"), value));
189 } 190 }
190 191
@@ -254,6 +255,10 @@ class SymbolCollectorTest {
254 LogicValue.UNKNOWN)); 255 LogicValue.UNKNOWN));
255 } 256 }
256 257
258 static Stream<Arguments> valueTypes() {
259 return Stream.of(Arguments.of("3", "int"), Arguments.of("3.14", "real"), Arguments.of("\"foo\"", "string"));
260 }
261
257 @Test 262 @Test
258 void invalidProblemTest() { 263 void invalidProblemTest() {
259 var problem = parseHelper.parse(""" 264 var problem = parseHelper.parse("""
@@ -265,8 +270,18 @@ class SymbolCollectorTest {
265 assertDoesNotThrow(() -> desugarer.collectSymbols(problem)); 270 assertDoesNotThrow(() -> desugarer.collectSymbols(problem));
266 } 271 }
267 272
268 static Stream<Arguments> valueTypes() { 273 @Test
269 return Stream.of(Arguments.of("3", "int"), Arguments.of("3.14", "real"), Arguments.of("\"foo\"", "string")); 274 void errorAssertionTest() {
275 var problem = parseHelper.parse("""
276 error foo(node a, node b) <-> equals(a, b).
277 """);
278 var collectedSymbols = desugarer.collectSymbols(problem.get());
279 var fooInfo = collectedSymbols.relations().get(problem.pred("foo").get());
280 assertThat(fooInfo.assertions(), hasSize(1));
281 var assertion = fooInfo.assertions().stream().findFirst().orElseThrow();
282 assertThat(assertion.getValue(), is(LogicValue.FALSE));
283 assertThat(assertion.getArguments(), hasSize(2));
284 assertThat(assertion.getArguments(), everyItem(instanceOf(WildcardAssertionArgument.class)));
270 } 285 }
271 286
272 private static Matcher<Iterable<? super Assertion>> assertsNode(Node node, LogicValue value) { 287 private static Matcher<Iterable<? super Assertion>> assertsNode(Node node, LogicValue value) {