Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / t / 001_mouse / 060-threads.t
index 1fb4c62..c6dd876 100644 (file)
@@ -6,9 +6,8 @@ use Test::More;
 
 use if !HAS_THREADS, 'Test::More',
     (skip_all => "This is a test for threads ($@)");
-use if $Test::More::VERSION == 2.00_01, 'Test::More',
-    (skip_all => "Test::Builder2 2.00_01 has bugs about threads");
-
+use if $Test::More::VERSION >= 2.00, 'Test::More',
+    (skip_all => "Test::Builder2 has bugs about threads");
 
 {
     package MyTraits;
@@ -21,6 +20,12 @@ use if $Test::More::VERSION == 2.00_01, 'Test::More',
         is => 'rw',
         isa => 'Foo',
     );
+    has bar => (
+        is => 'rw',
+
+        lazy    => 1,
+        default => sub { 42 },
+    );
 
     package Foo;
     use Mouse;
@@ -32,6 +37,7 @@ use if $Test::More::VERSION == 2.00_01, 'Test::More',
         traits => [qw(MyTraits)],
     );
 }
+pass;
 
 my $o = MyClass->new(foo => Foo->new(value => 42));
 threads->create(sub{
@@ -50,6 +56,8 @@ threads->create(sub{
     $x->foo(Foo->new(value => 20));
 
     is $x->foo->value, 20;
+
+    is $x->bar, 42, 'callback for default';
 })->join();
 
 is $o->foo->value, 42;