6 use Test::More tests => 19;
11 require_ok(File::Spec->catdir('examples', 'InsideOutClass.pod'));
17 sub meta { InsideOutClass->initialize($_[0]) }
19 Foo->meta->add_attribute('foo' => (
21 predicate => 'has_foo',
24 Foo->meta->add_attribute('bar' => (
27 default => 'FOO is BAR'
32 bless $class->meta->construct_instance(@_) => $class;
40 can_ok($foo, 'has_foo');
41 can_ok($foo, 'get_bar');
42 can_ok($foo, 'set_bar');
44 ok(!$foo->has_foo, '... Foo::foo is not defined yet');
45 is($foo->foo(), undef, '... Foo::foo is not defined yet');
46 is($foo->get_bar(), 'FOO is BAR', '... Foo::bar has been initialized');
48 $foo->foo('This is Foo');
50 ok($foo->has_foo, '... Foo::foo is defined now');
51 is($foo->foo(), 'This is Foo', '... Foo::foo == "This is Foo"');
54 is($foo->get_bar(), 42, '... Foo::bar == 42');
56 my $foo2 = Foo->new();
59 ok(!$foo2->has_foo, '... Foo2::foo is not defined yet');
60 is($foo2->foo(), undef, '... Foo2::foo is not defined yet');
61 is($foo2->get_bar(), 'FOO is BAR', '... Foo2::bar has been initialized');
63 $foo2->set_bar('DONT PANIC');
64 is($foo2->get_bar(), 'DONT PANIC', '... Foo2::bar == DONT PANIC');
66 is($foo->get_bar(), 42, '... Foo::bar == 42');