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(
20 InsideOutClass::Attribute->new('foo' => (
22 predicate => 'has_foo',
26 Foo->meta->add_attribute(
27 InsideOutClass::Attribute->new('bar' => (
30 default => 'FOO is BAR'
36 bless $class->meta->construct_instance() => $class;
44 can_ok($foo, 'has_foo');
45 can_ok($foo, 'get_bar');
46 can_ok($foo, 'set_bar');
48 ok(!$foo->has_foo, '... Foo::foo is not defined yet');
49 is($foo->foo(), undef, '... Foo::foo is not defined yet');
50 is($foo->get_bar(), 'FOO is BAR', '... Foo::bar has been initialized');
52 $foo->foo('This is Foo');
54 ok($foo->has_foo, '... Foo::foo is defined now');
55 is($foo->foo(), 'This is Foo', '... Foo::foo == "This is Foo"');
58 is($foo->get_bar(), 42, '... Foo::bar == 42');
60 my $foo2 = Foo->new();
63 ok(!$foo2->has_foo, '... Foo2::foo is not defined yet');
64 is($foo2->foo(), undef, '... Foo2::foo is not defined yet');
65 is($foo2->get_bar(), 'FOO is BAR', '... Foo2::bar has been initialized');
67 $foo2->set_bar('DONT PANIC');
68 is($foo2->get_bar(), 'DONT PANIC', '... Foo2::bar == DONT PANIC');
70 is($foo->get_bar(), 42, '... Foo::bar == 42');