print "1..10\n";

print (( 1 + 1 =  = 2  ? "": "not "), "ok 1\n");
print (( 2 + 2 != 7  ? "": "not "), "ok 2\n");
if (foobar(  ) ) {
    print "ok 3\n";
} else {
    print "not ok 3\n";
}
...
---------------------------------
print "1..10\n";

my $i = 1;
print (( 1 + 1 =  = 2  ? "": "not "), "ok ", $i++, "\n");
print (( 2 + 2 != 7  ? "": "not "), "ok ", $i++, "\n");
...
---------------------------------
use Test::Simple tests => 3;

ok( 1 + 1 =  = 2 );
ok( 2 + 2 != 7, "Dwa plus dwa to nie siedem" );
ok( foobar(  ) );
---------------------------------
1..3
ok 1
ok 2 - Dwa plus dwa to nie siedem 
ok 3
---------------------------------
ok( 1 =  = 2, "Jeden rwna si dwa" );
---------------------------------
not ok 1 - Jeden rwna si dwa 
#     Failed test (simple.t at line 5)
---------------------------------
is( test_function(  ), 1234, "Spawdzanie, czy funkcja test_function zwrci 1234");
---------------------------------
isnt( MyClass->new(  ), undef, "nowa metoda powinna dziaa dobrze");
---------------------------------
like(time, qr/^\d+$/, "Czas powinien by dodatni liczb cakowit");
---------------------------------
cmp_ok(MyModule::foo(  ), ">", 12, "foo wiksze ni 12");
---------------------------------
not ok 1 - Sprawdzanie, czy funkcja test_function zwrci 1234
#     Failed test (more.t at line 5)
#          got: '4321'
#     expected: '1234'
not ok 2 - foo wiksze ni 12
#     Failed test (more.t at line 9)
#     '12'
#         >
#     '12'
---------------------------------
$got = pewna_funkcja(  ); # Powiedzmy, e zwrcia
                        # [ 1, { a => "foo", b => [ "bar" ] } ]

$expected =  [1, { a => "foo", b => "bar" }];

is_deeply($got, $expected);
---------------------------------
not ok 1
#     Failed test (t.pl at line 123)
#     Structures begin differing at:
#          $got->[1]{b} = 'ARRAY(0x6590)'
#     $expected->[1]{b} = 'bar'
# Looks like you failed 1 tests of 1.
---------------------------------
use Net::Config qw(%NetConfig);

my $may_make_connections = $NetConfig{test_hosts};
---------------------------------
SKIP: {
    skip "Nie ma poczenia sieciowego", 2 unless $may_make_connections;

    ok($client->connect("myhost.foonly.com"));

    is($client->request("2+2"),
       4,
       "Kalkulator foonly nie zgadza si, e 2+2 rwna si 4"
      );
}
---------------------------------
ok 1 # skip Nie ma poczenia sieciowego 
ok 2 # skip Nie ma poczenia sieciowego
---------------------------------
TODO: {
    local $TODO = "Brak funduszy";
    ok(eval { $man->put_on_mars });
    ok(eval { $man->colonize_planet });
}
---------------------------------
not ok 2 # TODO Brak funduszy 
#     Failed (TODO) test (t.pl at line 6)
not ok 3 # TODO Brak funduszy 
#     Failed (TODO) test (t.pl at line 7)
---------------------------------
t....ok
All tests successful.
Files=1, Tests=3,  0 wallclock secs ( 0.19 cusr +  0.01 csys =  0.20 CPU)
---------------------------------
ok(eq_set([myfunc(  )], [1..10]), "Mamy list liczb od 1 do 10");
---------------------------------
my $s = IO::Socket->new;
isa_ok($s, "IO::Socket");
---------------------------------
can_ok($s, "accept", "timeout", "connected",
           "close"); # Dziedziczone z IO::Handle
---------------------------------
1..25
ok 1 - Loaded module
ok 2 - Can create a new object
ok 3 -  ... of the correct class
...
---------------------------------
t/1...............ok
t/2...............ok
t/3...............FAILED tests 2, 5                                           
        Failed 2/6 tests, 66.67% okay

...
Failed Test Stat Wstat Total Fail  Failed  List of Failed
-------------------------------------------------------------------------------
t/3.t                      6    2  33.33%  2 5
Failed 1/20 test scripts, 95.00% okay. 2/349 subtests failed, 99.43% okay.
---------------------------------
ok
not ok 2
ok 3 - Waciwy porzdek tablicy
---------------------------------
OK
Testowanie, czy moemy ponownie zanalizowa kod XML... ok
4 not ok
---------------------------------
1..0
---------------------------------
use Test::Builder;
my $Test = Test::Builder->new;
---------------------------------
sub ok ($;$) {
    $Test->ok(@_);
}
---------------------------------
sub import {
    my $self = shift;
    if (@_) {
        my $package = caller;
        $Test->exported_to($package);
        $Test->plan(@_);
    };
    $self->export_to_level(1, $self, $_) foreach @EXPORT;
}
---------------------------------
use Test::Exception tests => 5;
---------------------------------
use Test::More tests => 5;
use Test::Exception;
---------------------------------
package Test::Fuzzy;

use Test::Builder;
use String::Approx qw( amatch );

use base qw( Exporter );
our @EXPORT = qw( is_fuzzy ); 

my $Test = Test::Builder->new;
---------------------------------
sub is_fuzzy ($$;$) {
    my ($got, $expected, $desc) = @_;
    my $result = amatch($expected, $got);
    $Test->ok($result, $desc);
}
---------------------------------
use Test::More tests => 2;
use Test::Fuzzy;

is_fuzzy('jeden', 'eden', "jeden przypomina eden");
is_fuzzy('niebieski', 'zielony', "niebieski przypomina zielony");
---------------------------------
ok 1 - jeden przypomina eden 
not ok 2 - niebieski przypomina zielony 
#     Failed test (fuzzy.t at line 7)
---------------------------------
use Test::Fuzzy;
use Test::Builder::Tester tests => 1;
---------------------------------
test_out("ok 1");
test_out("ok 2");
---------------------------------
is_fuzzy("psuje", "pasuje");
is_fuzzy("niedokladne",    "niedokadne");
---------------------------------
ok 1
ok 2
---------------------------------
test_test("Dwa trywialne testy wykonane z powodzeniem OK");
---------------------------------
ok 1 - Dwa trywialne testy wykonane z powodzeniem OK
---------------------------------
=head2 keywords

   my @keywords = keywords($text);

Oto przykad prostego algorytmu, ktry usuwa sowa stopujce z  
podsumowania tekstu, a nastpnie zlicza najbardziej istotne wedug 
niego sowa kluczowe. Procedura C<keywords> subroutine zwraca
list piciu sw kluczowych uporzdkowanych wedug ich wanoci. 

=begin testing

my @keywords = keywords(scalar `perldoc -t perlxs`); 
# prosty przykadowy dokument

is_deeply(\@keywords, [qw(perl xsub keyword code timep)], 
          "Prawidowe sowa kluczowe zwrcone przez perlxs");

=end testing

sub keywords {
    ...
---------------------------------
% pod2test lib/Keywords.pm t/Keywords-embedded.t
% make test
...
---------------------------------
package Person;
sub new {
    my $self = shift;
    my $name = shift;
    return undef unless $name;
    return bless { 
       name => $name
    }, $self;
}

sub name { 
    my $self = shift;
    $self->{name} = shift if @_;
    return $self->{name};
}
---------------------------------
package Person::Test;
use base 'Test::Class';

use Test::More tests => 1;
use Person;
---------------------------------
sub constructor :Test {
    my $self = shift;
    my $test_person = Person->new("Larry Wall");
    isa_ok($test_person, "Person");
}
---------------------------------
sub name :Test(2) { 
    my $self = shift;
    my $test_person = Person->new("Larry Wall");
    my $test_name = $test_person->name();
    is($test_name, "Larry Wall");

    my $test_name2 = $test_person->name("Llaw Yrral");
    is($test_name2, "Llaw Yrral");
}
---------------------------------
_ _PACKAGE_ _->runtests;
---------------------------------
  use Test::Class;
  my @classes;
  Test::Class->runtests(@classes);
  BEGIN {
    my @found = code_to_find_all_classes(  );
    foreach my $class (@found) {
      eval {require $class};
      push @classes, $class if $class->isa('Test::Class');
    }
  }
---------------------------------
sub setup_person :Test(setup) { 
    my $self = shift;
    $self->{person} = Person->new("Larry Wall");
}
---------------------------------
sub get_name :Test { 
    my $self = shift;
    is ($self->{person}->name, "Larry Wall");
}	

sub set_name :Test {
    my $self = shift;
    $self->{person}->name("Jon Orwant"); # Co za transformacja!
    is ($self->{person}->name, "Jon Orwant");

    $self->{person}->name("Larry Wall"); # Lepiej przywrci Larryego.
}
---------------------------------
sub setup_database :Test(startup) {
    my $self = shift;
    require DBI;
    $self->{dbh} = DBI->connect("dbi:mysql:dbname=test", $user, $pass);
    die "Nie mona poczy si z baz danych!" unless $self->{dbh};
}

sub destroy_database :Test(shutdown) { 
    my $self = shift;
    $self->{dbh}->disconnect;

}
---------------------------------
use Test::MockObject;

my $mock_ua = Test::MockObject->new(  );
---------------------------------
$mock_ua->mock('clone',  sub { return $mock_ua    });
---------------------------------
$mock_ua->set_always('_agent', 'libwww/perl-5.65');
---------------------------------
$mock_ua->fake_module("LWP::UserAgent");
---------------------------------
$mock_ua->fake_new("LWP::UserAgent");
---------------------------------
use Apache::FakeRequest;

my $r = Apache::FakeRequest->new(  );

myhandler($r);
---------------------------------
use Apache::FakeRequest;

my $r = Apache::FakeRequest->new(  );
*Apache::request = sub { $r };
*Apache::Request::new = sub { $r };

myhandler($r);
---------------------------------

