Improve enum to accept "enum($name, $arrayref)" construction
[gitmo/Mouse.git] / t / 001_mouse / 060-threads.t
CommitLineData
f259aaad 1#!perl
2use strict;
3use warnings;
4use constant HAS_THREADS => eval{ require threads };
5
6use 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
18my $o = MyClass->new(foo => 42);
19threads->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
37is $o->foo, 42;
38ok !$o->meta->is_immutable;
39