Skip to content

Commit

Permalink
test that the switch and smartmatch features are independent
Browse files Browse the repository at this point in the history
  • Loading branch information
tonycoz committed Feb 12, 2025
1 parent ced3d68 commit 8ddae4b
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions t/lib/feature/smartmatch
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,54 @@ 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.

0 comments on commit 8ddae4b

Please sign in to comment.