public Sentence concretize(Sentence s) { s = addRootCell.addImplicitCells(s); s = addParentCells.concretize(s); s = closeCells.close(s); s = sortCells.preprocess(s); s = sortCells.sortCells(s); s = sortCells.postprocess(s); return s; } }
@Test public void testClosedCellError1() { K term = cell("<thread>", cell("<k>")); exception.expect(KEMException.class); exception.expectMessage("Closed parent cell missing required children [EnvCell]"); new CloseCells(cfgInfo, sortInfo, labelInfo).close(term); }
@Test public void testSimpleClosure() { K term = cell("<k>", false, true, KApply(KLabel("_+_"), KVariable("I"), KVariable("J"))); K expected = ccell("<k>", KSequence(KApply(KLabel("_+_"), KVariable("I"), KVariable("J")), KVariable("DotVar0"))); Assert.assertEquals(expected, new CloseCells(cfgInfo, sortInfo, labelInfo).close(term)); }
@Test public void testCloseMap() { K term = cell("<env>", true, false, KApply(KLabel("'_|=>_"), intToToken(1), intToToken(2))); K expected = ccell("<env>", KApply(KLabel("_Map_"), KApply(KLabel("'_|=>_"), intToToken(1), intToToken(2)), KVariable("DotVar0"))); Assert.assertEquals(expected, new CloseCells(cfgInfo, sortInfo, labelInfo).close(term)); }
@Test public void testCloseCellVar() { K term = KApply(KLabels.CELLS, cell("<thread>", true, false, cell("<k>", intToToken(1))), cell("<thread>", false, true, cell("<k>", intToToken(2))), cell("<thread>", true, true, cell("<k>", intToToken(2)))); K expected = KApply(KLabels.CELLS, ccell("<thread>", ccell("<k>", intToToken(1)), KVariable("DotVar0")), ccell("<thread>", ccell("<k>", intToToken(2)), KVariable("DotVar1")), ccell("<thread>", ccell("<k>", intToToken(2)), KVariable("DotVar2"))); Assert.assertEquals(expected, new CloseCells(cfgInfo, sortInfo, labelInfo).close(term)); }
@Test public void testCloseList() { K term = KApply(KLabels.CELLS, cell("<list>", true, false, intToToken(1)), cell("<list>", false, true, intToToken(2)), cell("<list>", true, true, intToToken(3))); K expected = KApply(KLabels.CELLS, ccell("<list>", KApply(KLabel("_List_"), KVariable("DotVar0"), intToToken(1))), ccell("<list>", KApply(KLabel("_List_"), intToToken(2), KVariable("DotVar1"))), ccell("<list>", KApply(KLabel("_List_"), KVariable("DotVar2"), KApply(KLabel("_List_"), intToToken(3), KVariable("DotVar3"))))); Assert.assertEquals(expected, new CloseCells(cfgInfo, sortInfo, labelInfo).close(term)); }
@Test public void testCloseCellTerm() { K term = KRewrite(cells(), cells(cell("<thread>", true, false, cell("<k>", intToToken(1))), cell("<thread>", false, true, cell("<k>", intToToken(2))), cell("<thread>", true, true, cell("<env>", intToToken(2))))); K expected = KRewrite(cells(), cells(ccell("<thread>", ccell("<k>", intToToken(1)), ccell("<env>", KApply(KLabel(".Map")))), ccell("<thread>", ccell("<k>", intToToken(2)), ccell("<env>", KApply(KLabel(".Map")))), ccell("<thread>", ccell("<env>", intToToken(2)), ccell("<k>", stringToToken("defaultK"))))); Assert.assertEquals(expected, new CloseCells(cfgInfo, sortInfo, labelInfo).close(term)); }