def testInstanceBasics(self): value = 123 samer = Photon.ValueIdentity(value) self.assertEqual(samer.multiplicator(), 1) doubler = Photon.ValueDuplicator(value) self.assertEqual(doubler.multiplicator(), 2) self.assertEqual(samer.value(), doubler.value()) self.assertEqual(samer.calculate() * 2, doubler.calculate())
def testPassPointerThrough(self): obj1 = Photon.ValueIdentity(123) self.assertEqual(obj1, obj1.passPointerThrough(obj1)) obj2 = Photon.ValueDuplicator(321) self.assertEqual(obj2, obj2.passPointerThrough(obj2)) self.assertRaises(TypeError, obj1.passPointerThrough, obj2)
def testPassToMethodAsValue(self): value1, value2 = 123, 321 one = Photon.ValueIdentity(value1) other = Photon.ValueIdentity(value2) self.assertEqual(one.sumValueUsingPointer(other), value1 + value2)