This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix several differences in the parsing of $.. and ${...}
[perl5.git] / t / uni / variables.t
CommitLineData
07f72646
BF
1#!./perl
2
3# Checks if the parser behaves correctly in edge case
4# (including weird syntax errors)
5
6BEGIN {
7 require './test.pl';
8}
9
10use 5.016;
11use utf8;
12use open qw( :utf8 :std );
13
14plan (tests => 5);
15
16# ${single:colon} should not be valid syntax
17{
18 no strict;
19
20 local $@;
21 eval "\${\x{30cd}single:\x{30cd}colon} = 1";
22 like($@,
23 qr/syntax error .* near "\x{30cd}single:/,
24 '${\x{30cd}single:\x{30cd}colon} should not be valid syntax'
25 );
26
27 local $@;
28 no utf8;
29 evalbytes '${single:colon} = 1';
30 like($@,
31 qr/syntax error .* near "single:/,
32 '...same with ${single:colon}'
33 );
34}
35
36# ${yadda'etc} and ${yadda::etc} should both work under strict
37{
38 local $@;
39 eval q<use strict; ${flark::fleem}>;
40 is($@, '', q<${package::var} works>);
41
42 local $@;
43 eval q<use strict; ${fleem'flark}>;
44 is($@, '', q<...as does ${package'var}>);
45}
46
47# The first character in ${...} should respect the rules
48TODO: {
49 local $::TODO = "Fixed by the next commit";
50 local $@;
51 use utf8;
52 eval '${☭asd} = 1';
53 like($@, qr/\QUnrecognized character/, q(the first character in ${...} isn't special))
54}