Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
37 lines (26 sloc) 943 Bytes
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
Something went wrong with that request. Please try again.