@@ -69,10 +69,10 @@ public class ParserTest {
69
69
70
70
private static final String UNIT_TEST_EXPECT_UNSAT =
71
71
"p(1). p(2). "
72
- + ":- p(X), p(Y), X + Y = 3."
73
- + "#test expected_unsat(expect: unsat) {"
74
- + "given {}"
75
- + "}" ;
72
+ + ":- p(X), p(Y), X + Y = 3."
73
+ + "#test expected_unsat(expect: unsat) {"
74
+ + "given {}"
75
+ + "}" ;
76
76
77
77
private static final String UNIT_TEST_BASIC_TEST =
78
78
"a :- b. #test ensure_a(expect: 1) { given { b. } assertForAll { :- not a. } }" ;
@@ -86,17 +86,13 @@ public class ParserTest {
86
86
private static final String UNIT_TEST_KEYWORDS_AS_IDS =
87
87
"assert(a) :- given(b). # test test(expect: 1) { given { given(b). } assertForAll { :- not assert(a). :- assertForSome(b).}}" ;
88
88
89
- private static final String MODULE_SIMPLE = "#module aSimpleModule({ input/1} => {out1/2, out2/3}) { p(a). p(b). q(X) :- p(X). }" ;
89
+ private static final String MODULE_SIMPLE = "#module aSimpleModule(input/1 => {out1/2, out2/3}) { p(a). p(b). q(X) :- p(X). }" ;
90
90
91
- private static final String MODULE_OUTPUT_ALL = "#module mod({ in/1} => {*}) { a(X). b(X) :- a(X).}" ;
91
+ private static final String MODULE_OUTPUT_ALL = "#module mod(in/1 => {*}) { a(X). b(X) :- a(X).}" ;
92
92
93
- private static final String MODULE_WITH_REGULAR_STMTS = "p(a). p(b). q(X) :- p(X). #module aSimpleModule({ input/1} => {out1/2, out2/3}) { p(a). p(b). q(X) :- p(X). }" ;
93
+ private static final String MODULE_WITH_REGULAR_STMTS = "p(a). p(b). q(X) :- p(X). #module aSimpleModule(input/1 => {out1/2, out2/3}) { p(a). p(b). q(X) :- p(X). }" ;
94
94
95
- private static final String MODULE_MULTIPLE_DEFINITIONS = "a. b(5). #module aSimpleModule({input/1} => {out1/2, out2/3}) { p(a). p(b). q(X) :- p(X). } q(Y) :- r(S, Y), t(S). #module anotherModule({input/1} => {out1/2, out2/3}) { p(a). p(b). q(X) :- p(X). }" ;
96
-
97
- private static final String MODULE_EMPTY_INPUT_SPEC = "#module someModule({} => {*}) {p(a).}" ;
98
-
99
- private static final String MODULE_MULTIPLE_INPUTS = "#module someModule({input/1, input2/2} => {out1/2}) {p(a).}" ;
95
+ private static final String MODULE_MULTIPLE_DEFINITIONS = "a. b(5). #module aSimpleModule(input/1 => {out1/2, out2/3}) { p(a). p(b). q(X) :- p(X). } q(Y) :- r(S, Y), t(S). #module anotherModule(input/1 => {out1/2, out2/3}) { p(a). p(b). q(X) :- p(X). }" ;
100
96
101
97
private static final String MODULE_LITERAL = "p(a). q(b). r(X) :- p(X), q(Y), #mod[X, Y](X)." ;
102
98
@@ -336,11 +332,9 @@ public void simpleModule() {
336
332
assertEquals (1 , modules .size ());
337
333
Module module = modules .get (0 );
338
334
assertEquals ("aSimpleModule" , module .getName ());
339
- Set <Predicate > inputSpec = module .getInputSpec ();
340
- assertEquals (1 , inputSpec .size ());
341
- Predicate inputPredicate = inputSpec .iterator ().next ();
342
- assertEquals ("input" , inputPredicate .getName ());
343
- assertEquals (1 , inputPredicate .getArity ());
335
+ Predicate inputSpec = module .getInputSpec ();
336
+ assertEquals ("input" , inputSpec .getName ());
337
+ assertEquals (1 , inputSpec .getArity ());
344
338
Set <Predicate > outputSpec = module .getOutputSpec ();
345
339
assertEquals (2 , outputSpec .size ());
346
340
assertTrue (outputSpec .contains (Predicates .getPredicate ("out1" , 2 )));
@@ -358,11 +352,9 @@ public void moduleOutputAll() {
358
352
assertEquals (1 , modules .size ());
359
353
Module module = modules .get (0 );
360
354
assertEquals ("mod" , module .getName ());
361
- Set <Predicate > inputSpec = module .getInputSpec ();
362
- assertEquals (1 , inputSpec .size ());
363
- Predicate inputPredicate = inputSpec .iterator ().next ();
364
- assertEquals ("in" , inputPredicate .getName ());
365
- assertEquals (1 , inputPredicate .getArity ());
355
+ Predicate inputSpec = module .getInputSpec ();
356
+ assertEquals ("in" , inputSpec .getName ());
357
+ assertEquals (1 , inputSpec .getArity ());
366
358
assertTrue (module .getOutputSpec ().isEmpty ());
367
359
InputProgram implementation = module .getImplementation ();
368
360
assertEquals (1 , implementation .getFacts ().size ());
@@ -379,11 +371,9 @@ public void moduleAndRegularStmts() {
379
371
assertEquals (1 , modules .size ());
380
372
Module module = modules .get (0 );
381
373
assertEquals ("aSimpleModule" , module .getName ());
382
- Set <Predicate > inputSpec = module .getInputSpec ();
383
- assertEquals (1 , inputSpec .size ());
384
- Predicate inputPredicate = inputSpec .iterator ().next ();
385
- assertEquals ("input" , inputPredicate .getName ());
386
- assertEquals (1 , inputPredicate .getArity ());
374
+ Predicate inputSpec = module .getInputSpec ();
375
+ assertEquals ("input" , inputSpec .getName ());
376
+ assertEquals (1 , inputSpec .getArity ());
387
377
Set <Predicate > outputSpec = module .getOutputSpec ();
388
378
assertEquals (2 , outputSpec .size ());
389
379
assertTrue (outputSpec .contains (Predicates .getPredicate ("out1" , 2 )));
@@ -407,42 +397,13 @@ public void multipleModuleDefinitions() {
407
397
@ Test
408
398
public void invalidNestedModule () {
409
399
assertThrows (IllegalStateException .class , () ->
410
- parser .parse ("#module aSimpleModule({ input/1} => {out1/2, out2/3}) { p(a). p(b). #module anotherModule({ input/1} => {out1/2, out2/3}) { p(a). p(b). } }" ));
400
+ parser .parse ("#module aSimpleModule(input/1 => {out1/2, out2/3}) { p(a). p(b). #module anotherModule(input/1 => {out1/2, out2/3}) { p(a). p(b). } }" ));
411
401
}
412
402
413
403
@ Test
414
404
public void invalidNestedTest () {
415
405
assertThrows (IllegalStateException .class , () ->
416
- parser .parse ("#module mod({foo/1} => {*}) { #test test(expect: 1) { given { b. } assertForAll { :- a. } } }" ));
417
- }
418
-
419
- @ Test
420
- public void emptyInputSpec () {
421
- InputProgram prog = parser .parse (MODULE_EMPTY_INPUT_SPEC );
422
- List <Module > modules = prog .getModules ();
423
- assertEquals (1 , modules .size ());
424
- Module module = modules .get (0 );
425
- assertEquals ("someModule" , module .getName ());
426
- Set <Predicate > inputSpec = module .getInputSpec ();
427
- assertTrue (inputSpec .isEmpty ());
428
- Set <Predicate > outputSpec = module .getOutputSpec ();
429
- assertTrue (outputSpec .isEmpty ());
430
- }
431
-
432
- @ Test
433
- public void multipleInputs () {
434
- InputProgram prog = parser .parse (MODULE_MULTIPLE_INPUTS );
435
- List <Module > modules = prog .getModules ();
436
- assertEquals (1 , modules .size ());
437
- Module module = modules .get (0 );
438
- assertEquals ("someModule" , module .getName ());
439
- Set <Predicate > inputSpec = module .getInputSpec ();
440
- assertEquals (2 , inputSpec .size ());
441
- assertTrue (inputSpec .contains (Predicates .getPredicate ("input" , 1 )));
442
- assertTrue (inputSpec .contains (Predicates .getPredicate ("input2" , 2 )));
443
- Set <Predicate > outputSpec = module .getOutputSpec ();
444
- assertEquals (1 , outputSpec .size ());
445
- assertTrue (outputSpec .contains (Predicates .getPredicate ("out1" , 2 )));
406
+ parser .parse ("#module mod(foo/1 => {*}) { #test test(expect: 1) { given { b. } assertForAll { :- a. } } }" ));
446
407
}
447
408
448
409
@ Test
0 commit comments