Help for this page

Select Code to Download


  1. or download this
    use strict;
    use warnings;
    
    ...
    } else {
        croak "Contract failed: ".$c->get_tap;
    };
    
  2. or download this
    sub refute {
        my ($condition, $message) = @_;
        ok (!$condition, $message)
            or diag $condition;
    };
    
  3. or download this
    package My::Check;
    use Exporter qw(import);
    
    ...
    }, args => 2, export => 1;
    
    1;
    
  4. or download this
    use Test::More tests => 1;
    use My::Check;
    
    my_check $foo, $bar, "foo is fine";
    
  5. or download this
    # inside a running application
    use Test::Contract;
    use My::Check(); # don't pollute global namespace
    ...
    if (!$c->get_passing) {
        # ouch, something went wrong with $foo and $bar
    };
    
  6. or download this
    use Test::More;
    use Test::Contract::Unit qw(contract_is);
    use My::Check;
    ...
    
    is_contract $c, "1100", "my_check works as expected";
    done_testing;