Test no feature smartmatch
__END__
# NAME default
my @x = qw(a b c);
my $y = "b" ~~ @x;
EXPECT
########
# NAME explicit disable
no feature "smartmatch";
my @x = qw(a b c);
my $y = "b" ~~ @x;
EXPECT
OPTION fatal
syntax error at - line 3, near ""b" ~"
Execution of - aborted due to compilation errors.
########
# NAME explicit enable
use feature "smartmatch";
my @x = qw(a b c);
my $y = "b" ~~ @x;
EXPECT
########
# NAME explicit disable then enable
no feature "smartmatch";
use feature "smartmatch";
my @x = qw(a b c);
my $y = "b" ~~ @x;
EXPECT
########
# NAME implicit disable
use v5.41;
my @x = qw(a b c);
my $y = "b" ~~ @x;
EXPECT
OPTION fatal
syntax error at - line 3, near ""b" ~"
Execution of - aborted due to compilation errors.
########
# NAME implicit disable then enable
use v5.41;
use feature "smartmatch";
my @x = qw(a b c);
my $y = "b" ~~ @x;
EXPECT
########
# NAME smartmatch and switch features independent
no feature "switch";
use feature "smartmatch";
BEGIN {
print STDERR "switch ",
feature::feature_enabled("switch") ? "is" : "is not",
" enabled\n";
print STDERR "smartmatch ",
feature::feature_enabled("smartmatch") ? "is" : "is not",
" enabled\n";
}
my @x = qw(a b c);
my $y = "b" ~~ @x;
given ($y) {
when (1) {
print "fail!";
}
}
EXPECT
OPTION fatal
switch is not enabled
smartmatch is enabled
syntax error at - line 13, near ") {"
Execution of - aborted due to compilation errors.
########
# NAME smartmatch and switch features independent
use feature "switch";
no feature "smartmatch";
BEGIN {
print STDERR "switch ",
feature::feature_enabled("switch") ? "is" : "is not",
" enabled\n";
print STDERR "smartmatch ",
feature::feature_enabled("smartmatch") ? "is" : "is not",
" enabled\n";
}
my $z;
given ($z) {
when (1) {
print "fail!";
}
}
my @x = qw(a b c);
my $y = "b" ~~ @x;
EXPECT
OPTION fatal
switch is enabled
smartmatch is not enabled
syntax error at - line 18, near ""b" ~"
Execution of - aborted due to compilation errors.