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))
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))
def test_keyword_args(self): f = Foobar() with self.assertRaises(FoobarException): f.foo(bar=5)
def test_nested(self): f = Foobar() self.assertNodeOutput("$foo(2,$bar('blah'),7)", f.foo(2, f.bar('blah'), 7))
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()))
def test_keyword_args(self): f = Foobar() with self.assertRaises(FoobarException): f.foo(bar=5)
def test_nested(self): f = Foobar() self.assertNodeOutput("$foo(2,$bar('blah'),7)", f.foo(2, f.bar('blah'), 7))