Subject: | unlike does not work with multi-line output, prototype is missing in More.pm |
Module : Test-More-0.46 (I think that the problem still exists in Test-More-0.47)
Perl version : This is perl, version 5.005_03 built for sun4-solaris
OS : SunOS 5.7 Generic_106541-25 sun4u sparc SUNW,UltraSPARC-IIi-cEngine
Test-script :
#!/usr/local/bin/perl -w
use Test::More;
use strict;
use Test::More tests => 4;
like (qx/echo "this is a dog"/, "/dog/", "Output is like 'dog'");
unlike (qx/echo "this ia a dog"/, "/cat/", "Output is unlike 'cat'");
like (qx/echo "this is \na dog"/, "/dog/", "Multi-line output is like 'dog'");
unlike (qx/echo "this is \na dog"/, "/cat/", "Multi-line output is unlike 'cat'");
Output :
1..4
ok 1 - Output is like 'dog'
ok 2 - Output is unlike 'cat'
ok 3 - Multi-line output is like 'dog'
not ok 4 - /cat/
# Failed test (kris.pl at line 12)
# 'a dog
# ' doesn't look much like a regex to me.
# Looks like you failed 1 tests of 4.
Problem : unlike has no Prototype ($$;$)
Test/More .pm (line 372)
sub like ($$;$) {
$Test->like(@_);
}
...
sub unlike {
$Test->unlike(@_);
}
Fix :
sub like ($$;$) {
$Test->like(@_);
}
...
sub unlike ($$;$) {
$Test->unlike(@_);
}
Output test-script :
1..4
ok 1 - Output is like 'dog'
ok 2 - Output is unlike 'cat'
ok 3 - Multi-line output is like 'dog'
ok 4 - Multi-line output is unlike 'cat'
Extra test :
#!/usr/local/bin/perl -w
use Test::More;
use strict;
use Test::More tests => 2;
unlike (qx/echo "this is \na dog"/, "/cat/", "Multi-line output is unlike 'cat'");
unlike (qx/echo "this is \na dog"/, "/dog/", "Multi-line output is not unlike 'dog'");
Output :
1..2
ok 1 - Multi-line output is unlike 'cat'
not ok 2 - Multi-line output is not unlike 'dog'
# Failed test (kris1.pl at line 9)
# 'this is
# a dog
# '
# matches '/dog/'
# Looks like you failed 1 tests of 2.