File: GenericValidator.pm

package info (click to toggle)
libcode-tidyall-perl 0.83~ds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,036 kB
  • sloc: perl: 5,240; lisp: 47; makefile: 2; sh: 1
file content (50 lines) | stat: -rw-r--r-- 1,416 bytes parent folder | download | duplicates (2)
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
package TestFor::Code::TidyAll::Plugin::GenericValidator;

use Test::Class::Most parent => 'TestFor::Code::TidyAll::Plugin';
use FindBin    qw( $Bin );
use Path::Tiny qw( path );

sub test_main : Tests {
    my $self = shift;

    my $cmd = join q{ }, $self->_this_perl, path( $Bin, qw( helper-bin generic-validator.pl ) );

    $self->tidyall(
        source    => 'this text is ok',
        expect_ok => 1,
        desc      => 'text does not contain forbidden word',
        conf      => {
            cmd => $cmd,
        },
    );
    $self->tidyall(
        source       => 'this text is forbidden',
        expect_error => qr/exited with 1/,
        desc         => 'text does contain forbidden word',
        conf         => {
            cmd => $cmd,
        },
    );

    my $exit = join q{ }, $self->_this_perl, path( $Bin, qw( helper-bin exit.pl ) );
    $self->tidyall(
        source    => 'this text is fine',
        expect_ok => 1,
        desc      => 'exit code of 2 is ok',
        conf      => {
            cmd           => "$exit 2",
            ok_exit_codes => [ 0, 1, 2 ],
        },
    );
    $self->tidyall(
        source       => 'this text is fine',
        expect_error => qr/exited with 3/,
        desc         => 'exit code of 3 is an exception',
        conf         => {
            cmd           => "$exit 3",
            ok_exit_codes => [ 0, 1, 2 ],
        },
    );
}

1;