Skip to content
Browse files

Muck around unsuccessfully with prefix +.

  • Loading branch information...
1 parent ee9c26f commit 85bd658fd86ba8f3ff112049ec02e5ded2ad0187 @LastOfTheCarelessMen committed Aug 30, 2009
Showing with 11 additions and 0 deletions.
  1. +5 −0 lib/Vector.pm
  2. +6 −0 t/01-basics.t
View
5 lib/Vector.pm
@@ -61,6 +61,11 @@ class Vector is also
}
}
+# multi sub prefix:<+>(Vector $a)
+# {
+# $a;
+# }
+
multi sub infix:<+>(Vector $a, Vector $b where { $a.Dim == $b.Dim })
{
Vector.new($a.coordinates »+« $b.coordinates);
View
6 t/01-basics.t
@@ -78,6 +78,7 @@ for @vectors -> $v
{
is_approx($v.Length ** 2, ⎡$v*$v ⎤, "v.Length squared equals ⎡v ⎤ squared");
is_approx($v.Length ** 2, $v$v, "v.Length squared equals v ⋅ v");
+ # is_approx(abs($v) ** 2, $v ⋅ $v, "abs(v) squared equals v ⋅ v");
}
for @vectors -> $v
@@ -175,6 +176,11 @@ dies_ok( { $v5 cross $v6 }, "You can't do 5D cross products");
dies_ok( { $a += $v2; }, "Catch if += violates the UnitVector constraint");
}
+# test prefix plus
+# isa_ok(+$v1, Vector, "Prefix + works on the Vector class");
+dies_ok( { $v1.Num; }, "Make sure .Num does not work on 3D vector");
+
+# test extensions
class VectorWithLength is Vector
{
has $.length;

0 comments on commit 85bd658

Please sign in to comment.
Something went wrong with that request. Please try again.