Permalink
Browse files

negate the filter tests, so that returning false from a filter will r…

…emove

the test.
  • Loading branch information...
1 parent 602eccb commit 533e31ec35f9222fb7dc1ac2061fb30430909a32 @makk384 makk384 committed Apr 27, 2010
Showing with 9 additions and 9 deletions.
  1. +4 −4 lib/Test/Class.pm
  2. +1 −1 t/filter.t
  3. +1 −1 t/filter_fixtures.t
  4. +1 −1 t/filter_fixtures_only.t
  5. +2 −2 t/filter_multiple.t
View
8 lib/Test/Class.pm
@@ -150,9 +150,9 @@ sub _get_methods {
if ( $info->type eq TEST ) {
# determine if method is filtered, true if *any* filter
- # returns true.
+ # returns false.
foreach my $filter ( @Filters ) {
- next FILTER if $filter->( $class, $name );
+ next FILTER unless $filter->( $class, $name );
}
}
@@ -1074,7 +1074,7 @@ be used by specifying coderefs to the 'add_filter' method of this class.
In determining which tests should be run, all filters that have previously
been specified via the add_filter method will be run in-turn for each normal
-test method. If B<any> of these filters return a true value, the method will
+test method. If B<any> of these filters return a false value, the method will
not be executed, or included in the number of tests. Note that filters will
only be run for normal test methods, they are ignored for startup, shutdown,
setup, and teardown test methods.
@@ -1096,7 +1096,7 @@ above is:
my $filter = sub {
my ( $test_class, $test_method ) = @_;
- return 1 if $test_method !~ $MYTEST_METHOD;
+ return $test_method =~ $MYTEST_METHOD;
};
Test::Class->add_filter( $filter );
View
2 t/filter.t
@@ -21,6 +21,6 @@ sub test_filter_due_to_class : Test(1) {
package main;
-Test::Class->add_filter( sub { $_[0] eq 'Bar' } );
+Test::Class->add_filter( sub { $_[0] eq 'Foo' } );
Test::Class->runtests;
View
2 t/filter_fixtures.t
@@ -34,6 +34,6 @@ sub test_should_run : Test( 1 ) {
package main;
-Test::Class->add_filter( sub { $_[1] =~ /filtered/ } );
+Test::Class->add_filter( sub { $_[1] !~ /filtered/ } );
Test::Class->runtests;
View
2 t/filter_fixtures_only.t
@@ -30,6 +30,6 @@ sub test_filtered : Test( 1 ) {
package main;
-Test::Class->add_filter( sub { 1 } );
+Test::Class->add_filter( sub { 0 } );
Test::Class->runtests;
View
4 t/filter_multiple.t
@@ -29,7 +29,7 @@ sub test_another_not_matching : Test(1) {
package main;
-Test::Class->add_filter( sub { $_[1] =~ /filter_me/ } );
-Test::Class->add_filter( sub { $_[1] =~ /me_too/ } );
+Test::Class->add_filter( sub { $_[1] !~ /filter_me/ } );
+Test::Class->add_filter( sub { $_[1] !~ /me_too/ } );
Test::Class->runtests;

0 comments on commit 533e31e

Please sign in to comment.