use of at.ac.tuwien.kr.alpha.api.programs.atoms.ExternalAtom in project Alpha by alpha-asp.
the class ArithmeticTermsRewritingTest method rewriteExternalAtom.
@Test
public void rewriteExternalAtom() {
NormalProgram inputProgram = NormalProgramImpl.fromInputProgram(parser.parse("p :- Y = 13, &extArithTest[Y*5](Y-4)."));
assertEquals(1, inputProgram.getRules().size());
ArithmeticTermsRewriting arithmeticTermsRewriting = new ArithmeticTermsRewriting();
NormalProgram rewrittenProgram = arithmeticTermsRewriting.apply(inputProgram);
assertEquals(1, rewrittenProgram.getRules().size());
NormalRule rewrittenRule = rewrittenProgram.getRules().get(0);
assertEquals(4, rewrittenRule.getBody().size());
List<Literal> externalLiterals = rewrittenRule.getBody().stream().filter(lit -> lit instanceof ExternalLiteral).collect(toList());
assertEquals(1, externalLiterals.size());
ExternalAtom rewrittenExternal = ((ExternalLiteral) externalLiterals.get(0)).getAtom();
assertEquals(1, rewrittenExternal.getInput().size());
assertTrue(rewrittenExternal.getInput().get(0) instanceof VariableTerm);
assertEquals(1, rewrittenExternal.getOutput().size());
assertTrue(rewrittenExternal.getOutput().get(0) instanceof VariableTerm);
}
use of at.ac.tuwien.kr.alpha.api.programs.atoms.ExternalAtom in project Alpha by alpha-asp.
the class AtomsTest method testExternalHasOutput.
@Test
public void testExternalHasOutput() {
ASPCore2Program p = parser.parse("a:- &extWithOutput[1](OUT).", externals);
Atom ext = p.getRules().get(0).getBody().stream().findFirst().get().getAtom();
assertExternalAtomGround(ext, false);
assertTrue(((ExternalAtom) ext).hasOutput());
}
Aggregations