3 # Checks if the parser behaves correctly in edge cases
4 # (including weird syntax errors)
15 like( $@, qr/^Can't modify hash dereference in repeat \(x\)/, '%@x=0' );
18 eval q{{s//${}/; //}};
19 like( $@, qr/syntax error/, 'syntax error, used to dump core' );
23 like( $@, qr/^Missing right brace on \\x/,
24 'syntax error in string, used to dump core' );
26 eval "a.b.c.d.e.f;sub";
27 like( $@, qr/^Illegal declaration of anonymous subroutine/,
28 'found by Markov chain stress testing' );
31 eval '($a, b) = (1, 2);';
32 like( $@, qr/^Can't modify constant item in list assignment/,
33 'bareword in list assignment' );
35 eval 'tie FOO, "Foo";';
36 like( $@, qr/^Can't modify constant item in tie /,
37 'tying a bareword causes a segfault in 5.6.1' );
40 like( $@, qr/^Can't modify constant item in undef operator /,
41 'undefing constant causes a segfault in 5.6.1 [ID 20010906.019]' );
43 eval 'read($bla, FILE, 1);';
44 like( $@, qr/^Can't modify constant item in read /,
45 'read($var, FILE, 1) segfaults on 5.6.1 [ID 20011025.054]' );
47 # This used to dump core (bug #17920)
48 eval q{ sub { sub { f1(f2();); my($a,$b,$c) } } };
49 like( $@, qr/error/, 'lexical block discarded by yacc' );
51 # bug #18573, used to corrupt memory
53 like( $@, qr/^Missing control char name in \\c/, q("\c" string) );
56 like( $@, qr/Final \$ should be \\\$ or \$name/, q($ at end of "" string) );
58 # two tests for memory corruption problems in the said variables
59 # (used to dump core or produce strange results)
61 is( "\Q\Q\Q\Q\Q\Q\Q\Q\Q\Q\Q\Q\Qa", "a", "PL_lex_casestack" );
64 {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
65 {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
66 {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
67 }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
68 }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
69 }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
71 is( $@, '', 'PL_lex_brackstack' );
74 # tests for bug #20716
78 is("${a}{", "A{", "interpolation, qq//");
79 is("${a}[", "A[", "interpolation, qq//");
81 is("@{b}{", "B{", "interpolation, qq//");
82 is(qr/${a}{/, '(?-xism:A{)', "interpolation, qr//");
85 is($&, 'A{', "interpolation, m//");
87 is($c, 'foo', "interpolation, s/...//");
89 is($c, 'A{', "interpolation, s//.../");
90 is(<<"${a}{", "A{ A[ B{\n", "interpolation, here doc");
95 eval q{ sub a(;; &) { } a { } };
96 is($@, '', "';&' sub prototype confuses the lexer");
99 # ensure that the second print statement works, by playing a bit
100 # with the test output.
101 my %data = ( foo => "\n" );
108 # { q.* => ... } should be interpreted as hash, not block
110 foreach my $line (split /\n/, <<'EOF')
118 1 { q=bar= => 'bar' }
121 my ($expect, $eval) = split / /, $line, 2;
122 my $result = eval $eval;
123 ok($@ eq '', "eval $eval");
124 is(ref $result, $expect ? 'HASH' : '', $eval);
129 local $SIG{__WARN__} = sub { }; # silence mandatory warning
130 eval q{ my $x = -F 1; };
131 like( $@, qr/syntax error .* near "F 1"/, "unknown filetest operators" );
133 eval q{ sub F { 42 } -F 1 },
135 '-F calls the F function'