File: regression.t

package info (click to toggle)
libtest-regression-perl 0.08-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 168 kB
  • sloc: perl: 288; makefile: 2
file content (65 lines) | stat: -rw-r--r-- 1,570 bytes parent folder | download | duplicates (6)
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
#!perl 

use strict;
use warnings;
use Test::Builder::Tester tests => 1;
use Test::More;
use Test::Regression;
use lib qw(t/lib);
srand(42);
use OutputDir;

sub faithful_function {
    my $r = "";
    for(my $i = 0; $i < 10; $i++) {
	$r .= "$i\n";
    }
    return $r;
}

sub unfaithful_function {
    my $r = "";
    for(my $i = 0; $i < 10; $i++) {
	$r .= rand()."\n";
    }
    return $r;
}

sub fatal_function {
    die "How am I doing?";
}

sub empty_string_function {
    return '';
}


test_out("ok 1 - f1 gen");
test_out("ok 2 - f1 check");
test_out("ok 3 - f2 gen");
test_out("not ok 4 - f2 check");
test_out("not ok 5 - f3 gen");
test_out("not ok 6 - f3 check");
test_out("ok 7 - f4 gen");
test_out("ok 8 - f4 check");
test_diag("  Failed test 'f2 check'");

$ENV{TEST_REGRESSION_GEN} = 1;
ok_regression(\&faithful_function, "t/output/f1", "f1 gen");
delete $ENV{TEST_REGRESSION_GEN};
ok_regression(\&faithful_function, "t/output/f1", "f1 check");
$ENV{TEST_REGRESSION_GEN} = 1;
ok_regression(\&unfaithful_function, "t/output/f2", "f2 gen");
delete $ENV{TEST_REGRESSION_GEN};
ok_regression(\&unfaithful_function, "t/output/f2", "f2 check");
$ENV{TEST_REGRESSION_GEN} = 1;
ok_regression(\&fatal_function, "t/output/f3", "f3 gen");
delete $ENV{TEST_REGRESSION_GEN};
ok_regression(\&fatal_function, "t/output/f3", "f3 check");
$ENV{TEST_REGRESSION_GEN} = 1;
ok_regression(\&empty_string_function, "t/output/f4", "f4 gen");
delete $ENV{TEST_REGRESSION_GEN};
ok_regression(\&empty_string_function, "t/output/f4", "f4 check");

test_test(name=>"blah", skip_err=>1);