File: misc_errors.t

package info (click to toggle)
libsub-install-perl 0.924-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 132 kB
  • ctags: 12
  • sloc: perl: 149; makefile: 45
file content (23 lines) | stat: -rw-r--r-- 668 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
use Sub::Install qw(install_sub);
use Test::More 'no_plan';

use strict;
use warnings;

{ # you have to install /something/!
  eval { install_sub({ into => "Doesn't::Matter" }); };

  like($@, qr/code.+not optional/, "you must supply something to install");
}

{ # you can't just make names up and expect Sub::Install to know what you mean
  eval { install_sub({ code => 'none_such', into => 'Whatever' }); };

  like($@, qr/couldn't find subroutine/, "error on unfound sub name");
}

{ # can't install anonymous subs without a name
  eval { install_sub({ code => sub { return 1; } }); };

  like($@, qr/couldn't determine name/, "anon subs need names to install");
}