6 use Test::More tests => 67;
11 use_ok('Class::MOP::Attribute');
15 my $attr = Class::MOP::Attribute->new('$foo');
16 isa_ok($attr, 'Class::MOP::Attribute');
18 is($attr->name, '$foo', '... $attr->name == $foo');
19 ok($attr->has_init_arg, '... $attr does have an init_arg');
20 is($attr->init_arg, '$foo', '... $attr init_arg is the name');
22 ok(!$attr->has_accessor, '... $attr does not have an accessor');
23 ok(!$attr->has_reader, '... $attr does not have an reader');
24 ok(!$attr->has_writer, '... $attr does not have an writer');
25 ok(!$attr->has_default, '... $attr does not have an default');
27 my $class = Class::MOP::Class->initialize('Foo');
28 isa_ok($class, 'Class::MOP::Class');
31 $attr->attach_to_class($class);
32 } '... attached a class successfully';
34 is($attr->associated_class, $class, '... the class was associated correctly');
36 my $attr_clone = $attr->clone();
37 isa_ok($attr_clone, 'Class::MOP::Attribute');
38 isnt($attr, $attr_clone, '... but they are different instances');
40 is($attr->associated_class, $attr_clone->associated_class, '... the associated classes are the same though');
41 is($attr->associated_class, $class, '... the associated classes are the same though');
42 is($attr_clone->associated_class, $class, '... the associated classes are the same though');
44 is_deeply($attr, $attr_clone, '... but they are the same inside');
48 my $attr = Class::MOP::Attribute->new('$foo', (
52 isa_ok($attr, 'Class::MOP::Attribute');
54 is($attr->name, '$foo', '... $attr->name == $foo');
56 ok($attr->has_init_arg, '... $attr does have an init_arg');
57 is($attr->init_arg, '-foo', '... $attr->init_arg == -foo');
58 ok($attr->has_default, '... $attr does have an default');
59 is($attr->default, 'BAR', '... $attr->default == BAR');
61 ok(!$attr->has_accessor, '... $attr does not have an accessor');
62 ok(!$attr->has_reader, '... $attr does not have an reader');
63 ok(!$attr->has_writer, '... $attr does not have an writer');
65 my $attr_clone = $attr->clone();
66 isa_ok($attr_clone, 'Class::MOP::Attribute');
67 isnt($attr, $attr_clone, '... but they are different instances');
69 is($attr->associated_class, $attr_clone->associated_class, '... the associated classes are the same though');
70 is($attr->associated_class, undef, '... the associated class is actually undef');
71 is($attr_clone->associated_class, undef, '... the associated class is actually undef');
73 is_deeply($attr, $attr_clone, '... but they are the same inside');
77 my $attr = Class::MOP::Attribute->new('$foo', (
82 isa_ok($attr, 'Class::MOP::Attribute');
84 is($attr->name, '$foo', '... $attr->name == $foo');
86 ok($attr->has_init_arg, '... $attr does have an init_arg');
87 is($attr->init_arg, '-foo', '... $attr->init_arg == -foo');
88 ok($attr->has_default, '... $attr does have an default');
89 is($attr->default, 'BAR', '... $attr->default == BAR');
91 ok($attr->has_accessor, '... $attr does have an accessor');
92 is($attr->accessor, 'foo', '... $attr->accessor == foo');
94 ok(!$attr->has_reader, '... $attr does not have an reader');
95 ok(!$attr->has_writer, '... $attr does not have an writer');
97 my $attr_clone = $attr->clone();
98 isa_ok($attr_clone, 'Class::MOP::Attribute');
99 isnt($attr, $attr_clone, '... but they are different instances');
101 is_deeply($attr, $attr_clone, '... but they are the same inside');
105 my $attr = Class::MOP::Attribute->new('$foo', (
111 isa_ok($attr, 'Class::MOP::Attribute');
113 is($attr->name, '$foo', '... $attr->name == $foo');
115 ok($attr->has_init_arg, '... $attr does have an init_arg');
116 is($attr->init_arg, '-foo', '... $attr->init_arg == -foo');
117 ok($attr->has_default, '... $attr does have an default');
118 is($attr->default, 'BAR', '... $attr->default == BAR');
120 ok($attr->has_reader, '... $attr does have an reader');
121 is($attr->reader, 'get_foo', '... $attr->reader == get_foo');
122 ok($attr->has_writer, '... $attr does have an writer');
123 is($attr->writer, 'set_foo', '... $attr->writer == set_foo');
125 ok(!$attr->has_accessor, '... $attr does not have an accessor');
127 my $attr_clone = $attr->clone();
128 isa_ok($attr_clone, 'Class::MOP::Attribute');
129 isnt($attr, $attr_clone, '... but they are different instances');
131 is_deeply($attr, $attr_clone, '... but they are the same inside');
135 my $attr = Class::MOP::Attribute->new('$foo');
136 isa_ok($attr, 'Class::MOP::Attribute');
138 my $attr_clone = $attr->clone('name' => '$bar');
139 isa_ok($attr_clone, 'Class::MOP::Attribute');
140 isnt($attr, $attr_clone, '... but they are different instances');
142 isnt($attr->name, $attr_clone->name, '... we changes the name parameter');
144 is($attr->name, '$foo', '... $attr->name == $foo');
145 is($attr_clone->name, '$bar', '... $attr_clone->name == $bar');