2 # This is automatically generated by author/import-moose-test.pl.
3 # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4 use t::lib::MooseCompat;
12 use Scalar::Util 'isweak';
25 ::ok(!$@, '... created the writer method okay');
28 has 'foo_required' => (
29 reader => 'get_foo_required',
30 writer => 'set_foo_required',
34 ::ok(!$@, '... created the required writer method okay');
38 reader => 'get_foo_int',
39 writer => 'set_foo_int',
43 ::ok(!$@, '... created the writer method with type constraint okay');
47 reader => 'get_foo_weak',
48 writer => 'set_foo_weak',
52 ::ok(!$@, '... created the writer method with weak_ref okay');
56 my $foo = Foo->new(foo_required => 'required');
61 can_ok($foo, 'set_foo');
62 is($foo->get_foo(), undef, '... got an unset value');
65 } '... set_foo wrote successfully';
66 is($foo->get_foo(), 100, '... got the correct set value');
68 ok(!isweak($foo->{foo}), '... it is not a weak reference');
74 } '... cannot create without the required attribute';
76 can_ok($foo, 'set_foo_required');
77 is($foo->get_foo_required(), 'required', '... got an unset value');
79 $foo->set_foo_required(100);
80 } '... set_foo_required wrote successfully';
81 is($foo->get_foo_required(), 100, '... got the correct set value');
84 $foo->set_foo_required();
85 } '... set_foo_required died successfully with no value';
88 $foo->set_foo_required(undef);
89 } '... set_foo_required did accept undef';
91 ok(!isweak($foo->{foo_required}), '... it is not a weak reference');
93 # with type constraint
95 can_ok($foo, 'set_foo_int');
96 is($foo->get_foo_int(), undef, '... got an unset value');
98 $foo->set_foo_int(100);
99 } '... set_foo_int wrote successfully';
100 is($foo->get_foo_int(), 100, '... got the correct set value');
103 $foo->set_foo_int("Foo");
104 } '... set_foo_int died successfully';
106 ok(!isweak($foo->{foo_int}), '... it is not a weak reference');
112 can_ok($foo, 'set_foo_weak');
113 is($foo->get_foo_weak(), undef, '... got an unset value');
115 $foo->set_foo_weak($test);
116 } '... set_foo_weak wrote successfully';
117 is($foo->get_foo_weak(), $test, '... got the correct set value');
119 ok(isweak($foo->{foo_weak}), '... it is a weak reference');