diff options
author | 2023-07-09 19:53:46 +0200 | |
---|---|---|
committer | 2023-07-09 19:53:46 +0200 | |
commit | f6440ff43e2e7497116c2cf762f61e07834b229f (patch) | |
tree | 0c5719408fcf061aa72781424af1002d6bbabe39 /subprojects/store-query-viatra/src/test | |
parent | refactor: Dnf lifter (diff) | |
download | refinery-f6440ff43e2e7497116c2cf762f61e07834b229f.tar.gz refinery-f6440ff43e2e7497116c2cf762f61e07834b229f.tar.zst refinery-f6440ff43e2e7497116c2cf762f61e07834b229f.zip |
refactor: enable data variable unification
This is needed for demand set transformation of DNFs with input data parameters,
where the result of the transformation has an out data parameter that has to be
unified with the variable in the parent clause.
Diffstat (limited to 'subprojects/store-query-viatra/src/test')
-rw-r--r-- | subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/FunctionalQueryTest.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/FunctionalQueryTest.java b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/FunctionalQueryTest.java index c4f877c5..7f5c24fe 100644 --- a/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/FunctionalQueryTest.java +++ b/subprojects/store-query-viatra/src/test/java/tools/refinery/store/query/viatra/FunctionalQueryTest.java | |||
@@ -424,6 +424,42 @@ class FunctionalQueryTest { | |||
424 | } | 424 | } |
425 | 425 | ||
426 | @QueryEngineTest | 426 | @QueryEngineTest |
427 | void multipleAssignmentTest(QueryEvaluationHint hint) { | ||
428 | var query = Query.of("MultipleAssignment", Integer.class, (builder, p1, p2, output) -> builder | ||
429 | .clause(Integer.class, Integer.class, (x1, x2) -> List.of( | ||
430 | ageView.call(p1, x1), | ||
431 | ageView.call(p2, x2), | ||
432 | output.assign(mul(x1, constant(2))), | ||
433 | output.assign(mul(x2, constant(3))) | ||
434 | ))); | ||
435 | |||
436 | var store = ModelStore.builder() | ||
437 | .symbols(age) | ||
438 | .with(ViatraModelQueryAdapter.builder() | ||
439 | .defaultHint(hint) | ||
440 | .queries(query)) | ||
441 | .build(); | ||
442 | |||
443 | var model = store.createEmptyModel(); | ||
444 | var ageInterpretation = model.getInterpretation(age); | ||
445 | var queryEngine = model.getAdapter(ModelQueryAdapter.class); | ||
446 | var queryResultSet = queryEngine.getResultSet(query); | ||
447 | |||
448 | ageInterpretation.put(Tuple.of(0), 3); | ||
449 | ageInterpretation.put(Tuple.of(1), 2); | ||
450 | ageInterpretation.put(Tuple.of(2), 15); | ||
451 | ageInterpretation.put(Tuple.of(3), 10); | ||
452 | |||
453 | queryEngine.flushChanges(); | ||
454 | assertNullableResults(Map.of( | ||
455 | Tuple.of(0, 1), Optional.of(6), | ||
456 | Tuple.of(1, 0), Optional.empty(), | ||
457 | Tuple.of(2, 3), Optional.of(30), | ||
458 | Tuple.of(3, 2), Optional.empty() | ||
459 | ), queryResultSet); | ||
460 | } | ||
461 | |||
462 | @QueryEngineTest | ||
427 | void notFunctionalTest(QueryEvaluationHint hint) { | 463 | void notFunctionalTest(QueryEvaluationHint hint) { |
428 | var query = Query.of("NotFunctional", Integer.class, (builder, p1, output) -> builder.clause((p2) -> List.of( | 464 | var query = Query.of("NotFunctional", Integer.class, (builder, p1, output) -> builder.clause((p2) -> List.of( |
429 | personView.call(p1), | 465 | personView.call(p1), |