1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
#!/usr/bin/perl
####################################################################
# Description of what this test does:
# Checks to see if _match does the right thing
####################################################################
use strict;
use warnings;
# useful diagnostic modules that's good to have loaded
use Data::Dumper;
use Devel::Peek;
# colourising the output if we want to
use Term::ANSIColor qw(:constants);
$Term::ANSIColor::AUTORESET = 1;
###################################
# user editable parts
use Test::Exception;
# start the tests
use Test::More tests => 8;
use Test::Log4perl;
ok(Test::Log4perl::_matches("foo", "foo"), "foo foo");
ok(!Test::Log4perl::_matches("foo", "bar"), "foo bar");
ok(Test::Log4perl::_matches("foo", qr/foo/), "foo qr/foo/");
ok(!Test::Log4perl::_matches("foo", qr/bar/), "foo qr/bar/");
dies_ok { Test::Log4perl::_matches("foo", {}) } "hash";
dies_ok { Test::Log4perl::_matches("foo", bless({}, "bar"))} "object";
package Wibble;
use overload '""' => "as_string", fallback => 1;
sub as_string { "foo" };
package main;
ok(Test::Log4perl::_matches("foo", bless({}, "Wibble")), "foo foo object");
ok(!Test::Log4perl::_matches("bar", bless({}, "Wibble")), "bar foo object ");
|