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_subtract(self): f = Foobar() self.assertNodeOutput("$sub($one(),3)", f.one() - 3)
def test_mul(self): f = Foobar() self.assertNodeOutput("$mul($one(),3)", f.one() * 3)
def test_div(self): f = Foobar() self.assertNodeOutput("$div($one(),3)", f.one() / 3)
def test_add(self): f = Foobar() self.assertNodeOutput("$add($one(),3)", f.one() + 3)