l = factory.makeModuleList_Modules(mods[3]);
testAssert(l.isSortModuleList() == true, "is<type> test");
testAssert(l.isModules() == true, "is<cons> test");
String example = "[]";
ATerm termExample;
try {
termExample = factory.getPureFactory().parse(example);
testAssert(termExample != null, "need reference to prevent gc");
mods[4] = factory.makeModules();
}
catch (ClassCastException ex) {
testAssert(false, "ClassCastException occurred due to wrong equivalence implementation");
}
example = "\"amodule\"";
termExample = factory.getPureFactory().parse(example);
Module amodule = factory.makeModule_Default(example);
testAssert(amodule != null, "test cast");
ATerm pattern =
factory.getPureFactory().parse(
"[\"m1\",l(\"l1\"),\"sep\",l(\"l2\"),\"m2\",l(\"l3\"),\"sep\",l(\"l4\"),\"m3\",l(\"l5\"),\"sep\",l(\"l6\"),\"m4\"]");
Separated sep = factory.SeparatedFromTerm(pattern);
testAssert(sep.toTerm().isEqual(pattern), " fromTerm == toTerm separated lists");
ATerm patternReversed =
factory.getPureFactory().parse(
"[\"m4\",l(\"l5\"),\"sep\",l(\"l6\"),\"m3\",l(\"l3\"),\"sep\",l(\"l4\"),\"m2\",l(\"l1\"),\"sep\",l(\"l2\"),\"m1\"]");
Separated sepReversed = factory.SeparatedFromTerm(patternReversed);
testAssert(sep.reverse().isEqual(sepReversed), " separated reverse test");
testAssert(sep.reverseSeparated().toTerm().isEqual(patternReversed), "separated reverse toTerm test");
Module head = sep.getHead();
testAssert(head.isEqual(factory.makeModule_Default("m1")), "separator from term test, head");
Layout l1 = sep.getWsl();
testAssert(l1.isEqual(factory.makeLayout_Default("l1")), "getSeparator test l1");
Layout l2 = sep.getWsr();
testAssert(l2.isEqual(factory.makeLayout_Default("l2")), "getSeparator test l2");
Module second = sep.getTail().getHead();
testAssert(second.isEqual(factory.makeModule_Default("m2")), "separator from term test, second element");
Layout l3 = sep.getTail().getWsl();
testAssert(l3.isEqual(factory.makeLayout_Default("l3")), "getSeparator test l3");
Layout l4 = sep.getTail().getWsr();
testAssert(l4.isEqual(factory.makeLayout_Default("l4")), "getSeparator test l4");
testAssert(sep.getLength() == 4, "separated list length test");
sep = factory.makeSeparated();
testAssert(sep.toTerm().isEqual(factory.getPureFactory().makeList()), "empty separated list");
m = factory.makeModule_Default("m");
sep = factory.makeSeparated(m);
testAssert(sep.toTerm().isEqual(factory.getPureFactory().makeList(m.toTerm())), "singleton separated list");
Module m2 = factory.makeModule_Default("m2");
l1 = factory.makeLayout_Default("l1");
l2 = factory.makeLayout_Default("l2");
sep = factory.makeSeparated(m, l1, l2, factory.makeSeparated(m2));
ATerm p = factory.getPureFactory().parse("[\"m\",l(\"l1\"),\"sep\",l(\"l2\"),\"m2\"]");
testAssert(sep.toTerm().isEqual(p), "many separated list");
ATerm pc =
((ATermList) p).concat((ATermList) factory.getPureFactory().parse("[l(\"l1\"),\"sep\",l(\"l2\")]")).concat(
(ATermList) p);
testAssert(factory.concat(sep, l1, l2, sep).toTerm().isEqual(pc), "concat test");
testMakeLists();