Permalink
Browse files

added tests

  • Loading branch information...
1 parent 59c8c0f commit 5aef8ba8fe6c58b570ff76ee8f5f7ade8062ebc1 @kabe kabe committed Apr 13, 2012
Showing with 55 additions and 0 deletions.
  1. +23 −0 e3/t/bird.t
  2. +32 −0 e3/t/forest.t
View
@@ -0,0 +1,23 @@
+package test::Bird;
+use strict;
+use warnings;
+use base qw(Test::Class);
+use Test::More;
+use Bird;
+use Forest;
+
+sub init : Test(1) {
+ new_ok 'Bird';
+}
+
+sub attr : Tests {
+ my $forest = Forest->new;
+ my $bird = Bird->new(name => "hoge", forest => $forest);
+ is $bird->name, "hoge";
+ is $bird->{forest}, $forest;
+}
+
+__PACKAGE__->runtests;
+
+1;
+
View
@@ -0,0 +1,32 @@
+package test::Forest;
+use strict;
+use warnings;
+use base qw(Test::Class);
+use Test::More;
+use Bird;
+use Tweet;
+use Forest;
+
+sub init : Test(1) {
+ new_ok 'Forest';
+}
+
+sub register_birds : Tests {
+ my $f = Forest->new;
+ my $b1 = Bird->new(name => "b1", forest => $f);
+ my $b2 = Bird->new(name => "b2", forest => $f);
+ my $b3 = Bird->new(name => "b3", forest => $f);
+ is scalar @{$f->{birds}}, 3;
+ is_deeply [map { $_->name } @{$f->{birds}}], [qw/b1 b2 b3/];
+}
+
+sub duplicated_register_birds : Tests {
+ my $f = Forest->new;
+ my $b1 = Bird->new(name => "b1", forest => $f);
+ my $b2 = eval { Bird->new(name => "b1", forest => $f) };
+ is (X::BirdExists->caught(), 'Bird name b1 already registered.');
+}
+
+__PACKAGE__->runtests;
+
+1;

0 comments on commit 5aef8ba

Please sign in to comment.