summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MANIFEST1
-rw-r--r--t/op/overload_integer.t55
2 files changed, 56 insertions, 0 deletions
diff --git a/MANIFEST b/MANIFEST
index b4d5ea06e0..38edcca4ab 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -3740,6 +3740,7 @@ t/op/oct.t See if oct and hex work
t/op/ord.t See if ord works
t/op/or.t See if || works in weird situations
t/op/override.t See if operator overriding works
+t/op/overload_integer.t See if overload::constant for integer works after "use".
t/op/pack.t See if pack and unpack work
t/op/pat.t See if esoteric patterns work
t/op/pos.t See if pos works
diff --git a/t/op/overload_integer.t b/t/op/overload_integer.t
new file mode 100644
index 0000000000..073ac2a55c
--- /dev/null
+++ b/t/op/overload_integer.t
@@ -0,0 +1,55 @@
+#!./perl
+
+use strict;
+use warnings;
+
+print "1..2\n";
+
+package Foo;
+
+use overload;
+
+sub import
+{
+ overload::constant 'integer' => sub { return shift; };
+}
+
+package main;
+
+BEGIN { $INC{'Foo.pm'} = "/lib/Foo.pm" }
+
+use Foo;
+
+my $result = eval "5+6";
+
+my $error = $@;
+
+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";
+}
+