Mercurial > lcfOS
comparison test/testir.py @ 317:e30a77ae359b
Added glue blocks
author | Windel Bouwman |
---|---|
date | Sun, 22 Dec 2013 15:50:59 +0100 |
parents | 68b01c8abf8a |
children | 86b02c98a717 |
comparison
equal
deleted
inserted
replaced
316:56e6ff84f646 | 317:e30a77ae359b |
---|---|
25 bb = self.b.newBlock() | 25 bb = self.b.newBlock() |
26 self.b.emit(ir.Jump(bb)) | 26 self.b.emit(ir.Jump(bb)) |
27 self.b.setBlock(bb) | 27 self.b.setBlock(bb) |
28 self.b.emit(ir.Exp(ir.Const(0))) | 28 self.b.emit(ir.Exp(ir.Const(0))) |
29 self.b.emit(ir.Jump(f.epiloog)) | 29 self.b.emit(ir.Jump(f.epiloog)) |
30 self.m.check() | |
31 # Run interpreter: | 30 # Run interpreter: |
32 # r = self.m.getFunction('add').call(1, 2) | 31 # r = self.m.getFunction('add').call(1, 2) |
33 #self.assertEqual(3, r) | 32 #self.assertEqual(3, r) |
34 | 33 |
35 | 34 |
36 class PatternMatchTestCase(unittest.TestCase): | 35 class PatternMatchTestCase(unittest.TestCase): |
36 @unittest.skip('Not yet implemented') | |
37 def testSimpleTree(self): | 37 def testSimpleTree(self): |
38 t = ir.Term('x') | 38 t = ir.Term('x') |
39 pat = ir.Binop(ir.Const(2), '+', t) | 39 pat = ir.Binop(ir.Const(2), '+', t) |
40 res, mp = ir.match_tree(ir.Binop(ir.Const(2), '+', 3), pat) | 40 res, mp = ir.match_tree(ir.Binop(ir.Const(2), '+', 3), pat) |
41 self.assertTrue(res) | 41 self.assertTrue(res) |
42 self.assertIn(t, mp) | 42 self.assertIn(t, mp) |
43 self.assertEqual(3, mp[t]) | 43 self.assertEqual(3, mp[t]) |
44 | 44 |
45 @unittest.skip('Not yet implemented') | |
45 def testSimpleTree2(self): | 46 def testSimpleTree2(self): |
46 t = ir.Term('x') | 47 t = ir.Term('x') |
47 t2 = ir.Term('y') | 48 t2 = ir.Term('y') |
48 pat = ir.Binop(ir.Const(2), '+', ir.Binop(t, '-', t2)) | 49 pat = ir.Binop(ir.Const(2), '+', ir.Binop(t, '-', t2)) |
49 res, mp = ir.match_tree(ir.Binop(ir.Const(2), '+', ir.Binop(2,'-',3)), pat) | 50 res, mp = ir.match_tree(ir.Binop(ir.Const(2), '+', ir.Binop(2,'-',3)), pat) |