Get the optree almost right
[p5sagit/Gather-Once.git] / t / basic.t
index ecaa468..c68402e 100644 (file)
--- a/t/basic.t
+++ b/t/basic.t
@@ -3,11 +3,11 @@ use warnings;
 use Test::More 0.89;
 
 use Gather::Once
-    block => 'with',
-    take  => 'iff',
+    block      => 'with',
+    take       => 'iff',
     topicalise => 1,
     predicate  => sub {
-        warn "$_[0] == $_[1]";
+        diag explain \@_;
         $_[0] == $_[1];
     };
 
@@ -15,6 +15,7 @@ my $n = 42;
 
 my @ret = with ($n) {
     warn 42;
+    iff (23) { 42 };
     iff (42) { 23 };
     warn 23;
     42;
@@ -22,6 +23,25 @@ my @ret = with ($n) {
 
 diag explain \@ret;
 
+done_testing;
+
+__END__
+
+my $pred = sub {};
+my @ret___ = do {
+    warn 42;
+    ($pred->($n, 23))
+        ? do { 42 }
+            : ($pred->($n, 42))
+                ? do { 23 }
+                    : do {
+                        warn 23;
+                        42;
+                    };
+};
+
+diag explain \@ret;
+
 use Gather::Once
     block => 'moo',
     take  => 'iff_',
@@ -39,6 +59,10 @@ my @ret_ = moo {
     iff_ (42) { 1, 2, 3 };
 };
 
+my @ret__ = do {
+    $pred->(42) ? do { 1, 2, 3 } : ()
+};
+
 diag explain \@ret_;
 
 done_testing;