# Adjusted.t 18sep14waw use strict; use warnings; use Test::More # tests => ?? + 1 # Test::NoWarnings adds 1 test 'no_plan' ; use Test::NoWarnings; use Test::Exception; use constant VALS => ( # from OP perlmonks node 1100962 '00000000{', # +0 '00000000{', # +0 '00000000{', # +0 '00000369I', # +3699 '00000020{', # +200 '00000000{', # +0 '00000100}', # -1000 '00000289R', # -2899 ); use constant SUM => 3699 + 200 - 1000 - 2899; # sum == 0 BEGIN { use_ok 'Adjusted'; } TEST_VECTOR: for my $ar_vector ( "just one vector for now", [ SUM, 'OPed data, sum', VALS ], ) { if (not ref $ar_vector) { note $ar_vector; next TEST_VECTOR; } my ($sum, $msg, @vals) = @$ar_vector; ok Adjusted::values_summed(@vals) == $sum, $msg; } # end for TEST_VECTOR note "\nTAKE NOTE -- test various exceptions \n\n"; EXCEPTION: for my $ar_vector ( [ qr'bad value', 'too few digits', '0000369I' ], [ qr'bad value', 'too many digits', '000000369I' ], [ qr'bad value', 'unknown suffix', '00000369Z' ], "should empty values list really be an exception?", [ qr'uninitialized value in division', 'empty values list', () ], ) { if (not ref $ar_vector) { note $ar_vector; next EXCEPTION; } my ($rx, $msg, @vals) = @$ar_vector; throws_ok { Adjusted::values_summed(@vals) } $rx, $msg; } # end for EXCEPTION