Exemple #1
0
 def test_multiple_memoizations(self):
     f = Foobar()
     m1 = f.memoize(f.one())
     m2 = f.memoize(f.two())
     self.assertNodeOutput("$put(v0,$one())", m1)
     self.assertNodeOutput("$put(v0,$two())", m2)
     self.assertNodeOutput("$put(v0,$one())", m1)
     self.assertNodeOutput("$put(v0,$two())", m2)
     self.assertNodeOutput("$foo($put(v0,$one()),$bar($get(v0),$put(v1,$two())),$get(v1))",
                           f.foo(m1, f.bar(m1, m2), m2))
Exemple #2
0
 def test_multiple_memoizations(self):
     f = Foobar()
     m1 = f.memoize(f.one())
     m2 = f.memoize(f.two())
     self.assertNodeOutput("$put(v0,$one())", m1)
     self.assertNodeOutput("$put(v0,$two())", m2)
     self.assertNodeOutput("$put(v0,$one())", m1)
     self.assertNodeOutput("$put(v0,$two())", m2)
     self.assertNodeOutput(
         "$foo($put(v0,$one()),$bar($get(v0),$put(v1,$two())),$get(v1))",
         f.foo(m1, f.bar(m1, m2), m2))
Exemple #3
0
 def test_nested(self):
     f = Foobar()
     self.assertNodeOutput("$foo(2,$bar('blah'),7)", f.foo(2, f.bar('blah'), 7))
Exemple #4
0
 def test_memoize(self):
     f = Foobar()
     self.assertEqualIncludingHash(f.memoize(f.foo()), f.memoize(f.foo()))
     self.assertNotEqualIncludingHash(f.memoize(f.foo()), f.memoize(f.bar()))
Exemple #5
0
 def test_nested(self):
     f = Foobar()
     self.assertNodeOutput("$foo(2,$bar('blah'),7)",
                           f.foo(2, f.bar('blah'), 7))