forked from Raku/roast
/
brainos.t
36 lines (26 loc) · 943 Bytes
/
brainos.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use v6;
use Test;
plan 9;
=begin pod
Perl 6 has an explicitly declared C<=~> which should die at compile time
and is intended to catch user "brainos"; it recommends C<~~> to the user
instead. Similar for C<!~>.
=end pod
#L<S03/Chaining binary precedence/"To catch">
my $str = 'foo';
try { EVAL '$str =~ m/bar/;' };
ok $! ~~ Exception, 'caught "=~" braino';
ok "$!" ~~ /'~~'/, 'error for "=~" usage mentions "~~"';
try { EVAL '$str !~ m/bar/;' };
ok $! ~~ Exception, 'caught "!~" braino';
ok "$!" ~~ /'!~~'/, 'error for "!~" usage mentions "!~~"';
# RT #76878
{
my $x = 2;
is EVAL('"$x =~ b"'), '2 =~ b', '=~ allowed in double quotes';
is EVAL('"$x !~ b"'), '2 !~ b', '!~ allowed in double quotes';
is EVAL('"$x << b"'), '2 << b', '<< allowed in double quotes';
is EVAL('"$x >> b"'), '2 >> b', '>> allowed in double quotes';
is EVAL('"$x . b"'), '2 . b', '. allowed in double quotes';
}
# vim: ft=perl6