private void parseTerm(String term, String sort, K expected) { parseTerm(term, sort, expected, 0); }
@Test public void testEmptyList1() { parseTerm(".As", "As", NIL); }
@Test public void testConcreteTop() { parseTerm(".As", "As", NIL); parseTerm("a,a", "As", KApply(CONS, A, KApply(CONS, A, NIL))); parseTerm("a,.As", "As", KApply(CONS, A, NIL)); parseTerm("a,b", "As", KApply(CONS, A, KApply(CONS, B, NIL))); parseTerm("b,.Bs", "As", KApply(CONS, B, NIL)); parseTerm("b,b", "As", KApply(CONS, B, KApply(CONS, B, NIL))); }
@Test public void testArgumentLabeledNil() { parseTerm("f(`.List{\"_,__TEST\"}`(.KList))", "K", KApply(F, NIL)); }
@Test public void testArgumentLabeledNilSub1() { parseTerm("h(`.List{\"_,__TEST\"}`(.KList))", "K", KApply(H, NIL)); }
@Test public void testConcreteArgument() { parseTerm("f(.As)", "K", KApply(F, NIL)); parseTerm("f(a)", "K", KApply(F, KApply(CONS, A, NIL))); parseTerm("f(a,a)", "K", KApply(F, KApply(CONS, A, KApply(CONS, A, NIL)))); parseTerm("f(a,.As)", "K", KApply(F, KApply(CONS, A, NIL))); parseTerm("f(a,b)", "K", KApply(F, KApply(CONS, A, KApply(CONS, B, NIL)))); parseTerm("f(b,.Bs)", "K", KApply(F, KApply(CONS, B, NIL))); parseTerm("f(b,b)", "K", KApply(F, KApply(CONS, B, KApply(CONS, B, NIL)))); }
@Test public void testLabedFunConcreteArgument() { parseTerm("`f`(.As)", "K", KApply(F, NIL)); parseTerm("`f`((a,a))", "K", KApply(F, KApply(CONS, A, KApply(CONS, A, NIL)))); parseTerm("`f`((a,.As))", "K", KApply(F, KApply(CONS, A, NIL))); parseTerm("`f`((a,b))", "K", KApply(F, KApply(CONS, A, KApply(CONS, B, NIL)))); parseTerm("`f`((b,.Bs))", "K", KApply(F, KApply(CONS, B, NIL))); parseTerm("`f`((b,b))", "K", KApply(F, KApply(CONS, B, KApply(CONS, B, NIL)))); }
@Test public void testArgumentLabeledConsSub2() { // gets a warning because the argument of sort As does not fit.n parseTerm("h(`_,__TEST`(a,.As))", "K", KApply(H, KApply(CONS, A, NIL)), 1); }
@Test public void testAnnVar() { parseTerm("V:As", "K", KApply(CAST_AS, KVariable("V"))); }
@Ignore("The API of AddEmptyLists needs to change for this to be possible") @Test public void testItem() { parseTerm("a", "As", KApply(CONS, A, NIL)); }
@Test public void testArgumentLabeledCons() { parseTerm("f(`_,__TEST`(a,.As))", "K", KApply(F, KApply(CONS, A, NIL))); }
@Test public void testArgumentLabeledConsSub1() { parseTerm("h(`_,__TEST`(b,.Bs))", "K", KApply(H, KApply(CONS, B, NIL))); }
@Test public void testArgumentInferredListVar() { // 1 warning from inference parseTerm("f(V)", "K", KApply(F, KApply(CAST_AS, KVariable("V"))), 1); }
@Ignore("BUG: need to also propagate correct sorts to arguments of labeled application") @Test public void testLabeledFunSingleItem() { parseTerm("`f`(a)", "K", KApply(F, KApply(CONS, A, NIL))); }
@Test public void testArgumentAnnListVar() { parseTerm("f(V:As)", "K", KApply(F, KApply(CAST_AS, KVariable("V")))); }
@Test public void testArgumentAnnSubListVar() { parseTerm("f(V:Bs)", "K", KApply(F, KApply(CAST_BS, KVariable("V")))); }
@Test public void testArgumentAnnItemVar() { parseTerm("f(V:A)", "K", KApply(F, KApply(CONS, KApply(CAST_A, KVariable("V")), NIL))); }
@Test public void testArgumentAnnSubItemVar() { parseTerm("f(V:B)", "K", KApply(F, KApply(CONS, KApply(CAST_B, KVariable("V")), NIL))); } }
@Test public void testArgumentInferredItemVar() { // 1 warning from inference parseTerm("f(V)~>g(V)", "K", KSequence(KApply(F, KApply(CONS, KApply(CAST_A, KVariable("V")), NIL)), KApply(G, KApply(CAST_A, KVariable("V")))), 1); }