From: Graham Knop Date: Wed, 25 Apr 2018 12:28:46 +0000 (+0200) Subject: $_call_if_object with DOES should fail without a DOES method X-Git-Tag: v1.000010~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f7d8bf5245f96e7dea55fffc2766beab3d65b84e;p=p5sagit%2FSafe-Isa.git $_call_if_object with DOES should fail without a DOES method --- diff --git a/t/safe_does.t b/t/safe_does.t index e1ae548..b079e65 100644 --- a/t/safe_does.t +++ b/t/safe_does.t @@ -42,8 +42,17 @@ ok($bar->$_does('Foo'), 'bar $_does Foo'); ok(eval { $blam->$_does('Foo'); 1 }, 'no boom today'); ok(eval { $undef->$_does('Foo'); 1 }, 'nor tomorrow either'); -ok($foo->$_call_if_object(DOES => 'Foo'), 'foo $_call_if_object(DOES => Foo)'); -ok($bar->$_call_if_object(DOES => 'Foo'), 'bar $_call_if_object(DOES => Foo)'); +if (UNIVERSAL->can('DOES')) { + ok($foo->$_call_if_object(DOES => 'Foo'), 'foo $_call_if_object(DOES => Foo)'); + ok($bar->$_call_if_object(DOES => 'Foo'), 'bar $_call_if_object(DOES => Foo)'); +} +else { + ok(!eval { $foo->$_call_if_object(DOES => 'Foo'); 1 }, + 'foo $_call_if_object(DOES => Foo) fails without UNIVERSAL::DOES'); + ok(!eval { $bar->$_call_if_object(DOES => 'Foo'); 1 }, + 'bar $_call_if_object(DOES => Foo) fails without UNIVERSAL::DOES'); +} + ok(eval { $blam->$_call_if_object(DOES => 'Foo'); 1 }, 'no boom today'); ok(eval { $undef->$_call_if_object(DOES => 'Foo'); 1 }, 'nor tomorrow either');