Improve enum to accept "enum($name, $arrayref)" construction
[gitmo/Mouse.git] / t / 001_mouse / 060-threads.t
1 #!perl
2 use strict;
3 use warnings;
4 use constant HAS_THREADS => eval{ require threads };
5
6 use Test::More HAS_THREADS ? (tests => 6) : (skip_all => "This is a test for threads ($@)");
7
8 {
9     package MyClass;
10     use Mouse;
11
12     has foo => (
13         is => 'rw',
14         isa => 'Int',
15     );
16 }
17
18 my $o = MyClass->new(foo => 42);
19 threads->create(sub{
20     my $x = MyClass->new(foo => 1);
21     is $x->foo, 1;
22
23     $x->foo(2);
24
25     is $x->foo, 2;
26
27     MyClass->meta->make_immutable();
28
29     $x = MyClass->new(foo => 10);
30     is $x->foo, 10;
31
32     $x->foo(20);
33
34     is $x->foo, 20;
35 })->join();
36
37 is $o->foo, 42;
38 ok !$o->meta->is_immutable;
39