Add test for adding accessors more than once.
Florian Ragwitz [Tue, 3 Feb 2009 18:27:32 +0000 (18:27 +0000)]
t/double_apply.t [new file with mode: 0644]

diff --git a/t/double_apply.t b/t/double_apply.t
new file mode 100644 (file)
index 0000000..ae520f5
--- /dev/null
@@ -0,0 +1,31 @@
+#!perl
+use strict;
+use warnings;
+use Test::More tests => 5;
+use Test::Exception;
+
+# 1
+use_ok('MooseX::Adopt::Class::Accessor::Fast');
+{
+  package My::Package;
+  use base qw/Class::Accessor::Fast/;
+  for (0..1) {
+    __PACKAGE__->mk_accessors(qw( foo ));
+    __PACKAGE__->mk_ro_accessors(qw( bar ));
+    __PACKAGE__->mk_wo_accessors(qw( baz ));
+  }
+}
+
+my $i = bless { bar => 'bar' }, 'My::Package';
+
+# 2
+lives_ok {
+  $i->foo('foo');
+  $i->baz('baz');
+
+  # 3-5
+  is($i->foo, 'foo');
+  is($i->bar, 'bar');
+  is($i->{baz}, 'baz');
+} 'No exception';
+