File: 20_careful_exception_handling.t

package info (click to toggle)
libdata-formvalidator-perl 4.66-1%2Bsqueeze1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 588 kB
  • ctags: 127
  • sloc: perl: 2,756; makefile: 2
file content (38 lines) | stat: -rw-r--r-- 868 bytes parent folder | download | duplicates (7)
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
#!/usr/bin/perl -w

# This tests to make sure that when we test $@, we are testing the right thing.
# inspired by a patch from dom@semantico.com
use lib ('.','../t');

$^W = 1;

use Test::More tests => 1;

use strict;
use Data::FormValidator;

# So as to not trigger a require later on in the code.
require UNIVERSAL;

my $input_profile =
{
	required => 'nothing',
};

my $validator = new Data::FormValidator({default => $input_profile});

my $input_hashref = { 
	'1_required' => 1,
	'1_optional' => 1,
};

eval {
        # populate $@ to see if D::FV dies when it shouldn't
        $@ = 'exceptional value';
        my ($valids, $missings, $invalids, $unknowns) = ({},[],[],[]);
	($valids, $missings, $invalids, $unknowns) = $validator->validate($input_hashref, 'default');
};

unlike($@, qr/Error compiling regular expression/);

# vim: set ai et sw=8 syntax=perl :