diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-07-02 09:07:31 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-09-15 22:44:54 -0700 |
commit | 39075fb14ee634cbc405da5ce45b841c659549a6 (patch) | |
tree | 1dcaf99a12e67fde2e373bd4d29f3830f6c4e89b /t/cmd | |
parent | c07656ed340bbe7027cae47dc3a85a51910f9d07 (diff) | |
download | perl-39075fb14ee634cbc405da5ce45b841c659549a6.tar.gz |
Use test.pl in lexsub.t
I thought cmd/ couldn’t use test.pl, but was mistaken.
Diffstat (limited to 't/cmd')
-rw-r--r-- | t/cmd/lexsub.t | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/t/cmd/lexsub.t b/t/cmd/lexsub.t index 6dd5059c36..0b35964ebb 100644 --- a/t/cmd/lexsub.t +++ b/t/cmd/lexsub.t @@ -1,35 +1,34 @@ #!perl -print "1..14\n"; +BEGIN { + chdir 't'; + require './test.pl'; + *bar::is = *is; +} +plan 14; { our sub foo { 42 } - print "not " unless foo == 42; - print "ok 1 - calling our sub from same package\n"; - print "not " unless &foo == 42; - print "ok 2 - calling our sub from same package (amper)\n"; + is foo, 42, 'calling our sub from same package'; + is &foo, 42, 'calling our sub from same package (amper)'; package bar; sub bar::foo { 43 } - print "not " unless foo == 42; - print "ok 3 - calling our sub from another package # TODO\n"; - print "not " unless &foo == 42; - print "ok 4 - calling our sub from another package (amper)\n"; + { local $::TODO = ' '; + is foo, 42, 'calling our sub from another package'; + } + is &foo, 42, 'calling our sub from another package (amper)'; } package bar; -print "not " unless foo == 43; -print "ok 5 - our sub falling out of scope\n"; -print "not " unless &foo == 43; -print "ok 6 - our sub falling out of scope (called via amper)\n"; +is foo, 43, 'our sub falling out of scope'; +is &foo, 43, 'our sub falling out of scope (called via amper)'; package main; { sub bar::a { 43 } our sub a { if (shift) { package bar; - print "not " unless a == 43; - print "ok 7 - our sub invisible inside itself\n"; - print "not " unless &a == 43; - print "ok 8 - our sub invisible inside itself (called via amper)\n"; + is a, 43, 'our sub invisible inside itself'; + is &a, 43, 'our sub invisible inside itself (called via amper)'; } 42 } @@ -39,10 +38,10 @@ package main; our sub b { if (shift) { package bar; - print "not " unless b == 42; - print "ok 9 - our sub visible inside itself after decl # TODO\n"; - print "not " unless &b == 42; - print "ok 10 - our sub visible inside itself after decl (amper)\n"; + { local $::TODO = ' '; + is b, 42, 'our sub visible inside itself after decl'; + } + is &b, 42, 'our sub visible inside itself after decl (amper)'; } 42 } @@ -53,18 +52,18 @@ sub bar::c { 43 } { our sub c; package bar; - print "not " unless c == 42; - print "ok 11 - our sub foo; makes lex alias for existing sub # TODO\n"; - print "not " unless &c == 42; - print "ok 12 - our sub foo; makes lex alias for existing sub (amper)\n"; + { local $::TODO = ' '; + is c, 42, 'our sub foo; makes lex alias for existing sub'; + } + is &c, 42, 'our sub foo; makes lex alias for existing sub (amper)'; } { our sub d; sub d { 'd42' } sub bar::d { 'd43' } package bar; - print "not " unless d eq 'd42'; - print "ok 13 - our sub foo; applies to subsequent sub foo {} # TODO\n"; - print "not " unless &d eq 'd42'; - print "ok 14 - our sub foo; applies to subsequent sub foo {} (amper)\n"; + { local $::TODO = ' '; + is d, 'd42', 'our sub foo; applies to subsequent sub foo {}'; + } + is &d, 'd42', 'our sub foo; applies to subsequent sub foo {} (amper)'; } |