Move is_valid_class_name into XS
[gitmo/Mouse.git] / t / 001_mouse / 058-accessor-leaks.t
1 #!perl
2 # This is based on Class-MOP/t/312_anon_class_leak.t
3 use strict;
4 use warnings;
5 use Test::More;
6
7 BEGIN {
8     eval "use Test::LeakTrace 0.10;";
9     plan skip_all => "Test::LeakTrace 0.10 is required for this test" if $@;
10 }
11
12 plan tests => 11;
13
14 {
15     package MyClass;
16     use Mouse;
17
18     has simple => (is => 'rw');
19
20     has w_int => (is => 'rw', isa => 'Int');
21     has w_int_or_undef
22               => (is => 'rw', isa => 'Int | Undef');
23     has w_foo => (is => 'rw', isa => 'Foo');
24     has w_aint=> (is => 'rw', isa => 'ArrayRef[Int]');
25 }
26
27 no_leaks_ok{
28     MyClass->new();
29 };
30
31 my $o = MyClass->new;
32 no_leaks_ok {
33     $o->simple(10);
34 };
35 no_leaks_ok {
36     $o->simple();
37 };
38
39 no_leaks_ok {
40     $o->w_int(10);
41 };
42 no_leaks_ok {
43     $o->w_int();
44 };
45
46 no_leaks_ok {
47     $o->w_int_or_undef(10);
48 };
49 no_leaks_ok {
50     $o->w_int_or_undef();
51 };
52
53 my $foo = bless {}, 'Foo';
54 no_leaks_ok {
55     $o->w_foo($foo);
56 };
57 no_leaks_ok {
58     $o->w_int();
59 };
60
61 my $aref = [10];
62 no_leaks_ok {
63     $o->w_aint($aref);
64 };
65 no_leaks_ok {
66     $o->w_aint();
67 };
68
69
70