1use Sub::Install; 2use Test::More tests => 4; 3 4use strict; 5use warnings; 6 7BEGIN { use_ok('Sub::Install'); } 8 9package Bar; 10{ no warnings 'once'; 11 *import = Sub::Install::exporter { exports => [ qw(foo) ] }; 12} 13sub foo { return 10; } 14 15package main; 16 17eval { Bar->import('bar'); }; 18like($@, qr/'bar' is not exported/, "exception on bad import"); 19 20eval { foo(); }; 21like($@, qr/Undefined subroutine/, "foo isn't imported yet"); 22 23Bar->import(qw(foo)); 24is(foo(), 10, "foo imported from Bar OK"); 25