Michael G Schwern > Test-Simple-1.005000_005 > TB2::CanLoad

Download:
Test-Simple-1.005000_005.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 1.005000_005   Source   Latest Release: Test-Simple-1.005000_006

NAME ^

TB2::CanLoad - load modules without effecting global variables

SYNOPSIS ^

    package My::Thing;

    use TB2::Mouse;
    with "TB2::CanLoad";

    My::Thing->load("Some::Module");

DESCRIPTION ^

Test::Builder2 must be careful to leave the global state of the test alone. This especially includes things like $@ and $!. Unfortunately, a lot of things change them. require is one of them.

This module provides load as a safe replacement for require which does not affect global variables (except the obvious ones like %INC).

load

    $class->load($module);

This works like require to load a module, except it will not affect $! and $@ and not trip a $SIG{__DIE__} handler. Use it internally in your test module when you want to load a module.

It will die on failure if the $module fails to load in which case it will set $@. If you want to trap the failure, see TB2::CanTry.

SEE ALSO ^

TB2::CanTry

syntax highlighting: