This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Provide inclusive names allowlist and denylist
[perl5.git] / cpan / experimental / t / basic.t
CommitLineData
de84ff2b
RS
1#! perl
2
62805098
SH
3use strict;
4use warnings;
5
de84ff2b
RS
6use Test::More 0.89;
7
acd998d7
RS
8plan skip_all => 'This module is a no-op on perls earlier than 5.010' if "$]" < 5.010000;
9
de84ff2b
RS
10local $SIG{__WARN__} = sub { fail("Got unexpected warning"); diag($_[0]) };
11
12if ($] >= 5.010000) {
61030386
CBW
13 is (eval <<'END', 1, 'state compiles') or diag $@;
14 use experimental 'state';
15 state $foo = 1;
16 is($foo, 1, '$foo is 1');
17 1;
de84ff2b
RS
18END
19}
de84ff2b
RS
20
21if ($] >= 5.010001) {
acd998d7
RS
22 is (eval <<'END', 1, 'switch compiles') or diag $@;
23 use experimental 'switch';
24 sub bar { 1 };
25 given(1) {
26 when (\&bar) {
27 pass("bar matches 1");
f8c3bb9c 28 }
acd998d7 29 default {
14e4cec4
Z
30 fail("bar matches 1");
31 }
14e4cec4 32 }
acd998d7
RS
33 1;
34END
f8c3bb9c
CBW
35}
36
37if ($] >= 5.010001) {
de84ff2b
RS
38 is (eval <<'END', 1, 'smartmatch compiles') or diag $@;
39 use experimental 'smartmatch';
acd998d7
RS
40 sub baz { 1 };
41 is(1 ~~ \&baz, 1, "is 1");
f8c3bb9c 42 1;
de84ff2b
RS
43END
44}
45
46if ($] >= 5.018) {
47 is (eval <<'END', 1, 'lexical subs compiles') or diag $@;
48 use experimental 'lexical_subs';
49 my sub foo { 1 };
50 is(foo(), 1, "foo is 1");
51 1;
52END
53}
54
b4d728a5
SH
55if ($] >= 5.026000) {
56 is (eval <<'END', 1, 'declared refs compiles') or diag $@;
57 use experimental 'declared_refs';
58 my @b;
59 my \@a = \@b;
60 is(\@a, \@b, '@a and @b are the same after \@a=\@b');
61 1;
62END
63}
64elsif ($] >= 5.021005) {
e87ace2e 65 is (eval <<'END', 1, 'ref aliasing compiles') or diag $@;
baabe3fb 66 use experimental 'refaliasing';
62805098 67 my (@a, @b);
9c71c2c5
CBW
68 \@a = \@b;
69 is(\@a, \@b, '@a and @b are the same after \@a=\@b');
70 1;
71END
72}
73
de84ff2b
RS
74done_testing;
75