projects
/
gitmo/Mouse.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
Add an arg check to appply_metaroles()
[gitmo/Mouse.git]
/
t
/
001_mouse
/
066-magic.t
1
#!perl
2
use strict;
3
use warnings;
4
use Test::More tests => 6;
5
6
use 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
22
sub ts_init {
23
tie $_[0], 'Tie::StdScalar', $_[1];
24
}
25
26
ts_init(my $x, 10);
27
28
my $o = MyClass->new();
29
is(eval{ $o->foo($x) }, 10)
30
or diag("Error: $@");
31
32
ts_init($x, 'foo');
33
34
eval{
35
$o->bar($x);
36
};
37
isnt $@, '';
38
39
ts_init $x, 42;
40
is(eval{ $o->bar($x) }, 42)
41
or diag("Error: $@");
42
43
$o = eval{
44
ts_init(my $a, 10);
45
ts_init(my $b, 42);
46
MyClass->new(foo => $a, bar => $b);
47
};
48
ok $o;
49
is eval{ $o->foo }, 10;
50
is eval{ $o->bar }, 42;