use of suite.node.Node in project suite by stupidsing.
the class RecursiveFactorizerTest method operatorNode.
private Node operatorNode(Source<Node> g, TermOp op, Node n0, Node n1) {
Str name = new Str(op.toString());
List<Node> nodes = List.of(n0, terminalNode(op.getName().trim()), n1);
return treeNode(g, name, nodes);
}
use of suite.node.Node in project suite by stupidsing.
the class FunctionalTemplateRendererTest method test.
@Test
public void test() {
List<Node> fruits = Arrays.<Node>asList(new Str("orange"), new Str("apple"), new Str("pear"));
Map<String, Node> map = //
Read.from2(//
List.of(//
Pair.of("list", Tree.of(TermOp.OR____, fruits)), //
Pair.of("title", new Str("My favourite things")))).collect(As::map);
System.out.println(//
new FunctionalTemplateRenderer().render(//
"" + //
"<html> \n" + //
" <head> \n" + //
" <#= title #> \n" + //
" </head> \n" + //
" </body> \n" + //
" Fruits: \n" + //
"<# . (list | apply . map {fruit => id#> <li><#= fruit #></li> \n" + //
"<#}) #> <body> \n" + //
"</html> \n", map));
}
use of suite.node.Node in project suite by stupidsing.
the class Fun23TreeTest method test.
@Test
public void test() throws IOException {
int n = 100;
String list100 = "0 until " + n + " | map {insert} | apply | {Tree (9999, Empty;)}";
Node fp0 = Suite.substitute("use 23-TREE >> " + list100);
Node result0 = Suite.evaluateFun(Suite.fcc(fp0, false));
String out0 = Formatter.dump(result0);
System.out.println("OUT:\n" + out0);
int nPars0 = Read.from(String_.chars(out0)).filter(c -> c == '(').size();
assertTrue(3 <= nPars0);
Node fp1 = Suite.substitute("use 23-TREE >> 0 until " + n / 2 + " | map {remove} | apply | {" + list100 + "}");
Node result1 = Suite.evaluateFun(Suite.fcc(fp1, false));
String out1 = Formatter.dump(result1);
System.out.println("OUT:\n" + out1);
int nPars1 = Read.from(String_.chars(out1)).filter(c -> c == '(').size();
assertTrue(3 <= nPars1);
}
use of suite.node.Node in project suite by stupidsing.
the class FunTypeTest method checkType.
private void checkType(String fps, String bindTo, String ts) {
Trail trail = new Trail();
Node type = getType(fps);
assertTrue(Binder.bind(type, SewingGeneralizerImpl.generalize(Suite.parse(bindTo)), trail));
assertTrue(Comparer.comparer.compare(Suite.parse(ts), type) == 0);
}
use of suite.node.Node in project suite by stupidsing.
the class SuiteIntrinsicsTest method testSubstitute.
@Test
public void testSubstitute() {
String fp0 = //
"" + //
"use SUITE >> chars:\"1 + 2\" \n" + //
"| suite-parse \n" + //
"| (n => suite-substitute {chars:\"fn {.0}\"} {n;}) \n" + "| suite-to-chars";
Node n = Suite.evaluateFun(fp0, true);
assertEquals("fn {1 + 2}", Data.get(n).toString());
}
Aggregations