Permalink
Browse files

[t/spec] clean up some junction testing mess

since eigenstates are now private, it's WRONG to rely on them heavily, even if
we may later on obtain a way to ask for them via monkey typing.

Also adds some rakudo skips. Needs more cleanups.

git-svn-id: http://svn.pugscode.org/pugs@28972 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
moritz
moritz committed Nov 1, 2009
1 parent ffa7511 commit 46b247a92587c56859feda5890e45d0d988aa1f2
Showing with 16 additions and 59 deletions.
  1. +6 −10 S03-junctions/associative.t
  2. +3 −5 S03-junctions/autothreading.t
  3. +0 −43 S03-junctions/basic.t
  4. +7 −1 S03-junctions/boolean-context.t
@@ -2,15 +2,15 @@ use v6;
use Test;
-plan 14;
+plan *;
# Checking Junctions' Associativeness
# TODO: need smartlink
sub jv(Object $j) {
- return $j!eigenstates.sort.join(' ');
-
-
+ my @e;
+ (-> Any $x { @e.push: $x }).($j);
+ return @e.sort.join(' ');
}
# L<S03/"Junctive operators">
@@ -29,15 +29,11 @@ sub jv(Object $j) {
is('1 2 3', jv(all(all(1,2),3)), "Left-associative all()");
is('1 2 3', jv(all(1,all(2,3))), "Right-associative all()");
- isnt('1 2 3', jv((1^2)^3), "Left-associative one, ^ operator");
- isnt('1 2 3', jv(1^(2^3)), "Right-associative one, ^ operator");
-
- isnt('1 2 3', jv(one(one(1,2),3)), "Left-associative one()");
- isnt('1 2 3', jv(one(1,one(2,3))), "Right-associative one()");
-
is('1 2 3', jv(none(none(1,2),3)), "Left-associative none()");
is('1 2 3', jv(none(1,none(2,3))), "Right-associative none()");
}
+done_testing();
+
# vim: ft=perl6
@@ -1,7 +1,7 @@
use v6;
use Test;
-plan 78;
+plan 77;
{
# Solves the equation A + B = A * C for integers
@@ -204,12 +204,10 @@ plan 78;
# test that various things autothread
+#?rakudo skip 'auto-threading over prefix:<+>'
{
- my junction $j = [1, 2] | 5;
- #?rakudo skip '.values and !eigenstates should flatten (?)'
- is +$j.values!eigenstates, 3, '([1, 2] | 3).values has three eigenstates';
+ my $j = [1, 2] | 5;
- #?rakudo 3 skip 'autothreading of prefix:<+>'
ok ?( +$j == 5 ), 'prefix:<+> autothreads (1)';
ok ?( +$j == 2 ), 'prefix:<+> autothreads (2)';
ok !( +$j == 3 ), 'prefix:<+> autothreads (3)';
View
@@ -1,43 +0,0 @@
-use v6;
-
-use Test;
-
-plan 22;
-
-=begin pod
-
-More Junction Tests
-
-These tests are derived from the Perl6 and Parrot Essentials Chapter 4, page 42
-
-=end pod
-
-# L<S03/Junctive operators/>
-
-my $j = any(1, 2, 3);
-ok $j ~~ junction, '$j is a junction';
-
-my @values = $j!eigenstates.sort;
-is(+@values, 3, 'our junction has three values in it');
-
-is(@values[0], 1, 'our junctions first value is 1');
-is(@values[1], 2, 'our junctions second value is 2');
-is(@values[2], 3, 'our junctions third value is 3');
-
-my $sums = $j + 3;
-
-ok $sums ~~ junction, '$j + 3 is also a junction';
-
-my @sums_values = sort $sums!eigenstates;
-is(+@sums_values, 3, 'our junction has three values in it');
-is(@sums_values[0], 4, 'our junctions first value is 4');
-is(@sums_values[1], 5, 'our junctions second value is 5');
-is(@sums_values[2], 6, 'our junctions third value is 6');
-
-# loop enough to go through it twice
-for (1 .. 6) {
- ok((1 ^ 2 ^ 3) == $j!eigenstates.pick, 'it is always at least one');
- ok((1 | 2 | 3) == $j!eigenstates.pick, 'it is always one of them');
-}
-
-# vim: ft=perl6
@@ -58,13 +58,19 @@ ok ?(0|$undef == 0), '0|undef == 0 in boolean context';
my $message1 = 'boolean context collapses junctions';
my $message2 = '...so that they\'re not junctions anymore';
ok ?(Bool::True & Bool::False) == Bool::False, $message1;
+#?DOES 1
+#?rakudo skip 'junction type (lower case)'
ok ?(Bool::True & Bool::False) !~~ junction, $message2;
ok !(Bool::True & Bool::False) == Bool::True, $message1;
+#?DOES 1
+#?rakudo skip 'junction type (lower case)'
ok !(Bool::True & Bool::False) !~~ junction, $message2;
-#?rakudo 2 todo 'named unary as function call'
+#?rakudo todo 'named unary as function call'
ok true(Bool::True & Bool::False) == Bool::False, $message1;
+#?rakudo skip 'junction type (lower case)'
ok true(Bool::True & Bool::False) !~~ junction, $message2;
ok not(Bool::True & Bool::False) == Bool::True, $message1;
+#?rakudo skip 'junction type (lower case)'
ok not(Bool::True & Bool::False) !~~ junction, $message2;
# vim: ft=perl6

0 comments on commit 46b247a

Please sign in to comment.