From: gfx Date: Wed, 9 Dec 2009 11:54:28 +0000 (+0900) Subject: More robust tests for threads X-Git-Tag: 0.44~10 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=commitdiff_plain;h=aff73a9e6d34b45a21123586c0893921df98181b More robust tests for threads --- diff --git a/t/001_mouse/060-threads.t b/t/001_mouse/060-threads.t index 32eb2bc..06748db 100644 --- a/t/001_mouse/060-threads.t +++ b/t/001_mouse/060-threads.t @@ -11,29 +11,36 @@ use Test::More HAS_THREADS ? (tests => 6) : (skip_all => "This is a test for thr has foo => ( is => 'rw', - isa => 'Int', + isa => 'Foo', + ); + + package Foo; + use Mouse; + + has value => ( + is => 'rw', ); } -my $o = MyClass->new(foo => 42); +my $o = MyClass->new(foo => Foo->new(value => 42)); threads->create(sub{ - my $x = MyClass->new(foo => 1); - is $x->foo, 1; + my $x = MyClass->new(foo => Foo->new(value => 1)); + is $x->foo->value, 1; - $x->foo(2); + $x->foo(Foo->new(value => 2)); - is $x->foo, 2; + is $x->foo->value, 2; MyClass->meta->make_immutable(); - $x = MyClass->new(foo => 10); - is $x->foo, 10; + $x = MyClass->new(foo => Foo->new(value => 10)); + is $x->foo->value, 10; - $x->foo(20); + $x->foo(Foo->new(value => 20)); - is $x->foo, 20; + is $x->foo->value, 20; })->join(); -is $o->foo, 42; +is $o->foo->value, 42; ok !$o->meta->is_immutable;