package main;
require './test.pl';
-plan( tests => 9 );
+plan( tests => 30 );
my($x);
$x = '';
$x //= 0;
is($x, '', ' //=: left-hand operand defined but empty');
+
+@ARGV = (undef, 0, 3);
+is(shift // 7, 7, 'shift // ... works');
+is(shift() // 7, 0, 'shift() // ... works');
+is(shift @ARGV // 7, 3, 'shift @array // ... works');
+
+@ARGV = (3, 0, undef);
+is(pop // 7, 7, 'pop // ... works');
+is(pop() // 7, 0, 'pop() // ... works');
+is(pop @ARGV // 7, 3, 'pop @array // ... works');
+
+# Test that various syntaxes are allowed
+
+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/ );