package UNIVERSAL::can; # Small performance hit and breaks otherwise working code. # http://rt.cpan.org/Ticket/Display.html?id=31709 use Config; my $max_int = 2 ** ( $Config{intsize} * 8 ); our $VERSION = $max_int; 1; #### use CPAN; { no warnings 'redefine'; sub CPAN::Module::inst_file { shift->_file_in_path(['deps_patched/lib']); } } CPAN::Shell->r; #### use Test::Most 'no_plan'; use Config use UNIVERSAL::can; use Sub::Information; # for inspect() cmp_ok $UNIVERSAL::can::VERSION, '==', ( 2 ** ($Config{intsize} * 8 ), 'We should be loading our local version of modules'; # XXX this looks rather obscure, but what's going on is that the original # &UNIVERSAL::can's package is UNIVERSAL, but if UNIVERSAL::can is really # loaded, then the package is reported as UNIVERSAL::can. is inspect(\&UNIVERSAL::can)->package, 'UNIVERSAL', '... and not be accidentally reloading'; # more tests require Exporter::NoWork; foreach ('import') { # force an alias to a read-only constant eval { Exporter::NoWork::import( __PACKAGE__, $_ ) }; ok my $error = $@, 'Trying to import an unexportable tag with Exporter::NoWork should fail' unlike $error, qr/Modification of a read-only value/, '... but not with a "modification of readonly value" error'; my $package = <<' END_PACKAGE'; package Foo; use Exporter::NoWork; no warnings 'redefine'; sub unusual_function_name { return 'here I am' } END_PACKAGE eval $package; eval $package; is +(scalar grep { /Exporter::NoWork/ } @Foo::ISA), 1, '... and multiple uses of Exporter::NoWork should only add to @ISA once' }