use of at.ac.tuwien.kr.alpha.commons.AnswerSetBuilder in project Alpha by alpha-asp.
the class AnswerSetToWorkbookMapperTest method smokeTest.
@Test
public void smokeTest() throws IOException {
AnswerSet as = new AnswerSetBuilder().predicate("bla").instance("blubb", "blubb").instance("foo", "bar").predicate("foo").instance("bar").instance("baz").predicate("complex").instance(Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3)).build();
try (Workbook wb = this.mapper.mapFromAnswerSet(as)) {
assertNotNull(wb.getSheet("Flags"));
assertNotNull(wb.getSheet("bla_2"));
assertNotNull(wb.getSheet("foo_1"));
assertNotNull(wb.getSheet("complex_3"));
}
}
use of at.ac.tuwien.kr.alpha.commons.AnswerSetBuilder in project Alpha by alpha-asp.
the class SimpleAnswerSetFormatterTest method basicFormatterWithSeparator.
@Test
public void basicFormatterWithSeparator() {
AnswerSetFormatter<String> fmt = new SimpleAnswerSetFormatter(" bla ");
AnswerSet as = new AnswerSetBuilder().predicate("p").instance("a").predicate("q").instance("b").build();
String formatted = fmt.format(as);
assertEquals("{ p(\"a\") bla q(\"b\") }", formatted);
}
use of at.ac.tuwien.kr.alpha.commons.AnswerSetBuilder in project Alpha by alpha-asp.
the class AlphaImplTest method basicUsage.
@Test
public void basicUsage() throws Exception {
Alpha system = new AlphaImpl();
Set<AnswerSet> actual = system.solve(system.readProgram(InputConfig.forString("p(a)."))).collect(Collectors.toSet());
Set<AnswerSet> expected = new HashSet<>(singletonList(new AnswerSetBuilder().predicate("p").symbolicInstance("a").build()));
assertEquals(expected, actual);
}
use of at.ac.tuwien.kr.alpha.commons.AnswerSetBuilder in project Alpha by alpha-asp.
the class AlphaImplTest method withExternal.
@Test
public void withExternal() throws Exception {
Alpha alpha = new AlphaImpl();
InputConfig inputCfg = InputConfig.forString("a :- &isOne[1].");
inputCfg.addPredicateMethod("isOne", Externals.processPredicateMethod(this.getClass().getMethod("isOne", int.class)));
ASPCore2Program program = alpha.readProgram(inputCfg);
Set<AnswerSet> actual = alpha.solve(program).collect(Collectors.toSet());
Set<AnswerSet> expected = new HashSet<>(singletonList(new AnswerSetBuilder().predicate("a").build()));
assertEquals(expected, actual);
}
use of at.ac.tuwien.kr.alpha.commons.AnswerSetBuilder in project Alpha by alpha-asp.
the class AlphaImplTest method addsFacts.
@Test
public void addsFacts() {
Alpha system = new AlphaImpl();
Thingy a = new Thingy();
Thingy b = new Thingy();
List<Thingy> things = asList(a, b);
InputProgram program = InputProgram.builder().addFacts(Externals.asFacts(Thingy.class, things)).build();
Set<AnswerSet> actual = system.solve(program).collect(Collectors.toSet());
Set<AnswerSet> expected = new HashSet<>(singletonList(new AnswerSetBuilder().predicate("thingy").instance(a).instance(b).build()));
assertEquals(expected, actual);
}
Aggregations