Permalink
Browse files

[t/spec] autothreading prime test

git-svn-id: http://svn.pugscode.org/pugs@25575 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
moritz
moritz committed Feb 26, 2009
1 parent 6664f49 commit 9a049c7430e9842f67b2b7da3e2834bdf55d33ed
Showing with 16 additions and 1 deletion.
  1. +16 −1 S03-junctions/autothreading.t
@@ -1,7 +1,7 @@
use v6;
use Test;
-plan 55;
+plan 69;
{
# Solves the equatioin A + B = A * C for integers
@@ -214,3 +214,18 @@ plan 55;
ok ?( +$j == 2 ), 'prefix:<+> autothreads (2)';
ok !( +$j == 3 ), 'prefix:<+> autothreads (3)';
}
+
+# this is nothing new, but it's such a cool example for
+# autothreading that I want it to be in the test suite nonetheless ;-)
+{
+ sub primetest(Int $n) {
+ ?(none(2..$n) * any(2..$n) == $n);
+ };
+
+ # 2 3 4 5 6 7 8 9 10 11 12 13 14 15
+ my @is_prime = (1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0);
+
+ for @is_prime.kv -> $idx, $ref {
+ is +primetest($idx + 2), $ref, "primality test for { $idx + 2 } works";
+ }
+}

0 comments on commit 9a049c7

Please sign in to comment.