require './test.pl';
}
-plan tests => 5;
+plan tests => 11;
use strict;
use warnings;
+
+my @tests = ('$obj ~~ "key"', '"key" ~~ $obj', '$obj ~~ $obj');
+
{
package Test::Object::NoOverload;
sub new { bless { key => 1 } }
{
my $obj = Test::Object::NoOverload->new;
isa_ok($obj, 'Test::Object::NoOverload');
- my $r = eval { ($obj ~~ 'key') };
-
- local $::TODO = 'To be implemented';
-
- ok(
- ! defined $r,
- "we do not smart match against an object's underlying implementation",
- );
-
- like(
- $@,
- qr/overload/,
- "we die when smart matching an obj with no ~~ overload",
- );
+ for (@tests) {
+ my $r = eval;
+ ok(
+ ! defined $r,
+ "we do not smart match against an object's underlying implementation",
+ );
+ like(
+ $@,
+ qr/overload/,
+ "we die when smart matching an obj with no ~~ overload",
+ );
+ }
}
{
{
my $obj = Test::Object::CopyOverload->new;
isa_ok($obj, 'Test::Object::CopyOverload');
- ok($obj ~~ 'key', 'we are able to make an object ~~ overload');
+ ok(eval, 'we are able to make an object ~~ overload') for @tests;
}