Sophie

Sophie

distrib > Mageia > 7 > x86_64 > by-pkgid > b3c3b84e9b6887230b8594f615a32472 > files > 4

perl-Test-Assert-0.0504-3.mga7.noarch.rpm

NAME
    Test::Assert - Assertion methods for those who like JUnit.

SYNOPSIS
      # Use as imported methods
      #
      package My::Test;

      use Test::Assert ':all';

      assert_true(1, "pass");
      assert_true(0, "fail");

      use Test::More;
      assert_test(sub { require_ok($module) });

      # Use for debugging purposes
      # Assertions are compiled only if Test::Assert was used
      # from the main package.
      #
      package My::Package;

      use Test::Assert ':assert';

      my $state = do_something();
      assert_true($state >= 1 && $state <=2) if ASSERT;
      if ($state == 1) {
          # 1st state
          do_foo();
      } elsif ($state == 2) {
          # 2nd and last state
          do_bar();
      }

      my $a = get_a();
      my $b = get_b();
      assert_num_not_equals(0, $b) if ASSERT;
      my $c = $a / $b;

      # Clean the namespace
      no Test::Assert;

      # From command line
      $ perl -MTest::Assert script.pl  # sets Test::Assert::ASSERT to 1

DESCRIPTION
    This class provides a set of assertion methods useful for writing tests.
    The API is based on JUnit4 and Test::Unit::Lite and the methods die on
    failure.

    These assertion methods might be not useful for common
    Test::Builder-based (Test::Simple, Test::More, etc.) test units.

    The assertion methods can be used in class which is derived from
    `Test::Assert' or used as standard Perl functions after importing them
    into user's namespace.

    `Test::Assert' can also wrap standard Test::Simple, Test::More or other
    Test::Builder-based tests.

    The assertions can be also used for run-time checking.

AUTHOR
    Piotr Roszatycki <dexter@cpan.org>

COPYRIGHT
    Copyright (C) 2008, 2009 by Piotr Roszatycki <dexter@cpan.org>.

    This program is free software; you can redistribute it and/or modify it
    under the same terms as Perl itself.

    See http://www.perl.com/perl/misc/Artistic.html