From: Vincent Pit Date: Sun, 3 Jan 2010 16:24:31 +0000 (+0100) Subject: Test monkeypatching X-Git-Tag: v0.02~13 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=d13eb03da10981aca9ff101bd8d95727c1de4b5e;p=perl%2Fmodules%2FSub-Op.git Test monkeypatching --- diff --git a/MANIFEST b/MANIFEST index 9df334e..e5142fd 100644 --- a/MANIFEST +++ b/MANIFEST @@ -12,6 +12,7 @@ samples/try.pl t/10-base.t t/11-existing.t t/20-deparse.t +t/21-monkeypatch.t t/91-pod.t t/92-pod-coverage.t t/95-portability-files.t diff --git a/t/21-monkeypatch.t b/t/21-monkeypatch.t new file mode 100644 index 0000000..faaf83a --- /dev/null +++ b/t/21-monkeypatch.t @@ -0,0 +1,45 @@ +#!perl + +use strict; +use warnings; + +use Test::More; + +BEGIN { + if (exists $INC{'B.pm'} or exists $INC{'B/Deparse.pm'}) { + plan skip_all => 'Test::More loaded B or B::Deparse for some reason'; + } else { + plan tests => 5; + } +} + +use Sub::Op; + +BEGIN { + is_deeply [ sort keys %B:: ], [ sort + qw/OP:: Deparse:: Hooks::/, + qw/OPf_STACKED/, + qw/svref_2object/, + ], 'No extra symbols in B::'; + is_deeply [ sort keys %B::Deparse:: ], [ sort + qw/null pp_entersub/ + ], 'No extra symbols in B::Deparse'; +} + +use B; + +BEGIN { + for my $meth (qw/first can/) { + ok do { no strict 'refs'; defined &{"B::OP::$meth"} }, + "B::OP::$meth is now defined"; + } +} + +use B::Deparse; + +BEGIN { + for my $meth (qw/pp_custom/) { + ok do { no strict 'refs'; defined &{"B::Deparse::$meth"} }, + "B::Deparse::$meth is now defined"; + } +}