summaryrefslogtreecommitdiff
path: root/t/lib/OverloadingTests.pm
diff options
context:
space:
mode:
Diffstat (limited to 't/lib/OverloadingTests.pm')
-rw-r--r--t/lib/OverloadingTests.pm47
1 files changed, 47 insertions, 0 deletions
diff --git a/t/lib/OverloadingTests.pm b/t/lib/OverloadingTests.pm
new file mode 100644
index 0000000..d1ab195
--- /dev/null
+++ b/t/lib/OverloadingTests.pm
@@ -0,0 +1,47 @@
+package OverloadingTests;
+
+use strict;
+use warnings;
+
+use Test::More 0.88;
+
+sub test_overloading_for_package {
+ my $package = shift;
+
+ ok(
+ overload::Overloaded($package),
+ "$package is overloaded"
+ );
+ ok(
+ overload::Method( $package, q{""} ),
+ "$package overloads stringification"
+ );
+}
+
+sub test_no_overloading_for_package {
+ my $package = shift;
+
+ ok(
+ !overload::Overloaded($package),
+ "$package is not overloaded"
+ );
+ ok(
+ !overload::Method( $package, q{""} ),
+ "$package does not overload stringification"
+ );
+}
+
+sub test_overloading_for_object {
+ my $class = shift;
+ my $thing = shift || "$class object";
+
+ my $object = ref $class ? $class : $class->new( { message => 'foo' } );
+
+ is(
+ "$object",
+ 'foo',
+ "$thing stringifies to value of message attribute"
+ );
+}
+
+1;