| 1 |
#!/usr/bin/perl |
| 2 |
|
| 3 |
use Test::Inter; |
| 4 |
$o = new Test::Inter; |
| 5 |
|
| 6 |
print "The following demonstrates some improperly formed tests\n\n"; |
| 7 |
|
| 8 |
sub func1 { |
| 9 |
my($a,$b) = @_; |
| 10 |
|
| 11 |
if ($a eq 'a' && $b eq 'b') { return 1; } |
| 12 |
elsif ($a eq 'c' && $b eq 'd') { return 2; } |
| 13 |
elsif ($a eq 'e' && $b eq 'f') { return 3; } |
| 14 |
} |
| 15 |
|
| 16 |
print "The 2nd one fails with 'expected results for some tests, not others'\n\n"; |
| 17 |
$o->tests(func => \&func1, |
| 18 |
tests => "a b => 1 |
| 19 |
|
| 20 |
c d |
| 21 |
|
| 22 |
e f => 3"); |
| 23 |
|
| 24 |
print "\n\nFails with '=>' found twice\n\n"; |
| 25 |
$o->tests(func => \&func1, |
| 26 |
tests => "a b => 1 => 1"); |
| 27 |
|
| 28 |
print "\n\nFails with odd number of elements in hash\n\n"; |
| 29 |
$o->tests(func => \&func1, |
| 30 |
tests => "{ a b c } => 1"); |
| 31 |
|
| 32 |
print "\n\nFails with improper quoting\n\n"; |
| 33 |
$o->tests(func => \&func1, |
| 34 |
tests => "a 'b => 1"); |
| 35 |
|
| 36 |
print "\n\nFails with unable to parse\n\n"; |
| 37 |
$o->tests(func => \&func1, |
| 38 |
tests => "(a b c"); |
| 39 |
|
| 40 |
print "\n\nFails with unexpected token\n\n"; |
| 41 |
$o->tests(func => \&func1, |
| 42 |
tests => "(a b c)(d e) => 1"); |