make experimental.pm test agnostic about switch
authorZefram <zefram@fysh.org>
Fri, 29 Dec 2017 12:19:49 +0000 (12:19 +0000)
committerZefram <zefram@fysh.org>
Fri, 29 Dec 2017 12:19:49 +0000 (12:19 +0000)
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.

cpan/experimental/t/basic.t
t/porting/customized.dat

index b54bd11..adfc566 100644 (file)
@@ -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) {
index 9d7b538..f4bf00b 100644 (file)
@@ -25,7 +25,7 @@ autodie cpan/autodie/lib/autodie/hints.pm e1998fec61fb4e82fe46585bd82c73200be6f2
 autodie cpan/autodie/t/exceptions.t ad315a208f875e06b0964012ce8d65daa438c036
 autodie cpan/autodie/t/lib/Hints_pod_examples.pm 6944c218e9754b3613c8d0c90a5ae8aceccb5c99
 autodie cpan/autodie/t/mkdir.t 9e70d2282a3cc7d76a78bf8144fccba20fb37dac
-experimental cpan/experimental/t/basic.t 779e0dd420779467b4080ba3d1c857f7d941be8d
+experimental cpan/experimental/t/basic.t a073ea03ccc98dec496569f3648ab01a5fe1c7a0
 perlfaq cpan/perlfaq/lib/perlfaq5.pod bcc1b6af3b6dff3973643acf8d5e741463374123
 perlfaq cpan/perlfaq/lib/perlfaq8.pod bffbc0c8fa828aead24e0891a5e789369a8e0743
 podlators pod/perlpodstyle.pod c6500c9950b46e8228d4adbc09a3ee2ef23de2d0