Skip to content

Commit 576c1f4

Browse files
tonycozap
authored andcommitted
test that the switch and smartmatch features are independent
1 parent 2dd81b7 commit 576c1f4

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

t/lib/feature/smartmatch

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,54 @@ use feature "smartmatch";
4343
my @x = qw(a b c);
4444
my $y = "b" ~~ @x;
4545
EXPECT
46+
########
47+
# NAME smartmatch and switch features independent
48+
no feature "switch";
49+
use feature "smartmatch";
50+
BEGIN {
51+
print STDERR "switch ",
52+
feature::feature_enabled("switch") ? "is" : "is not",
53+
" enabled\n";
54+
print STDERR "smartmatch ",
55+
feature::feature_enabled("smartmatch") ? "is" : "is not",
56+
" enabled\n";
57+
}
58+
my @x = qw(a b c);
59+
my $y = "b" ~~ @x;
60+
given ($y) {
61+
when (1) {
62+
print "fail!";
63+
}
64+
}
65+
EXPECT
66+
OPTION fatal
67+
switch is not enabled
68+
smartmatch is enabled
69+
syntax error at - line 13, near ") {"
70+
Execution of - aborted due to compilation errors.
71+
########
72+
# NAME smartmatch and switch features independent
73+
use feature "switch";
74+
no feature "smartmatch";
75+
BEGIN {
76+
print STDERR "switch ",
77+
feature::feature_enabled("switch") ? "is" : "is not",
78+
" enabled\n";
79+
print STDERR "smartmatch ",
80+
feature::feature_enabled("smartmatch") ? "is" : "is not",
81+
" enabled\n";
82+
}
83+
my $z;
84+
given ($z) {
85+
when (1) {
86+
print "fail!";
87+
}
88+
}
89+
my @x = qw(a b c);
90+
my $y = "b" ~~ @x;
91+
EXPECT
92+
OPTION fatal
93+
switch is enabled
94+
smartmatch is not enabled
95+
syntax error at - line 18, near ""b" ~"
96+
Execution of - aborted due to compilation errors.

0 commit comments

Comments
 (0)