use of suite.node.Node in project suite by stupidsing.
the class TextTest method testSh.
@Test
public void testSh() throws IOException {
Node node = Suite.applyPerform(Suite.parse("sh {\"git status\"} {}"), Atom.of("any"));
StringWriter writer = new StringWriter();
Suite.evaluateFunToWriter(Suite.fcc(Suite.applyWriter(node)), writer);
String out = writer.toString();
System.out.println(out);
assertNotNull(out);
}
use of suite.node.Node in project suite by stupidsing.
the class IntrinsicTest method testCharsReplace.
@Test
public void testCharsReplace() {
String fp = "cs-replace {\"abc\" | cs-from-string} {\"def\" | cs-from-string} {\"012abcdefghi\" | cs-from-string} | cs-to-string";
Node expect = Suite.evaluateFun("\"012defdefghi\"", true);
Node actual = Suite.evaluateFun(fp, true);
assertTrue(Comparer.comparer.compare(expect, actual) == 0);
}
use of suite.node.Node in project suite by stupidsing.
the class FunCreatorTest method testExpression.
@Test
public void testExpression() {
Int N1 = Int.of(1);
@SuppressWarnings({ "rawtypes", "unchecked" }) FunCreator<Source<Node>> fc = (FunCreator) FunCreator.of(Source.class);
assertEquals(Suite.parse("1"), fc.create(() -> f.object(N1)).apply(void_).source());
assertEquals(Suite.parse("1 + 1"), fc.create(() -> //
f.invokeStatic(//
Tree.class, //
"of", //
f.object(TermOp.PLUS__), //
f.object(N1).cast_(Node.class), //
f.object(N1).cast_(Node.class))).apply(//
void_).source());
}
use of suite.node.Node in project suite by stupidsing.
the class LogicCompilerLevel1Test method testCompileFunProgram.
/**
* Compiles the functional compiler and use it to compile a simple functional
* program.
*/
@Test
public void testCompileFunProgram() {
RuleSet rs = Suite.newRuleSet(List.of("auto.sl", "fc/fc.sl"));
String gs = //
"" + //
"source .in" + //
", compile-function .0 .in .out" + ", sink .out";
Node goal = new Specializer().specialize(Suite.substitute(gs, Atom.of("LAZY")));
Node input = Suite.parse("1 + 2");
Node result = FindUtil.collectSingle(finder(rs, goal), input);
System.out.println(result);
assertNotNull(result);
}
use of suite.node.Node in project suite by stupidsing.
the class LogicCompilerLevel1Test method testTailCalls.
/**
* This test might fail in some poor tail recursion optimization
* implementations, as some variables are not unbounded when backtracking.
*/
@Test
public void testTailCalls() {
RuleSet rs = Suite.newRuleSet();
Suite.addRule(rs, "ab a");
Suite.addRule(rs, "ab b");
Node goal = Suite.parse("ab .a, ab .b, sink (.a, .b,)");
List<Node> results = FindUtil.collectList(finder(rs, goal), Atom.NIL);
System.out.println(results);
assertTrue(results.size() == 4);
}
Aggregations