Permalink
Browse files

Perlito5 - add more context tests

  • Loading branch information...
1 parent ef3e675 commit 75e269373c3d91826c552f9673ad03d91ccf3027 @fglock committed Sep 7, 2012
Showing with 34 additions and 0 deletions.
  1. +34 −0 t5/01-perlito/13-op-context.t
@@ -0,0 +1,34 @@
+use strict;
+use feature 'say';
+
+print "1..12\n";
+
+sub foo {
+ my $num = shift;
+ my $expected = shift;
+ my $result = wantarray ? "LIST" : defined wantarray ? "SCALAR" : "VOID";
+ print "not " if $result ne $expected;
+ say "ok $num # expected: $expected got: $result";
+}
+
+my $x;
+my @x;
+
+foo( 1, "SCALAR" ) or 1;
+0 or foo( 2, "VOID" );
+
+$x = foo( 3, "SCALAR" ) || 1;
+$x = 0 || foo( 4, "SCALAR" );
+
+@x = foo( 5, "SCALAR" ) || 1;
+@x = 0 || foo( 6, "LIST" );
+
+foo( 7, "SCALAR" ) and 1;
+1 and foo( 8, "VOID" );
+
+$x = 1 && foo( 9, "SCALAR" );
+$x = foo( 10, "SCALAR" ) && 1;
+
+@x = 1 && foo( 11, "LIST" );
+@x = foo( 12, "SCALAR" ) && 1;
+

0 comments on commit 75e2693

Please sign in to comment.