6 use Test::More tests => 58;
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 $attr_clone = $attr->clone();
28 isa_ok($attr_clone, 'Class::MOP::Attribute');
29 isnt($attr, $attr_clone, '... but they are different instances');
31 is_deeply($attr, $attr_clone, '... but they are the same inside');
35 my $attr = Class::MOP::Attribute->new('$foo', (
39 isa_ok($attr, 'Class::MOP::Attribute');
41 is($attr->name, '$foo', '... $attr->name == $foo');
43 ok($attr->has_init_arg, '... $attr does have an init_arg');
44 is($attr->init_arg, '-foo', '... $attr->init_arg == -foo');
45 ok($attr->has_default, '... $attr does have an default');
46 is($attr->default, 'BAR', '... $attr->default == BAR');
48 ok(!$attr->has_accessor, '... $attr does not have an accessor');
49 ok(!$attr->has_reader, '... $attr does not have an reader');
50 ok(!$attr->has_writer, '... $attr does not have an writer');
52 my $attr_clone = $attr->clone();
53 isa_ok($attr_clone, 'Class::MOP::Attribute');
54 isnt($attr, $attr_clone, '... but they are different instances');
56 is_deeply($attr, $attr_clone, '... but they are the same inside');
60 my $attr = Class::MOP::Attribute->new('$foo', (
65 isa_ok($attr, 'Class::MOP::Attribute');
67 is($attr->name, '$foo', '... $attr->name == $foo');
69 ok($attr->has_init_arg, '... $attr does have an init_arg');
70 is($attr->init_arg, '-foo', '... $attr->init_arg == -foo');
71 ok($attr->has_default, '... $attr does have an default');
72 is($attr->default, 'BAR', '... $attr->default == BAR');
74 ok($attr->has_accessor, '... $attr does have an accessor');
75 is($attr->accessor, 'foo', '... $attr->accessor == foo');
77 ok(!$attr->has_reader, '... $attr does not have an reader');
78 ok(!$attr->has_writer, '... $attr does not have an writer');
80 my $attr_clone = $attr->clone();
81 isa_ok($attr_clone, 'Class::MOP::Attribute');
82 isnt($attr, $attr_clone, '... but they are different instances');
84 is_deeply($attr, $attr_clone, '... but they are the same inside');
88 my $attr = Class::MOP::Attribute->new('$foo', (
94 isa_ok($attr, 'Class::MOP::Attribute');
96 is($attr->name, '$foo', '... $attr->name == $foo');
98 ok($attr->has_init_arg, '... $attr does have an init_arg');
99 is($attr->init_arg, '-foo', '... $attr->init_arg == -foo');
100 ok($attr->has_default, '... $attr does have an default');
101 is($attr->default, 'BAR', '... $attr->default == BAR');
103 ok($attr->has_reader, '... $attr does have an reader');
104 is($attr->reader, 'get_foo', '... $attr->reader == get_foo');
105 ok($attr->has_writer, '... $attr does have an writer');
106 is($attr->writer, 'set_foo', '... $attr->writer == set_foo');
108 ok(!$attr->has_accessor, '... $attr does not have an accessor');
110 my $attr_clone = $attr->clone();
111 isa_ok($attr_clone, 'Class::MOP::Attribute');
112 isnt($attr, $attr_clone, '... but they are different instances');
114 is_deeply($attr, $attr_clone, '... but they are the same inside');
118 my $attr = Class::MOP::Attribute->new('$foo');
119 isa_ok($attr, 'Class::MOP::Attribute');
121 my $attr_clone = $attr->clone('name' => '$bar');
122 isa_ok($attr_clone, 'Class::MOP::Attribute');
123 isnt($attr, $attr_clone, '... but they are different instances');
125 isnt($attr->name, $attr_clone->name, '... we changes the name parameter');
127 is($attr->name, '$foo', '... $attr->name == $foo');
128 is($attr_clone->name, '$bar', '... $attr_clone->name == $bar');