summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Kuskie <colink@perldreamer.com>2012-09-13 18:54:13 -0700
committerSteffen Mueller <smueller@cpan.org>2012-09-14 07:56:04 +0200
commitf9512aff8167b8979754fff88ecf90ca11d50ee6 (patch)
tree7870094dd22a5152419d4e2230c4e356e4ae87ea
parent09b1b8c1d05eae2dbab545ec0b6ead31183f8491 (diff)
downloadperl-f9512aff8167b8979754fff88ecf90ca11d50ee6.tar.gz
Refactor t/op/overload_integer.t to use test.pl instead of making TAP by hand.
With minor change from committer: Always assign $@ asap after an eval.
-rw-r--r--t/op/overload_integer.t42
1 files changed, 11 insertions, 31 deletions
diff --git a/t/op/overload_integer.t b/t/op/overload_integer.t
index 073ac2a55c..2375ab94c4 100644
--- a/t/op/overload_integer.t
+++ b/t/op/overload_integer.t
@@ -1,9 +1,15 @@
#!./perl
+BEGIN {
+ chdir 't' if -d 't';
+ push @INC, '../lib';
+ require './test.pl';
+}
+
use strict;
use warnings;
-print "1..2\n";
+plan tests => 2;
package Foo;
@@ -11,7 +17,7 @@ use overload;
sub import
{
- overload::constant 'integer' => sub { return shift; };
+ overload::constant 'integer' => sub { return shift };
}
package main;
@@ -21,35 +27,9 @@ BEGIN { $INC{'Foo.pm'} = "/lib/Foo.pm" }
use Foo;
my $result = eval "5+6";
-
my $error = $@;
+$result //= '';
-my $label = "No exception was thrown with an overload::constant 'integer' inside an eval.";
-# TEST
-if ($error eq "")
-{
- print "ok 1 - $label\n"
-}
-else
-{
- print "not ok 1 - $label\n";
- print "# Error is $error\n";
-}
-
-$label = "Correct solution";
-
-if (!defined($result))
-{
- $result = "";
-}
-# TEST
-if ($result eq 11)
-{
- print "ok 2 - $label\n";
-}
-else
-{
- print "not ok 2 - $label\n";
- print "# Result is $result\n";
-}
+is ($error, '', "No exception was thrown with an overload::constant 'integer' inside an eval.");
+is ($result, 11, "Correct solution");