]> git.vpit.fr Git - perl/modules/Sub-Op.git/blob - t/21-monkeypatch.t
Add preliminary support for hooking reference constructors
[perl/modules/Sub-Op.git] / t / 21-monkeypatch.t
1 #!perl
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7
8 BEGIN {
9  if (exists $INC{'B.pm'} or exists $INC{'B/Deparse.pm'}) {
10   plan skip_all => 'Test::More loaded B or B::Deparse for some reason';
11  } else {
12   plan tests => 5;
13  }
14 }
15
16 use Sub::Op;
17
18 sub stash_keys {
19  my ($pkg) = @_;
20
21  no strict 'refs';
22  keys %{"${pkg}::"};
23 }
24
25 BEGIN {
26  is_deeply [ sort +stash_keys 'B' ], [ sort
27   qw/OP:: Deparse:: Hooks::/,
28   qw/svref_2object/,
29  ], 'No extra symbols in B::';
30  is_deeply [ sort +stash_keys 'B::Deparse' ], [ ], 'No symbols in B::Deparse';
31 }
32
33 use B;
34
35 BEGIN {
36  for my $meth (qw/first can/) {
37   ok do { no strict 'refs'; defined &{"B::OP::$meth"} },
38                                       "B::OP::$meth is now defined";
39  }
40 }
41
42 use B::Deparse;
43
44 BEGIN {
45  for my $meth (qw/pp_custom/) {
46   ok do { no strict 'refs'; defined &{"B::Deparse::$meth"} },
47                                       "B::Deparse::$meth is now defined";
48  }
49 }