# foo.t use strict; use warnings; use Test::More qw/no_plan/; use Test::Exception; require_ok(q{foo.pl}); # ------ negative tests for add() ------ throws_ok { add(); } qr/error/i, q{Expect error when no args}; throws_ok { add('a'); } qr/error/i, q{Expect error with non-numeric input}; throws_ok { add('a1'); } qr/error/i, q{Expect error with non-numeric input}; throws_ok { add(1,'b'); } qr/error/i, q{Expect error with non-numeric input}; throws_ok { add(1,'b1'); } qr/error/i, q{Expect error with non-numeric input}; # ------ positive tests for add() ------ cmp_ok(add(2,2), q{==}, 4, q{Expect 2+2=4}); # Note: I want a warning here: cmp_ok(add(1000,1000), q{==}, 2000, q{Expect 1000+1000=2000}); __END__