Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / t / 001_mouse / 011-lazy.t
index 2d87867..d9b0863 100644 (file)
@@ -1,8 +1,7 @@
 #!/usr/bin/env perl
 use strict;
 use warnings;
-use Test::More tests => 16;
-use Test::Exception;
+use Test::More;
 
 my $lazy_run = 0;
 
@@ -22,12 +21,13 @@ do {
         default => "welp",
     );
 
-    ::throws_ok {
+    eval {
         has lazy_no_default => (
             is   => 'rw',
             lazy => 1,
         );
-    } qr/You cannot have lazy attribute \(lazy_no_default\) without specifying a default value for it/;
+    };
+    ::like $@, qr/You cannot have a lazy attribute \(lazy_no_default\) without specifying a default value for it/;
 };
 
 my $object = Class->new;
@@ -48,6 +48,9 @@ is($lazy_run, 1, "lazy coderef invoked once");
 is($object->lazy_value, "newp", "got new value");
 is($lazy_run, 1, "lazy coderef invoked once");
 
+is($object->lazy(42), 42);
+is($object->lazy_value(3.14), 3.14);
+
 my $object2 = Class->new(lazy => 'very', lazy_value => "heh");
 is($lazy_run, 1, "lazy attribute not initialized when an argument is passed to the constructor");
 
@@ -55,3 +58,4 @@ is($object2->lazy, 'very', 'value from the constructor');
 is($object2->lazy_value, 'heh', 'value from the constructor');
 is($lazy_run, 1, "lazy coderef not invoked, we already have a value");
 
+done_testing;