File: limits_keyspecs.t

package info (click to toggle)
pdl 1%3A2.4.7%2Bdfsg-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 10,128 kB
  • ctags: 5,821
  • sloc: perl: 26,328; fortran: 13,113; ansic: 9,378; makefile: 71; sh: 50; sed: 6
file content (78 lines) | stat: -rw-r--r-- 1,611 bytes parent folder | download | duplicates (8)
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
71
72
73
74
75
76
77
78

use strict;
use warnings;
use Test::More;

BEGIN {
  eval "use PDL::Slatec;";
  if ( !$@ ) {
    eval "use PDL::Graphics::Limits;";
    plan tests => 12;
  } else {
    plan skip_all => 'PDL::Slatec not available';
  }
};

*parse_vecspec = \&PDL::Graphics::Limits::parse_vecspec;

#################################################################

# test parsing of hash key specs

my @good = (
            'x<n>p&f' => { data => 'x',
      		     errn   => 'n',
      		     errp   => 'p',
      		     trans => 'f' },
            
            '<n>p&f' => { errn   => 'n',
      		    errp   => 'p',
      		    trans => 'f' },
            
            'x,<n,>p,&f' => { data => 'x',
      			errn   => 'n',
      			errp   => 'p',
      			trans => 'f' },

            'x <n >p &f' => { data => 'x',
      			errn   => 'n',
      			errp   => 'p',
      			trans => 'f' },

            
            '<n>p&f'  => { errn   => 'n',
      		     errp   => 'p',
      		     trans => 'f' },
            
            '&f'      => { trans => 'f' },

            'x'       => { data => 'x' },

            '&'       => { trans => undef },

            undef()   =>  { },

            '<>&'     => { errn   => undef,
      		     errp   => undef,
      		     trans => undef },

            '=s'  => { errn   => 's',
      	         errp   => 's' },


);

while( my ( $spec, $exp ) = splice( @good, 0, 2 ) )
{
  my $res = { parse_vecspec($spec) };
  ok( eq_hash( $exp, $res ), defined $spec ? $spec : 'undef' );
}

my @bad = ( '<<' );

for my $spec ( @bad )
{
  eval { parse_vecspec($spec) };
  ok( $@, "$spec" );
}