File: load_module.t

package info (click to toggle)
libmoo-perl 2.005005-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 840 kB
  • sloc: perl: 2,506; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 614 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use strict;
use warnings;
use lib 't/lib';

use Test::More;

# this test is replicated to t/load_module_role_tiny.t for Role::Tiny

use Moo::_Utils qw(_load_module);
use InlineModule (
  'Foo::Bar' => q{
    package Foo::Bar;
    sub baz { 1 }
    1;
  },
  'BrokenModule' => q{
    package BrokenModule;
    use strict;
    sub guff { 1 }

    ;_;
  },
);

{ package Foo::Bar::Baz; sub quux { } }

_load_module("Foo::Bar");

ok(eval { Foo::Bar->baz }, 'Loaded module ok');

ok do { my $e; eval { _load_module("BrokenModule"); 1 } or $e = $@; $e },
  'broken module that installs subs gives error';

done_testing;