File: tests

package info (click to toggle)
libtest-inter-perl 1.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 352 kB
  • sloc: perl: 1,776; sh: 22; makefile: 6
file content (42 lines) | stat: -rwxr-xr-x 1,067 bytes parent folder | download
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
#!/usr/bin/perl

use Test::Inter;
$o = new Test::Inter;

print "The following demonstrates some improperly formed tests\n\n";

sub func1 {
  my($a,$b) = @_;

  if    ($a eq 'a'  &&  $b eq 'b') { return 1; }
  elsif ($a eq 'c'  &&  $b eq 'd') { return 2; }
  elsif ($a eq 'e'  &&  $b eq 'f') { return 3; }
}

print "The 2nd one fails with 'expected results for some tests, not others'\n\n";
$o->tests(func  => \&func1,
          tests => "a b => 1

                    c d

                    e f => 3");

print "\n\nFails with '=>' found twice\n\n";
$o->tests(func  => \&func1,
          tests => "a b => 1 => 1");

print "\n\nFails with odd number of elements in hash\n\n";
$o->tests(func  => \&func1,
          tests => "{ a b c } => 1");

print "\n\nFails with improper quoting\n\n";
$o->tests(func  => \&func1,
          tests => "a 'b => 1");

print "\n\nFails with unable to parse\n\n";
$o->tests(func  => \&func1,
          tests => "(a b c");

print "\n\nFails with unexpected token\n\n";
$o->tests(func  => \&func1,
          tests => "(a b c)(d e) => 1");