This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Move some tests from t/run/fresh_perl.t
[perl5.git] / t / comp / parser.t
CommitLineData
923be969
RGS
1#!./perl
2
3# Checks if the parser behaves correctly in edge cases
4# (including weird syntax errors)
5
6BEGIN {
7 chdir 't' if -d 't';
8 @INC = '../lib';
9}
10
f15b33d3
RGS
11require "./test.pl";
12plan( tests => 9 );
13
14eval '%@x=0;';
15like( $@, qr/^Can't modify hash dereference in repeat \(x\)/, '%@x=0' );
16
17# Bug 20010422.005
18eval q{{s//${}/; //}};
19like( $@, qr/syntax error/, 'syntax error, used to dump core' );
20
21# Bug 20010528.007
22eval q/"\x{"/;
23like( $@, qr/^Missing right brace on \\x/,
24 'syntax error in string, used to dump core' );
25
26eval "a.b.c.d.e.f;sub";
27like( $@, qr/^Illegal declaration of anonymous subroutine/,
28 'found by Markov chain stress testing' );
29
30# Bug 20010831.001
31eval '($a, b) = (1, 2);';
32like( $@, qr/^Can't modify constant item in list assignment/,
33 'bareword in list assignment' );
34
35eval 'tie FOO, "Foo";';
36like( $@, qr/^Can't modify constant item in tie /,
37 'tying a bareword causes a segfault in 5.6.1' );
38
39eval 'undef foo';
40like( $@, qr/^Can't modify constant item in undef operator /,
41 'undefing constant causes a segfault in 5.6.1 [ID 20010906.019]' );
42
43eval 'read($bla, FILE, 1);';
44like( $@, qr/^Can't modify constant item in read /,
45 'read($var, FILE, 1) segfaults on 5.6.1 [ID 20011025.054]' );
923be969
RGS
46
47# This used to dump core (bug #17920)
48eval q{ sub { sub { f1(f2();); my($a,$b,$c) } } };
f15b33d3 49like( $@, qr/error/, 'lexical block discarded by yacc' );