This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Disable lexical $_
[perl5.git] / cpan / experimental / t / basic.t
1 #! perl
2
3 use Test::More 0.89;
4
5 local $SIG{__WARN__} = sub { fail("Got unexpected warning"); diag($_[0]) };
6
7 if ($] >= 5.010000) {
8         if ($] < 5.023) {
9                 is (eval <<'END', 1, 'lexical topic compiles') or diag $@;
10                 use experimental 'lexical_topic';
11                 my $_ = 1;
12                 is($_, 1, '$_ is 1');
13                 1;
14 END
15         }
16 }
17 else {
18         fail("No experimental features available on perl $]");
19 }
20
21 if ($] >= 5.010001) {
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");
28                 }
29                 default {
30                         fail("bar matches 1");
31                 }
32         }
33         1;
34 END
35 }
36
37 if ($] >= 5.010001) {
38         is (eval <<'END', 1, 'smartmatch compiles') or diag $@;
39         use experimental 'smartmatch';
40         sub bar { 1 };
41         is(1 ~~ \&bar, 1, "is 1");
42         1;
43 END
44 }
45
46 if ($] >= 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;
52 END
53 }
54
55 if ($] >= 5.021005) {
56         is (eval <<'END', 1, 'ref aliasing compiles') or diag $@;
57         use experimental 'refaliasing';
58         \@a = \@b;
59         is(\@a, \@b, '@a and @b are the same after \@a=\@b');
60         1;
61 END
62 }
63
64 done_testing;
65