add eval and error support to the t/op/smartmatch.t test
[p5sagit/p5-mst-13.2.git] / t / op / smobj.t
index 733e31c..9d1a0a5 100644 (file)
@@ -6,11 +6,14 @@ BEGIN {
     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 } }
@@ -19,20 +22,18 @@ use warnings;
 {
     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",
+       );
+    }
 }
 
 {
@@ -44,5 +45,5 @@ use warnings;
 {
     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;
 }