Commit | Line | Data |
---|---|---|
de84ff2b RS |
1 | #! perl |
2 | ||
62805098 SH |
3 | use strict; |
4 | use warnings; | |
5 | ||
de84ff2b RS |
6 | use Test::More 0.89; |
7 | ||
acd998d7 RS |
8 | plan skip_all => 'This module is a no-op on perls earlier than 5.010' if "$]" < 5.010000; |
9 | ||
de84ff2b RS |
10 | local $SIG{__WARN__} = sub { fail("Got unexpected warning"); diag($_[0]) }; |
11 | ||
12 | if ($] >= 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 |
18 | END |
19 | } | |
de84ff2b | 20 | |
1b8ae3c1 LT |
21 | use warnings (); |
22 | if ( $] >= 5.010001 | |
23 | && ( $] < 5.017011 || exists $warnings::Offsets{"experimental::smartmatch"} ) ) { | |
acd998d7 RS |
24 | is (eval <<'END', 1, 'switch compiles') or diag $@; |
25 | use experimental 'switch'; | |
26 | sub bar { 1 }; | |
27 | given(1) { | |
28 | when (\&bar) { | |
29 | pass("bar matches 1"); | |
f8c3bb9c | 30 | } |
acd998d7 | 31 | default { |
14e4cec4 Z |
32 | fail("bar matches 1"); |
33 | } | |
14e4cec4 | 34 | } |
acd998d7 RS |
35 | 1; |
36 | END | |
f8c3bb9c CBW |
37 | } |
38 | ||
1b8ae3c1 LT |
39 | if ( $] >= 5.010001 |
40 | && ( $] < 5.017011 || exists $warnings::Offsets{"experimental::smartmatch"} ) ) { | |
de84ff2b RS |
41 | is (eval <<'END', 1, 'smartmatch compiles') or diag $@; |
42 | use experimental 'smartmatch'; | |
acd998d7 RS |
43 | sub baz { 1 }; |
44 | is(1 ~~ \&baz, 1, "is 1"); | |
f8c3bb9c | 45 | 1; |
de84ff2b RS |
46 | END |
47 | } | |
48 | ||
49 | if ($] >= 5.018) { | |
50 | is (eval <<'END', 1, 'lexical subs compiles') or diag $@; | |
51 | use experimental 'lexical_subs'; | |
52 | my sub foo { 1 }; | |
53 | is(foo(), 1, "foo is 1"); | |
54 | 1; | |
55 | END | |
56 | } | |
57 | ||
b4d728a5 SH |
58 | if ($] >= 5.026000) { |
59 | is (eval <<'END', 1, 'declared refs compiles') or diag $@; | |
60 | use experimental 'declared_refs'; | |
61 | my @b; | |
62 | my \@a = \@b; | |
63 | is(\@a, \@b, '@a and @b are the same after \@a=\@b'); | |
64 | 1; | |
65 | END | |
66 | } | |
67 | elsif ($] >= 5.021005) { | |
e87ace2e | 68 | is (eval <<'END', 1, 'ref aliasing compiles') or diag $@; |
baabe3fb | 69 | use experimental 'refaliasing'; |
62805098 | 70 | my (@a, @b); |
9c71c2c5 CBW |
71 | \@a = \@b; |
72 | is(\@a, \@b, '@a and @b are the same after \@a=\@b'); | |
73 | 1; | |
74 | END | |
75 | } | |
76 | ||
de84ff2b RS |
77 | done_testing; |
78 |