File: fuzz.t

package info (click to toggle)
libppix-regexp-perl 0.090-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,524 kB
  • sloc: perl: 8,022; makefile: 8
file content (42 lines) | stat: -rw-r--r-- 688 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
package main;

use 5.006;

use strict;
use warnings;

use lib qw{ inc };

use My::Module::Test;
use My::Module::Test qw{ __quote };

note <<'EOD';
Obviously this is not a true fuzz test, just a collection of
pathological strings discovered via fuzz testing. Because the parse of
an invalid string may change, we just see if the code survived the test.
EOD

survival( 'x//' );

survival( ' ' );

done_testing;

sub survival {
    my ( $expr ) = @_;
    my $title = join ' ', 'Parse', __quote( $expr );
    eval {
	PPIx::Regexp->new( $expr );
	1;
    } and do {
	@_ = ( $title );
	goto &pass;
    } or do {
	@_ = ( "$title failed: $@" );
	goto &fail;
    };
}

1;

# ex: set textwidth=72 :