Permalink
Browse files

Add TB2::Events->event_classes

Some tests want a list of all the event classes, so make it a public method
of TB2::Events.  Don't see the need to make it publicly documented.
  • Loading branch information...
1 parent cf8b087 commit 9ef1086a51acc81acc71933da851c3d0e77560dc @schwern schwern committed Apr 23, 2013
Showing with 22 additions and 22 deletions.
  1. +20 −11 lib/TB2/Events.pm
  2. +2 −11 t/Event/Events.t
View
@@ -6,17 +6,26 @@ use warnings;
our $VERSION = '1.005000_006';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
-
-use TB2::Event::TestStart;
-use TB2::Event::TestEnd;
-use TB2::Event::SubtestStart;
-use TB2::Event::SubtestEnd;
-use TB2::Event::SetPlan;
-use TB2::Event::TestMetadata;
-use TB2::Event::Log;
-use TB2::Event::Comment;
-use TB2::Event::Abort;
-use TB2::Result;
+sub event_classes {
+ return qw(
+ TB2::Event::TestStart
+ TB2::Event::TestEnd
+ TB2::Event::SubtestStart
+ TB2::Event::SubtestEnd
+ TB2::Event::SetPlan
+ TB2::Event::TestMetadata
+ TB2::Event::Log
+ TB2::Event::Comment
+ TB2::Event::Abort
+ TB2::Result
+ );
+}
+
+BEGIN {
+ for my $class (__PACKAGE__->event_classes) {
+ eval "require $class" or die $@;
+ }
+}
=head1 NAME
View
@@ -6,18 +6,9 @@ use warnings;
BEGIN { require "t/test.pl"; }
use TB2::Events;
-my @events = map { "TB2::Event::".$_ }
- qw(TestStart TestEnd
- SetPlan
- TestMetadata
- Log
- Comment
- SubtestStart
- SubtestEnd
- Abort
- );
+my @events = TB2::Events->event_classes;
-for my $class (@events) {
+for my $class (grep !/TB2::Result/, @events) {
ok $class->can("event_type"), "$class loaded";
}

0 comments on commit 9ef1086

Please sign in to comment.