From: Vincent Pit Date: Wed, 14 Aug 2013 17:34:02 +0000 (-0300) Subject: Silence experimental warnings on perl 5.17.11+ for given/when in tests X-Git-Tag: rt88174^0 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=eefb9e3f4b67e0aa0e8c3e705d7f7010a49f0540;p=perl%2Fmodules%2FScope-Upper.git Silence experimental warnings on perl 5.17.11+ for given/when in tests Using if.pm would have been cleaner but it is core only on perl 5.6.2, and we still support 5.6.1. Moreover, trusting the toolchain on such old perls is not really an option. --- diff --git a/t/05-words.t b/t/05-words.t index 8a8a583..6971da6 100644 --- a/t/05-words.t +++ b/t/05-words.t @@ -210,6 +210,12 @@ SKIP: { if "$]" < 5.010; eval <<'TEST_GIVEN'; + BEGIN { + if ("$]" >= 5.017_011) { + require warnings; + warnings->unimport('experimental::smartmatch'); + } + } use feature 'switch'; my $desc = 'given'; my $base = HERE; @@ -224,6 +230,12 @@ TEST_GIVEN diag $@ if $@; eval <<'TEST_GIVEN_WHEN'; + BEGIN { + if ("$]" >= 5.017_011) { + require warnings; + warnings->unimport('experimental::smartmatch'); + } + } use feature 'switch'; my $desc = 'when in given'; my $base = HERE; @@ -241,6 +253,12 @@ TEST_GIVEN_WHEN diag $@ if $@; eval <<'TEST_GIVEN_DEFAULT'; + BEGIN { + if ("$]" >= 5.017_011) { + require warnings; + warnings->unimport('experimental::smartmatch'); + } + } use feature 'switch'; my $desc = 'default in given'; my $base = HERE; @@ -258,6 +276,12 @@ TEST_GIVEN_DEFAULT diag $@ if $@; eval <<'TEST_FOR_WHEN'; + BEGIN { + if ("$]" >= 5.017_011) { + require warnings; + warnings->unimport('experimental::smartmatch'); + } + } use feature 'switch'; my $desc = 'when in for'; my $base = HERE; diff --git a/t/13-reap-ctl.t b/t/13-reap-ctl.t index 6208642..e4e47b5 100644 --- a/t/13-reap-ctl.t +++ b/t/13-reap-ctl.t @@ -140,6 +140,12 @@ SKIP: skip 'Perl 5.10 required to test given/when' => 30 if "$]" < 5.010; eval <<' GIVEN_TEST_1'; + BEGIN { + if ("$]" >= 5.017_011) { + require warnings; + warnings->unimport('experimental::smartmatch'); + } + } use feature 'switch'; local $y; { @@ -161,6 +167,12 @@ SKIP: fail $@ if $@; eval <<' GIVEN_TEST_2'; + BEGIN { + if ("$]" >= 5.017_011) { + require warnings; + warnings->unimport('experimental::smartmatch'); + } + } use feature 'switch'; local $y; { @@ -184,6 +196,12 @@ SKIP: fail $@ if $@; eval <<' GIVEN_TEST_3'; + BEGIN { + if ("$]" >= 5.017_011) { + require warnings; + warnings->unimport('experimental::smartmatch'); + } + } use feature 'switch'; local $y; { @@ -205,6 +223,12 @@ SKIP: fail $@ if $@; eval <<' GIVEN_TEST_4'; + BEGIN { + if ("$]" >= 5.017_011) { + require warnings; + warnings->unimport('experimental::smartmatch'); + } + } use feature 'switch'; local $y; { @@ -228,6 +252,12 @@ SKIP: fail $@ if $@; eval <<' GIVEN_TEST_5'; + BEGIN { + if ("$]" >= 5.017_011) { + require warnings; + warnings->unimport('experimental::smartmatch'); + } + } use feature 'switch'; local $y; { diff --git a/t/23-localize-ctl.t b/t/23-localize-ctl.t index 5f4046e..b72be22 100644 --- a/t/23-localize-ctl.t +++ b/t/23-localize-ctl.t @@ -193,6 +193,12 @@ SKIP: skip 'Perl 5.10 required to test given/when' => 30 if "$]" < 5.010; eval <<' GIVEN_TEST_1'; + BEGIN { + if ("$]" >= 5.017_011) { + require warnings; + warnings->unimport('experimental::smartmatch'); + } + } use feature 'switch'; local $y; { @@ -214,6 +220,12 @@ SKIP: fail $@ if $@; eval <<' GIVEN_TEST_2'; + BEGIN { + if ("$]" >= 5.017_011) { + require warnings; + warnings->unimport('experimental::smartmatch'); + } + } use feature 'switch'; local $y; { @@ -237,6 +249,12 @@ SKIP: fail $@ if $@; eval <<' GIVEN_TEST_3'; + BEGIN { + if ("$]" >= 5.017_011) { + require warnings; + warnings->unimport('experimental::smartmatch'); + } + } use feature 'switch'; local $y; { @@ -258,6 +276,12 @@ SKIP: fail $@ if $@; eval <<' GIVEN_TEST_4'; + BEGIN { + if ("$]" >= 5.017_011) { + require warnings; + warnings->unimport('experimental::smartmatch'); + } + } use feature 'switch'; local $y; { @@ -281,6 +305,12 @@ SKIP: fail $@ if $@; eval <<' GIVEN_TEST_5'; + BEGIN { + if ("$]" >= 5.017_011) { + require warnings; + warnings->unimport('experimental::smartmatch'); + } + } use feature 'switch'; local $y; { diff --git a/t/55-yield-target.t b/t/55-yield-target.t index f927d20..ced05c8 100644 --- a/t/55-yield-target.t +++ b/t/55-yield-target.t @@ -83,6 +83,12 @@ SKIP: { if "$]" < 5.010; @res = eval <<'TESTCASE'; + BEGIN { + if ("$]" >= 5.017_011) { + require warnings; + warnings->unimport('experimental::smartmatch'); + } + } use feature 'switch'; (24, do { given (25) { @@ -98,6 +104,12 @@ TESTCASE # end of the enclosing given block. @res = (); eval <<'TESTCASE'; + BEGIN { + if ("$]" >= 5.017_011) { + require warnings; + warnings->unimport('experimental::smartmatch'); + } + } use feature 'switch'; @res = (28, do { given (29) { @@ -115,6 +127,12 @@ TESTCASE # But calling yield() in when() in for() sends us at the next iteration. @res = (); eval <<'TESTCASE'; + BEGIN { + if ("$]" >= 5.017_011) { + require warnings; + warnings->unimport('experimental::smartmatch'); + } + } use feature 'switch'; @res = (31, do { for (32, 33) { diff --git a/t/lib/Scope/Upper/TestGenerator.pm b/t/lib/Scope/Upper/TestGenerator.pm index c71b8f3..b4f6e1b 100644 --- a/t/lib/Scope/Upper/TestGenerator.pm +++ b/t/lib/Scope/Upper/TestGenerator.pm @@ -39,6 +39,11 @@ my %exports = ( ); sub import { + if ("$]" >= 5.017_011) { + require warnings; + warnings->unimport('experimental::smartmatch'); + } + if ("$]" >= 5.010_001) { require feature; feature->import('switch');