Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

RFC: Test::Contract - extensible object-oriented runtime check series

by Dallaylaen (Chaplain)
on May 07, 2017 at 14:17 UTC ( [id://1189735]=perlmeditation: print w/replies, xml ) Need Help??

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;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://1189735]
Approved by haukex
Front-paged by haukex
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-23 06:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found