diff options
author | Zefram <zefram@fysh.org> | 2017-12-29 12:19:49 +0000 |
---|---|---|
committer | Zefram <zefram@fysh.org> | 2017-12-29 12:19:49 +0000 |
commit | 14e4cec412927f1f65c5d2b21526e01b33029447 (patch) | |
tree | f1b179e4f65675797f2a9b8cdc313731e0cca861 /cpan/experimental | |
parent | 569476d57eacdb842220890e4e01ad479ec3667e (diff) | |
download | perl-14e4cec412927f1f65c5d2b21526e01b33029447.tar.gz |
make experimental.pm test agnostic about switch
Anticipating imminent reversion of smartmatch behaviour, make
experimental.pm able to test against either version of the switch feature,
detecting empirically which version the running perl supports.
Diffstat (limited to 'cpan/experimental')
-rw-r--r-- | cpan/experimental/t/basic.t | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/cpan/experimental/t/basic.t b/cpan/experimental/t/basic.t index b54bd1199a..adfc566744 100644 --- a/cpan/experimental/t/basic.t +++ b/cpan/experimental/t/basic.t @@ -17,17 +17,38 @@ END } if ($] >= 5.010001) { - is (eval <<'END', 1, 'switch compiles') or diag $@; - use experimental 'switch'; - sub bar { 1 }; - given(1) { - whereso (\&bar) { - pass("bar matches 1"); + if (eval ' + no warnings "experimental"; + use feature "switch"; + if(0) { when(3) {} } + 1; + ') { + is (eval <<'END', 1, 'switch compiles') or diag $@; + use experimental 'switch'; + sub bar { 1 }; + given(1) { + when (\&bar) { + pass("bar matches 1"); + } + default { + fail("bar matches 1"); + } } - fail("bar matches 1"); - } - 1; + 1; END + } else { + is (eval <<'END', 1, 'switch compiles') or diag $@; + use experimental 'switch'; + sub bar { 1 }; + given(1) { + whereso (\&bar) { + pass("bar matches 1"); + } + fail("bar matches 1"); + } + 1; +END + } } if ($] >= 5.010001) { |