Trying to add a guard to combinators.

So they can notice if they're given a stack that doesn't match what
they're expecting.

This seems to work, but I realized that type variables in the pending
expression need to be update()'d too.  hmm...
This commit is contained in:
Simon Forman
2018-06-26 21:45:58 -07:00
parent bbc0fae2e9
commit db28989b64
2 changed files with 75 additions and 45 deletions
+10 -4
View File
@@ -54,9 +54,15 @@ class TestCombinators(TestMixin, unittest.TestCase):
self.assertEqualTypeStructure(infr(expression), f)
def test_cons_dip(self):
expression = a1, (cons, s0), dip # a1 [cons] dip
# (a0 [...0] -- [a0 ...0] a1)
f = ((s0, (a0, s1)), (a1, ((a0, s0), s1)))
expression = (cons, s0), dip # [cons] dip
# (a2 [...1] a1 -- [a2 ...1] a3)
f = (a1, (s1, (a2, s2))), (a1, ((a2, s1), s2))
# shouldn't a3 be a1?
self.assertEqualTypeStructure(infr(expression), [f])
def test_dip(self):
expression = dip,
f = ((s1, (a1, s2)), (a2, s2)) # (a1 [...1] -- a2)
self.assertEqualTypeStructure(infr(expression), [f])
def test_cons_dipd(self):
@@ -163,4 +169,4 @@ class TestYin(TestMixin, unittest.TestCase):
if __name__ == '__main__':
unittest.main()
unittest.main(defaultTest='TestCombinators.test_cons_dip')