Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > 7f9c31c1973bf2fb93acaaddb09f4bcd > files > 29

perl-Test-Pretty-0.270.0-2.mga4.noarch.rpm

use strict;
use warnings;
use utf8;
use Test::More;

{
    package MessageFilter;
    sub new {
        my ($class, $word) = @_;
        bless \$word, $class;
    }
    sub detect {
        my ($self, $str) = @_;
        return index($str, $$self) >= 0;
    }
}

subtest 'MessageFilter' => sub {
    my $filter = MessageFilter->new('foo');

    subtest 'should detect message with NG word' => sub {
        ok($filter->detect('hello from foo'));
    };
    subtest 'should not detect message without NG word' => sub {
        ok(!$filter->detect('hello world!'));
    };
};

done_testing;