Fix broken PVector test.
MODIFY
runtime/src/jycessing/core.py
runtime/src/jycessing/core.py
@@ -59,6 +59,7 @@ class PVector(__pvector__):
self.x += args[0]
self.y += args[1]
self.z += args[2]
+ return self
def __instance_sub__(self, *args):
if len(args) == 1:
@@ -70,12 +71,13 @@ class PVector(__pvector__):
self.x -= args[0]
self.y -= args[1]
self.z -= args[2]
+ return self
def __instance_mult__(self, o):
- PVector.mult(self, o, self)
+ return PVector.mult(self, o, self)
def __instance_div__(self, f):
- PVector.div(self, f, self)
+ return PVector.div(self, f, self)
def __instance_cross__(self, o):
return PVector.cross(self, o, self)
@@ -104,6 +106,7 @@ class PVector(__pvector__):
else:
raise Exception('lerp takes either (x, y, z, t) or (v, t)')
__pvector__.lerp(self, x, y, z, t)
+ return self
def __init__(self, x=0, y=0, z=0):
__pvector__.__init__(self, x, y, z)

MODIFY
testing/resources/test_pvector.py
testing/resources/test_pvector.py
@@ -26,9 +26,6 @@ except TypeError:
c = PVector(310.0, 410.0, 570.0)
assert a * 10 == c
assert a * 10 == c
-copy_of_a = a
-assert copy_of_a.mult(10) == c
-assert copy_of_a.mult(10) == PVector.mult(c, 10)
assert PVector.mult(a, 10) == c
assert PVector.mult(a, 10) == c
a.mult(10)
@@ -133,6 +130,11 @@ assert end == PVector(100.0, 100.0)
end.lerp(200, 200, 0, .5)
assert end == PVector(150.0, 150.0)
+# test that instance op returns self
+a = PVector(3, 5, 7)
+b = a * 10
+assert a.mult(10) == b
+
print 'OK'
exit()

Fix broken PVector test.