Add tests for the C<my $x if foo> deprecation, and change the
[p5sagit/p5-mst-13.2.git] / t / comp / parser.t
index 54ad351..e59fec6 100644 (file)
@@ -9,7 +9,7 @@ BEGIN {
 }
 
 require "./test.pl";
-plan( tests => 21 );
+plan( tests => 43 );
 
 eval '%@x=0;';
 like( $@, qr/^Can't modify hash dereference in repeat \(x\)/, '%@x=0' );
@@ -52,6 +52,9 @@ like( $@, qr/error/, 'lexical block discarded by yacc' );
 eval q{ "\c" };
 like( $@, qr/^Missing control char name in \\c/, q("\c" string) );
 
+eval q{ qq(foo$) };
+like( $@, qr/Final \$ should be \\\$ or \$name/, q($ at end of "" string) );
+
 # two tests for memory corruption problems in the said variables
 # (used to dump core or produce strange results)
 
@@ -89,6 +92,9 @@ ${a}{ ${a}[ @{b}{
 ${a}{
 }
 
+eval q{ sub a(;; &) { } a { } };
+is($@, '', "';&' sub prototype confuses the lexer");
+
 # Bug #21575
 # ensure that the second print statement works, by playing a bit
 # with the test output.
@@ -97,3 +103,47 @@ print "#";
 print(
 $data{foo});
 pass();
+
+# Bug #21875
+# { q.* => ... } should be interpreted as hash, not block
+
+foreach my $line (split /\n/, <<'EOF')
+1 { foo => 'bar' }
+1 { qoo => 'bar' }
+1 { q   => 'bar' }
+1 { qq  => 'bar' }
+0 { q,'bar', }
+0 { q=bar= }
+0 { qq=bar= }
+1 { q=bar= => 'bar' }
+EOF
+{
+    my ($expect, $eval) = split / /, $line, 2;
+    my $result = eval $eval;
+    ok($@ eq  '', "eval $eval");
+    is(ref $result, $expect ? 'HASH' : '', $eval);
+}
+
+# Bug #24212
+{
+    local $SIG{__WARN__} = sub { }; # silence mandatory warning
+    eval q{ my $x = -F 1; };
+    like( $@, qr/(?:syntax|parse) error .* near "F 1"/, "unknown filetest operators" );
+    is(
+        eval q{ sub F { 42 } -F 1 },
+       '-42',
+       '-F calls the F function'
+    );
+}
+
+# Bug #24762
+{
+    eval q{ *foo{CODE} ? 1 : 0 };
+    is( $@, '', "glob subscript in conditional" );
+}
+
+# Bug #25824
+{
+    eval q{ sub f { @a=@b=@c;  {use} } };
+    like( $@, qr/syntax error/, "use without body" );
+}