diff options
author | Nicolas R <atoomic@cpan.org> | 2016-08-18 11:14:51 +1000 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2016-08-18 11:14:57 +1000 |
commit | 624c42e21a507311daed2012be92ca7adec9b65f (patch) | |
tree | 16f913214f5c84b2c73ab909d7275ed9088fde6e /t/mro | |
parent | fb9b5c74fb7605d3882509c33d3d353e88a7c253 (diff) | |
download | perl-624c42e21a507311daed2012be92ca7adec9b65f.tar.gz |
Use set_up_inc for several unit tests
Use set_up_inc when require.pl is loaded
move plan outside of BEGIN block
when no tests are run at BEGIN time.
Using set_up_inc allow to run these tests under minitest
but also compile them using B::C.
This also has the advantage to use a single
control point for @INC setup.
Note: some tests cannot use 'require test.pl',
unshfit is then used for them.
Diffstat (limited to 't/mro')
-rw-r--r-- | t/mro/basic.t | 2 | ||||
-rw-r--r-- | t/mro/inconsistent_c3.t | 5 | ||||
-rw-r--r-- | t/mro/inconsistent_c3_utf8.t | 5 | ||||
-rw-r--r-- | t/mro/isa_aliases.t | 6 | ||||
-rw-r--r-- | t/mro/isa_aliases_utf8.t | 6 | ||||
-rw-r--r-- | t/mro/isa_c3.t | 2 | ||||
-rw-r--r-- | t/mro/isa_c3_utf8.t | 2 | ||||
-rw-r--r-- | t/mro/isa_dfs.t | 2 | ||||
-rw-r--r-- | t/mro/isa_dfs_utf8.t | 2 | ||||
-rw-r--r-- | t/mro/isarev.t | 2 | ||||
-rw-r--r-- | t/mro/isarev_utf8.t | 2 | ||||
-rw-r--r-- | t/mro/method_caching.t | 2 | ||||
-rw-r--r-- | t/mro/method_caching_utf8.t | 5 | ||||
-rw-r--r-- | t/mro/next_edgecases.t | 4 | ||||
-rw-r--r-- | t/mro/next_edgecases_utf8.t | 8 | ||||
-rw-r--r-- | t/mro/overload_c3.t | 5 | ||||
-rw-r--r-- | t/mro/overload_c3_utf8.t | 5 | ||||
-rw-r--r-- | t/mro/overload_dfs.t | 5 | ||||
-rw-r--r-- | t/mro/package_aliases.t | 2 | ||||
-rw-r--r-- | t/mro/package_aliases_utf8.t | 2 | ||||
-rw-r--r-- | t/mro/recursion_c3.t | 5 | ||||
-rw-r--r-- | t/mro/recursion_c3_utf8.t | 5 | ||||
-rw-r--r-- | t/mro/recursion_dfs.t | 9 | ||||
-rw-r--r-- | t/mro/recursion_dfs_utf8.t | 5 |
24 files changed, 55 insertions, 43 deletions
diff --git a/t/mro/basic.t b/t/mro/basic.t index 8d54dc3f52..994831f134 100644 --- a/t/mro/basic.t +++ b/t/mro/basic.t @@ -2,8 +2,8 @@ BEGIN { chdir 't' if -d 't'; - @INC = '../lib'; require q(./test.pl); + set_up_inc('../lib'); } use strict; diff --git a/t/mro/inconsistent_c3.t b/t/mro/inconsistent_c3.t index b0052261dd..7bb53b1f71 100644 --- a/t/mro/inconsistent_c3.t +++ b/t/mro/inconsistent_c3.t @@ -3,14 +3,15 @@ BEGIN { unless (-d 'blib') { chdir 't' if -d 't'; - @INC = '../lib'; } + require q(./test.pl); + set_up_inc('../lib'); } use strict; use warnings; -require q(./test.pl); plan(tests => 1); +plan(tests => 1); require mro; diff --git a/t/mro/inconsistent_c3_utf8.t b/t/mro/inconsistent_c3_utf8.t index b7baa3ec5d..4d2b5be47e 100644 --- a/t/mro/inconsistent_c3_utf8.t +++ b/t/mro/inconsistent_c3_utf8.t @@ -3,8 +3,9 @@ BEGIN { unless (-d 'blib') { chdir 't' if -d 't'; - @INC = '../lib'; } + require q(./test.pl); + set_up_inc('../lib'); } use strict; @@ -13,7 +14,7 @@ use warnings; use utf8; use open qw( :utf8 :std ); -require q(./test.pl); plan(tests => 1); +plan(tests => 1); require mro; diff --git a/t/mro/isa_aliases.t b/t/mro/isa_aliases.t index 6ce81d137e..eb2aeeafd0 100644 --- a/t/mro/isa_aliases.t +++ b/t/mro/isa_aliases.t @@ -1,6 +1,10 @@ #!./perl -BEGIN { chdir 't' if -d 't'; @INC = '../lib'; require './test.pl' } +BEGIN { + chdir 't' if -d 't'; + require './test.pl'; + set_up_inc('../lib'); +} plan 13; diff --git a/t/mro/isa_aliases_utf8.t b/t/mro/isa_aliases_utf8.t index 721a4918dd..fa972e4c55 100644 --- a/t/mro/isa_aliases_utf8.t +++ b/t/mro/isa_aliases_utf8.t @@ -1,6 +1,10 @@ #!./perl -BEGIN { chdir 't' if -d 't'; @INC = '../lib'; require './test.pl' } +BEGIN { + chdir 't' if -d 't'; + require './test.pl'; + set_up_inc('../lib'); +} use utf8; use open qw( :utf8 :std ); diff --git a/t/mro/isa_c3.t b/t/mro/isa_c3.t index 20ae5f09b4..ecec0a5938 100644 --- a/t/mro/isa_c3.t +++ b/t/mro/isa_c3.t @@ -2,8 +2,8 @@ BEGIN { chdir 't' if -d 't'; - @INC = '../lib'; require "./test.pl"; + set_up_inc('../lib'); } use strict; diff --git a/t/mro/isa_c3_utf8.t b/t/mro/isa_c3_utf8.t index 3e2e7a999c..431e739567 100644 --- a/t/mro/isa_c3_utf8.t +++ b/t/mro/isa_c3_utf8.t @@ -2,8 +2,8 @@ BEGIN { chdir 't' if -d 't'; - @INC = '../lib'; require "./test.pl"; + set_up_inc('../lib'); } use strict; diff --git a/t/mro/isa_dfs.t b/t/mro/isa_dfs.t index 77c122ea74..e32ed756fb 100644 --- a/t/mro/isa_dfs.t +++ b/t/mro/isa_dfs.t @@ -2,8 +2,8 @@ BEGIN { chdir 't' if -d 't'; - @INC = '../lib'; require "./test.pl"; + set_up_inc('../lib'); } use strict; diff --git a/t/mro/isa_dfs_utf8.t b/t/mro/isa_dfs_utf8.t index 1c95eaa58e..6fa0b59ece 100644 --- a/t/mro/isa_dfs_utf8.t +++ b/t/mro/isa_dfs_utf8.t @@ -2,8 +2,8 @@ BEGIN { chdir 't' if -d 't'; - @INC = '../lib'; require "./test.pl"; + set_up_inc('../lib'); } use strict; diff --git a/t/mro/isarev.t b/t/mro/isarev.t index 892b40c798..bc35dd28bd 100644 --- a/t/mro/isarev.t +++ b/t/mro/isarev.t @@ -3,9 +3,9 @@ BEGIN { unless (-d 'blib') { chdir 't' if -d 't'; - @INC = '../lib'; } require q(./test.pl); + set_up_inc('../lib') unless -d 'blib'; } use strict; diff --git a/t/mro/isarev_utf8.t b/t/mro/isarev_utf8.t index dff3058ee6..61f7cf37cb 100644 --- a/t/mro/isarev_utf8.t +++ b/t/mro/isarev_utf8.t @@ -3,9 +3,9 @@ BEGIN { unless (-d 'blib') { chdir 't' if -d 't'; - @INC = '../lib'; } require q(./test.pl); + set_up_inc('../lib'); } use strict; diff --git a/t/mro/method_caching.t b/t/mro/method_caching.t index ab312a86bb..a6b2906802 100644 --- a/t/mro/method_caching.t +++ b/t/mro/method_caching.t @@ -3,9 +3,9 @@ BEGIN { unless (-d 'blib') { chdir 't' if -d 't'; - @INC = '../lib'; } require './test.pl'; + set_up_inc('../lib'); } use strict; diff --git a/t/mro/method_caching_utf8.t b/t/mro/method_caching_utf8.t index ee31869dd3..31187cabe1 100644 --- a/t/mro/method_caching_utf8.t +++ b/t/mro/method_caching_utf8.t @@ -3,8 +3,9 @@ BEGIN { unless (-d 'blib') { chdir 't' if -d 't'; - @INC = '../lib'; } + require './test.pl'; + set_up_inc('../lib'); } use utf8; @@ -14,8 +15,6 @@ use warnings; no warnings 'redefine'; # we do a lot of this no warnings 'prototype'; # we do a lot of this -require './test.pl'; - { package MC텟ᵀ::Bࡎᶓ; sub ᕘ { return $_[1]+1 }; diff --git a/t/mro/next_edgecases.t b/t/mro/next_edgecases.t index ccae4ef504..31a33552f3 100644 --- a/t/mro/next_edgecases.t +++ b/t/mro/next_edgecases.t @@ -3,7 +3,9 @@ use strict; use warnings; -BEGIN { chdir 't' if -d 't'; require q(./test.pl); @INC = qw "../lib lib" } +BEGIN { chdir 't' if -d 't'; require q(./test.pl); +set_up_inc('../lib', 'lib'); +} plan(tests => 12); diff --git a/t/mro/next_edgecases_utf8.t b/t/mro/next_edgecases_utf8.t index 3546a70b7b..8be8d66fea 100644 --- a/t/mro/next_edgecases_utf8.t +++ b/t/mro/next_edgecases_utf8.t @@ -3,7 +3,11 @@ use strict; use warnings; -BEGIN { chdir 't' if -d 't'; require q(./test.pl); @INC = qw "../lib lib" } +BEGIN { + chdir 't' if -d 't'; + require q(./test.pl); + set_up_inc('../lib', 'lib'); +} use utf8; use open qw( :utf8 :std ); @@ -47,7 +51,7 @@ plan(tests => 12); SKIP: { eval 'use Sub::Name'; skip("Sub::Name is required for this test", 3) if $@; - + my $m = sub { (shift)->next::method() }; Sub::Name::subname('Baɾ::ƚ', $m); { diff --git a/t/mro/overload_c3.t b/t/mro/overload_c3.t index db2b1ec660..0ba1509502 100644 --- a/t/mro/overload_c3.t +++ b/t/mro/overload_c3.t @@ -5,11 +5,12 @@ use warnings; BEGIN { unless (-d 'blib') { chdir 't' if -d 't'; - @INC = '../lib'; } + require q(./test.pl); + set_up_inc('../lib'); } -require q(./test.pl); plan(tests => 7); +plan(tests => 7); { package BaseTest; diff --git a/t/mro/overload_c3_utf8.t b/t/mro/overload_c3_utf8.t index bcb9f70c77..3981cbe42c 100644 --- a/t/mro/overload_c3_utf8.t +++ b/t/mro/overload_c3_utf8.t @@ -5,14 +5,15 @@ use warnings; BEGIN { unless (-d 'blib') { chdir 't' if -d 't'; - @INC = '../lib'; } + require q(./test.pl); + set_up_inc('../lib'); } use utf8; use open qw( :utf8 :std ); -require q(./test.pl); plan(tests => 7); +plan(tests => 7); { package 밧e텟ʇ; diff --git a/t/mro/overload_dfs.t b/t/mro/overload_dfs.t index 5943c855db..00d2753939 100644 --- a/t/mro/overload_dfs.t +++ b/t/mro/overload_dfs.t @@ -5,11 +5,12 @@ use warnings; BEGIN { unless (-d 'blib') { chdir 't' if -d 't'; - @INC = '../lib'; } + require q(./test.pl); + set_up_inc('../lib'); } -require q(./test.pl); plan(tests => 7); +plan(tests => 7); { package BaseTest; diff --git a/t/mro/package_aliases.t b/t/mro/package_aliases.t index 6998a89296..dd811a62f8 100644 --- a/t/mro/package_aliases.t +++ b/t/mro/package_aliases.t @@ -3,9 +3,9 @@ BEGIN { unless (-d 'blib') { chdir 't' if -d 't'; - @INC = '../lib'; } require q(./test.pl); + set_up_inc('../lib'); } use strict; diff --git a/t/mro/package_aliases_utf8.t b/t/mro/package_aliases_utf8.t index 09db6b7c19..0fc762d2d5 100644 --- a/t/mro/package_aliases_utf8.t +++ b/t/mro/package_aliases_utf8.t @@ -4,9 +4,9 @@ BEGIN { $ENV{PERL_UNICODE} = 0; unless (-d 'blib') { chdir 't' if -d 't'; - @INC = '../lib'; } require q(./test.pl); + set_up_inc('../lib'); } use strict; diff --git a/t/mro/recursion_c3.t b/t/mro/recursion_c3.t index 6ebd7fb2a1..d5bcbaf41a 100644 --- a/t/mro/recursion_c3.t +++ b/t/mro/recursion_c3.t @@ -1,14 +1,13 @@ #!./perl BEGIN { + require './test.pl'; unless (-d 'blib') { chdir 't' if -d 't'; - @INC = '../lib'; } + set_up_inc('../lib'); } -require './test.pl'; - use strict; use warnings; diff --git a/t/mro/recursion_c3_utf8.t b/t/mro/recursion_c3_utf8.t index 3abc136f72..bac3a59cac 100644 --- a/t/mro/recursion_c3_utf8.t +++ b/t/mro/recursion_c3_utf8.t @@ -5,14 +5,13 @@ use warnings; BEGIN { unless (-d 'blib') { chdir 't' if -d 't'; - @INC = '../lib'; } + require './test.pl'; + set_up_inc('../lib'); } use utf8; use open qw( :utf8 :std ); -require './test.pl'; - plan(skip_all => "Your system has no SIGALRM") if !exists $SIG{ALRM}; plan(tests => 8); diff --git a/t/mro/recursion_dfs.t b/t/mro/recursion_dfs.t index 00efe6d734..88c4ece76e 100644 --- a/t/mro/recursion_dfs.t +++ b/t/mro/recursion_dfs.t @@ -1,17 +1,14 @@ #!./perl BEGIN { - unless (-d 'blib') { - chdir 't' if -d 't'; - @INC = '../lib'; - } + chdir 't' if -d 't'; + require './test.pl'; + set_up_inc('../lib'); } use strict; use warnings; -require './test.pl'; - plan(skip_all => "Your system has no SIGALRM") if !exists $SIG{ALRM}; plan(tests => 8); diff --git a/t/mro/recursion_dfs_utf8.t b/t/mro/recursion_dfs_utf8.t index 6b428e1de3..4ad427e64f 100644 --- a/t/mro/recursion_dfs_utf8.t +++ b/t/mro/recursion_dfs_utf8.t @@ -5,14 +5,13 @@ use warnings; BEGIN { unless (-d 'blib') { chdir 't' if -d 't'; - @INC = '../lib'; } + require './test.pl'; + set_up_inc('../lib'); } use utf8; use open qw( :utf8 :std ); -require './test.pl'; - plan(skip_all => "Your system has no SIGALRM") if !exists $SIG{ALRM}; plan(tests => 8); |