File: open.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 (70 lines) | stat: -rw-r--r-- 1,734 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
66
67
68
69
70
#!perl 

use strict;
use warnings;
our $mock;

use Test::Builder::Tester tests => 3;
use Test::More;
BEGIN {
  eval "use Test::MockObject::Extends";
  unless( $@ ) {
    use FileHandle;
    $mock= Test::MockObject::Extends->new(FileHandle->new);
    $mock->fake_new( 'FileHandle' );
    $mock->set_false( 'open' );
  }

  use_ok( 'FileHandle' );
  use_ok( 'Test::Regression' );
}

use Test::Regression;
srand(42);
use lib qw(t/lib);
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 empty_string_function {
    return '';
}


test_out("not ok 1 - f1 gen: cannot open t/output/f1");
test_out("not ok 2 - f1 check: cannot read t/output/f1");
test_out("not ok 3 - f2 gen: cannot open t/output/f2");
test_out("not ok 4 - f2 check: cannot read t/output/f2");
test_out("not ok 5 - f4 gen: cannot open t/output/f4");
test_out("not ok 6 - f4 check: cannot read t/output/f4");
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(\&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);