File: export.t

package info (click to toggle)
libsub-install-perl 0.924-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny, squeeze
  • size: 132 kB
  • ctags: 13
  • sloc: perl: 149; makefile: 43
file content (24 lines) | stat: -rw-r--r-- 487 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use Sub::Install;
use Test::More tests => 4;

use strict;
use warnings;

BEGIN { use_ok('Sub::Install'); }

package Bar;
{ no warnings 'once';
  *import = Sub::Install::exporter { exports => [ qw(foo) ] };
}
sub foo { return 10; }

package main;

eval { Bar->import('bar'); };
like($@, qr/'bar' is not exported/, "exception on bad import");

eval { foo(); };
like($@, qr/Undefined subroutine/, "foo isn't imported yet");

Bar->import(qw(foo));
is(foo(), 10, "foo imported from Bar OK");