Permalink
Browse files

[t/spec] Few more tests for auto-threading, these ones covering auto-…

…threading of methods.

git-svn-id: http://svn.pugscode.org/pugs@24957 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
1 parent 4c677e8 commit 5c2c4cd70835d0ed43b7cc0e189d416c2c44e550 jnthn committed Jan 19, 2009
Showing with 24 additions and 1 deletion.
  1. +24 −1 S03-junctions/autothreading.t
@@ -1,7 +1,7 @@
use v6;
use Test;
-plan 2;
+plan 6;
{
# Solves the equatioin A + B = A * C for integers
@@ -27,3 +27,26 @@ plan 2;
ok( $answer eq "1 + 9 = 10", "found right answer");
}
+{
+ # Checks auto-threading works on method calls too, and that we get the
+ # right result.
+ class Foo {
+ has $.count = 0;
+ method test($x) { $!count++; return $x }
+ }
+
+ my ($x, $r, $ok);
+ $x = Foo.new;
+ $r = $x.test(1|2);
+ is($x.count, 2, 'method called right number of times');
+ $ok = $r.perl.subst(/\D/, '', :g) eq '12' | '21';
+ ok(?$ok, 'right values passed to method');
+
+ $x = Foo.new;
+ $r = $x.test(1 & 2 | 3);
+ is($x.count, 3, 'method called right number of times');
+ $ok = $r.perl.subst(/\D/, '', :g) eq '123' | '213' | '312' | '321'; # e.g. & values together
+ ok(?$ok, 'junction structure maintained');
+}
+
+

0 comments on commit 5c2c4cd

Please sign in to comment.