From: Nicholas Clark Date: Fri, 18 Sep 2009 13:00:23 +0000 (+0100) Subject: Avoid using lib.pm in miniperl's tests. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=dd90d555fd3323e29dc92c0ff0b2a6569cd2cc2e;p=p5sagit%2Fp5-mst-13.2.git Avoid using lib.pm in miniperl's tests. --- diff --git a/MANIFEST b/MANIFEST index 4350606..20bdcd0 100644 --- a/MANIFEST +++ b/MANIFEST @@ -4203,6 +4203,7 @@ t/lib/Sans_mypragma.pm Test module for t/lib/mypragma.t t/lib/strict/refs Tests of "use strict 'refs'" for strict.t t/lib/strict/subs Tests of "use strict 'subs'" for strict.t t/lib/strict/vars Tests of "use strict 'vars'" for strict.t +t/lib/test_use.pm A test pragma for t/comp/use.t t/lib/warnings/1global Tests of global warnings for warnings.t t/lib/warnings/2use Tests for "use warnings" for warnings.t t/lib/warnings/3both Tests for interaction of $^W and "use warnings" diff --git a/t/comp/use.t b/t/comp/use.t index 6afc1f0..56d2d81 100755 --- a/t/comp/use.t +++ b/t/comp/use.t @@ -2,7 +2,7 @@ BEGIN { chdir 't' if -d 't'; - @INC = '../lib'; + @INC = ('../lib', 'lib'); $INC{"feature.pm"} = 1; # so we don't attempt to load feature.pm } @@ -37,7 +37,7 @@ sub _ok { } else { print "not ok $test\n"; } - my @caller = caller(2); + my @caller = caller(1); print "# Failed test at $caller[1] line $caller[2]\n"; print "# Got '$got'\n"; if ($type eq 'is') { @@ -118,73 +118,73 @@ is ($@, ""); eval 'require 5.11.0; ${"foo"} = "bar";'; is ($@, ""); -{ use lib } # check that subparse saves pending tokens +{ use test_use } # check that subparse saves pending tokens -local $lib::VERSION = 1.0; +local $test_use::VERSION = 1.0; -eval "use lib 0.9"; +eval "use test_use 0.9"; is ($@, ''); -eval "use lib 1.0"; +eval "use test_use 1.0"; is ($@, ''); -eval "use lib 1.01"; +eval "use test_use 1.01"; isnt ($@, ''); -eval "use lib 0.9 qw(fred)"; +eval "use test_use 0.9 qw(fred)"; is ($@, ''); -is($INC[0], "fred"); +is("@test_use::got", "fred"); -eval "use lib 1.0 qw(joe)"; +eval "use test_use 1.0 qw(joe)"; is ($@, ''); -is($INC[0], "joe"); +is("@test_use::got", "joe"); -eval "use lib 1.01 qw(freda)"; +eval "use test_use 1.01 qw(freda)"; isnt($@, ''); -isnt($INC[0], "freda"); +is("@test_use::got", "joe"); { - local $lib::VERSION = 35.36; - eval "use lib v33.55"; + local $test_use::VERSION = 35.36; + eval "use test_use v33.55"; is ($@, ''); - eval "use lib v100.105"; - like ($@, qr/lib version v100.105.0 required--this is only version v35\.360\.0/); + eval "use test_use v100.105"; + like ($@, qr/test_use version v100.105.0 required--this is only version v35\.360\.0/); - eval "use lib 33.55"; + eval "use test_use 33.55"; is ($@, ''); - eval "use lib 100.105"; - like ($@, qr/lib version 100.105 required--this is only version 35.36/); + eval "use test_use 100.105"; + like ($@, qr/test_use version 100.105 required--this is only version 35.36/); - local $lib::VERSION = '35.36'; - eval "use lib v33.55"; + local $test_use::VERSION = '35.36'; + eval "use test_use v33.55"; like ($@, ''); - eval "use lib v100.105"; - like ($@, qr/lib version v100.105.0 required--this is only version v35\.360\.0/); + eval "use test_use v100.105"; + like ($@, qr/test_use version v100.105.0 required--this is only version v35\.360\.0/); - eval "use lib 33.55"; + eval "use test_use 33.55"; is ($@, ''); - eval "use lib 100.105"; - like ($@, qr/lib version 100.105 required--this is only version 35.36/); + eval "use test_use 100.105"; + like ($@, qr/test_use version 100.105 required--this is only version 35.36/); - local $lib::VERSION = v35.36; - eval "use lib v33.55"; + local $test_use::VERSION = v35.36; + eval "use test_use v33.55"; is ($@, ''); - eval "use lib v100.105"; - like ($@, qr/lib version v100.105.0 required--this is only version v35\.36\.0/); + eval "use test_use v100.105"; + like ($@, qr/test_use version v100.105.0 required--this is only version v35\.36\.0/); - eval "use lib 33.55"; + eval "use test_use 33.55"; is ($@, ''); - eval "use lib 100.105"; - like ($@, qr/lib version 100.105 required--this is only version v35.36/); + eval "use test_use 100.105"; + like ($@, qr/test_use version 100.105 required--this is only version v35.36/); } @@ -194,7 +194,7 @@ isnt($INC[0], "freda"); open F, ">xxx$$.pm" or die "Cannot open xxx$$.pm: $!\n"; print F "1;\n"; close F; - eval "use lib '.'; use xxx$$ 3;"; + eval "BEGIN {unshift \@INC, '.'}; use xxx$$ 3;"; like ($@, qr/^xxx$$ defines neither package nor VERSION--version check failed at/); unlink "xxx$$.pm"; } diff --git a/t/lib/test_use.pm b/t/lib/test_use.pm new file mode 100644 index 0000000..f1ed0b1 --- /dev/null +++ b/t/lib/test_use.pm @@ -0,0 +1,11 @@ +#!perl -w +# Don't use strict because this is for testing use + +package test_use; + +sub import { + shift; + @got = @_; +} + +1; diff --git a/t/re/pat.t b/t/re/pat.t index f84e07f..7b5bbb3 100644 --- a/t/re/pat.t +++ b/t/re/pat.t @@ -2877,7 +2877,9 @@ sub run_tests { { - use lib 'lib'; + BEGIN { + unshift @INC, 'lib'; + } use Cname; ok 'fooB' =~ /\N{foo}[\N{B}\N{b}]/, "Passthrough charname";