File: tests.t

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 (66 lines) | stat: -rwxr-xr-x 1,142 bytes parent folder | download | duplicates (3)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/perl

use warnings 'all';
use strict;
BEGIN {
   if (-d "lib") {
      use lib "./lib";
   } elsif (-d "../lib") {
      use lib "../lib";
   }
}

use Test::Inter;
my $ti = new Test::Inter $0;

sub func {
  my(@args) = @_;
  my @ret;
  foreach my $arg (@args) {
     push(@ret,length($arg));
  }
  return @ret;
}

$ti->tests(func  => \&func,
          tests => "foo        => 3

                    a ab       => 1 2

                    (x xy xyz) => 1 2 3

                    (a) (bc)   => 1 2

                    (a (b cd)) => 1 1 2

                    (,a,bc)    => 1 2

                    (,a,b c)   => 1 3
                   ");

$ti->tests(func     => \&func,
          expected => [ [1,2] ],
          tests    => "a ab

                       c cd

                       e ef
                      ");

$ti->tests(func     => \&func,
          expected => "1 2",
          tests    => "a ab

                       c cd

                       e ef
                      ");

$ti->tests(tests    => " '' ''

                        [] []

                        {} {}
                      ");

$ti->done_testing();