Giter VIP home page Giter VIP logo

test-exception-lessclever's Introduction

NAME
    Test::Exception::LessClever - Test::Exception simplified

DESCRIPTION
    An alternative to Test::Exception that is much simpler. This alternative
    does not use fancy stack tricks to hide itself. The idea here is to keep
    it simple. This also solves the Test::Exception bug where some dies will
    be hidden when a DESTROY method calls eval. If a DESTROY method masks $@
    a warning will be generated as well.

WHY REWRITE TEST-EXCEPTION
    Here is an IRC log.

        <Exodist> wtf? Bizarre copy of HASH in sassign at /usr/lib64/perl5/5.10.1/Carp/Heavy.pm line 104
        <Exodist> hmm, it doesn't happen when I step through the debugger, that sure is helpful yessir
        <Exodist> hmm, throws_ok or dies_ok { stuff that croaks in a package used by the one being tested }, at least in this case causes that error. If I change it to eval {}; ok( $@ ); like( $@, qr// ); it works fine
        <Exodist> Ah-Ha,   earlier when I mentioned I stopped using throws_ok because of something I could not remember, this was it, I stumbled on it again!
        <confound> probably because throws_ok tries to do clever things to fiddle with the call stack to make it appear as though its guts are not being called
        <confound> less clever would be more useful

SYNOPSYS
    Pretty much a clone of Test::Exception Refer to those docs for more
    details.

        use Test::More;
        use Test::Exception;

        dies_ok { die( 'xxx' )} "Should die";
        lives_ok { 1 } "Should live";
        throws_ok { die( 'xxx' )} qr/xxx/, "Throws 'xxx'";
        lives_and { ok( 1, "We did not die" )} "Ooops we died";

        done_testing;

EXPORTABLE FUNCTIONS
    $status = live_or_die( sub { ... }, $name )
    ($status, $msg) = live_or_die( sub { ... }, $name )
        Check if the code lives or dies. In scalar context returns true or
        false. In array context returns the same true or false with the
        error message. If the return is true the error message will be
        something along the lines of 'did not die' but this may change in
        the future.

        Will generate a warning if the test dies, $@ is empty AND called in
        array context. This usually occurs when an objects DESTROY method
        calls eval and masks $@.

        *NOT EXPORTED BY DEFAULT*

    lives_ok( sub { ... }, $name )
        Test passes if the sub does not die, false if it does.

    dies_ok( sub { ... }, $name )
        Test passes if the sub dies, false if it does not.

    throws_ok( sub { ... }, qr/message/, $name )
        Check that the sub dies, and that it throws an error that matches
        the regex.

        Test fails is the sub does not die, or if the message does not match
        the regex.

    lives_and( sub {...}, $name )
        Fails with $name if the sub dies, otherwise is passive. This is
        useful for running a test that could die. If it dies there is a
        failure, fi ti lives it is responsible for itself.

SEE ALSO
    Test::Exception

AUTHORS
    Chad Granum [email protected]

COPYRIGHT
    Copyright (C) 2010 Chad Granum

    Test-Exception-LessClever is free software; Standard perl licence.

    Test-Exception-LessClever is distributed in the hope that it will be
    useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for
    more details.

test-exception-lessclever's People

Contributors

exodist avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.