Skip tests for strict constructor on Moose
[gitmo/Mouse.git] / t / 001_mouse / 066-magic.t
CommitLineData
85a74fcf 1#!perl
2use strict;
3use warnings;
feb3c297 4use Test::More tests => 6;
85a74fcf 5
6use Tie::Scalar;
7
8{
9 package MyClass;
10 use Mouse;
11
12 has foo => (
13 is => 'rw',
14 isa => 'Int',
15 );
16 has bar => (
17 is => 'rw',
18 isa => 'Maybe[Int]',
19 );
20}
21
22sub ts_init {
23 tie $_[0], 'Tie::StdScalar', $_[1];
24}
25
26ts_init(my $x, 10);
27
28my $o = MyClass->new();
29is(eval{ $o->foo($x) }, 10)
30 or diag("Error: $@");
31
32ts_init($x, 'foo');
33
34eval{
35 $o->bar($x);
36};
37isnt $@, '';
38
39ts_init $x, 42;
40is(eval{ $o->bar($x) }, 42)
41 or diag("Error: $@");
42
feb3c297 43$o = eval{
44 ts_init(my $a, 10);
45 ts_init(my $b, 42);
46 MyClass->new(foo => $a, bar => $b);
47};
48ok $o;
49is eval{ $o->foo }, 10;
50is eval{ $o->bar }, 42;