1#! perl 2 3use Test::More 0.89; 4 5local $SIG{__WARN__} = sub { fail("Got unexpected warning"); diag($_[0]) }; 6 7if ($] >= 5.010000) { 8 is (eval <<'END', 1, 'state compiles') or diag $@; 9 use experimental 'state'; 10 state $foo = 1; 11 is($foo, 1, '$foo is 1'); 12 1; 13END 14} 15else { 16 fail("No experimental features available on perl $]"); 17} 18 19if ($] >= 5.010001) { 20 is (eval <<'END', 1, 'switch compiles') or diag $@; 21 use experimental 'switch'; 22 sub bar { 1 }; 23 given(1) { 24 when (\&bar) { 25 pass("bar matches 1"); 26 } 27 default { 28 fail("bar matches 1"); 29 } 30 } 31 1; 32END 33} 34 35if ($] >= 5.010001) { 36 is (eval <<'END', 1, 'smartmatch compiles') or diag $@; 37 use experimental 'smartmatch'; 38 sub bar { 1 }; 39 is(1 ~~ \&bar, 1, "is 1"); 40 1; 41END 42} 43 44if ($] >= 5.018) { 45 is (eval <<'END', 1, 'lexical subs compiles') or diag $@; 46 use experimental 'lexical_subs'; 47 my sub foo { 1 }; 48 is(foo(), 1, "foo is 1"); 49 1; 50END 51} 52 53if ($] >= 5.021005) { 54 is (eval <<'END', 1, 'ref aliasing compiles') or diag $@; 55 use experimental 'refaliasing'; 56 \@a = \@b; 57 is(\@a, \@b, '@a and @b are the same after \@a=\@b'); 58 1; 59END 60} 61 62done_testing; 63 64