1 2use strict; 3use warnings; 4use Test::More; 5 6BEGIN { 7 eval "use PDL::Slatec;"; 8 if ( !$@ ) { 9 eval "use PDL::Graphics::Limits;"; 10 plan tests => 12; 11 } else { 12 plan skip_all => 'PDL::Slatec not available'; 13 } 14}; 15 16*parse_vecspec = \&PDL::Graphics::Limits::parse_vecspec; 17 18################################################################# 19 20# test parsing of hash key specs 21 22my @good = ( 23 'x<n>p&f' => { data => 'x', 24 errn => 'n', 25 errp => 'p', 26 trans => 'f' }, 27 28 '<n>p&f' => { errn => 'n', 29 errp => 'p', 30 trans => 'f' }, 31 32 'x,<n,>p,&f' => { data => 'x', 33 errn => 'n', 34 errp => 'p', 35 trans => 'f' }, 36 37 'x <n >p &f' => { data => 'x', 38 errn => 'n', 39 errp => 'p', 40 trans => 'f' }, 41 42 43 '<n>p&f' => { errn => 'n', 44 errp => 'p', 45 trans => 'f' }, 46 47 '&f' => { trans => 'f' }, 48 49 'x' => { data => 'x' }, 50 51 '&' => { trans => undef }, 52 53 undef() => { }, 54 55 '<>&' => { errn => undef, 56 errp => undef, 57 trans => undef }, 58 59 '=s' => { errn => 's', 60 errp => 's' }, 61 62 63); 64 65while( my ( $spec, $exp ) = splice( @good, 0, 2 ) ) 66{ 67 my $res = { parse_vecspec($spec) }; 68 ok( eq_hash( $exp, $res ), defined $spec ? $spec : 'undef' ); 69} 70 71my @bad = ( '<<' ); 72 73for my $spec ( @bad ) 74{ 75 eval { parse_vecspec($spec) }; 76 ok( $@, "$spec" ); 77} 78 79