Change 28404 broke the construct s/foo/<<BAR/e. So, try to be more
[p5sagit/p5-mst-13.2.git] / t / op / dor.t
index 2f918fc..04e0f7d 100644 (file)
@@ -8,9 +8,10 @@ BEGIN {
 }
 
 package main;
+use feature "err";
 require './test.pl';
 
-plan( tests => 25 );
+plan( tests => 35 );
 
 my($x);
 
@@ -23,6 +24,8 @@ is($x // 1, 1,                '       // : left-hand operand undef');
 $x='';
 is($x // 0, '',                '       // : left-hand operand defined but empty');
 
+like([] // 0, qr/^ARRAY/,      '       // : left-hand operand a referece');
+
 $x=1;
 is(($x err 0), 1,      '       err: left-hand operand defined');
 
@@ -32,16 +35,18 @@ is(($x err 1), 1,   '       err: left-hand operand undef');
 $x='';
 is(($x err 0), '',     '       err: left-hand operand defined but empty');
 
+like(([] err 0), qr/^ARRAY/,   '       err: left-hand operand a referece');
+
 $x=undef;
 $x //= 1;
 is($x, 1,              '       //=: left-hand operand undefined');
 
 $x //= 0;
-is($x, 1,              '       //=: left-hand operand defined');
+is($x, 1,              '//=: left-hand operand defined');
 
 $x = '';
 $x //= 0;
-is($x, '',             '       //=: left-hand operand defined but empty');
+is($x, '',             '//=: left-hand operand defined but empty');
 
 @ARGV = (undef, 0, 3);
 is(shift       // 7, 7,        'shift // ... works');
@@ -59,3 +64,22 @@ for (qw(getc pos readline readlink undef umask <> <FOO> <$foo> -f)) {
     eval "sub { $_ // 0 }";
     is($@, '', "$_ // ... compiles");
 }
+
+# Test for some ambiguous syntaxes
+
+eval q# sub f ($) { } f $x / 2; #;
+is( $@, '' );
+eval q# sub f ($):lvalue { $y } f $x /= 2; #;
+is( $@, '' );
+eval q# sub f ($) { } f $x /2; #;
+like( $@, qr/^Search pattern not terminated/ );
+eval q# sub { print $fh / 2 } #;
+is( $@, '' );
+eval q# sub { print $fh /2 } #;
+like( $@, qr/^Search pattern not terminated/ );
+
+# [perl #28123] Perl optimizes // away incorrectly
+
+is(0 // 2, 0,          '       // : left-hand operand not optimized away');
+is('' // 2, '',                '       // : left-hand operand not optimized away');
+is(undef // 2, 2,      '       // : left-hand operand optimized away');