File: 27-string-as-type.t

package info (click to toggle)
libparams-validate-perl 0.91-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 524 kB
  • ctags: 729
  • sloc: perl: 2,596; makefile: 52
file content (33 lines) | stat: -rw-r--r-- 617 bytes parent folder | download
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
#!/usr/bin/perl -w

use strict;

use Params::Validate qw(validate);
use Test::More tests => 2;

{
    my @p = ( foo => 1 );

    eval
    {
        validate( @p,
                  { foo => { type => 'SCALAR' } },
                );
    };

    like( $@, qr/\QThe 'foo' parameter ("1") has a type specification which is not a number. It is a string - SCALAR/ );
}

{
    my @p = ( foo => 1 );

    eval
    {
        validate( @p,
                  { foo => { type => undef } },
                );
    };

    like( $@, qr/\QThe 'foo' parameter ("1") has a type specification which is not a number. It is undef/ );

}