Permalink
Browse files

added tests about excluding files and metric threshold

  • Loading branch information...
1 parent bffa053 commit e51330aa72a24bbd61f178643456ca43f692a5c8 @dann committed Jan 7, 2012
Showing with 254 additions and 4 deletions.
  1. +3 −3 lib/Test/Perl/Metrics/Lite.pm
  2. +1 −1 t/01_bacit.t
  3. +11 −0 t/02_except.t
  4. +11 −0 t/03_threshold.t
  5. +217 −0 t/lib/Bad/BadClass.pm
  6. +11 −0 t/lib/Good/GoodClass.pm
@@ -1,6 +1,6 @@
package Test::Perl::Metrics::Lite;
use strict;
-our $VERSION = '0.1';
+our $VERSION = '0.2';
use List::MoreUtils qw(any);
use Perl::Metrics::Lite;
@@ -49,10 +49,10 @@ sub _starting_points {
}
sub all_metrics_ok {
- my %param = @_;
+ my @dirs = @_;
+
Test::More::plan('no_plan');
- my @dirs = @_;
if ( not @dirs ) {
@dirs = _starting_points();
}
View
@@ -2,7 +2,7 @@ use strict;
use warnings;
use FindBin;
use File::Spec;
-use lib File::Spec->catdir($FindBin::Bin, 'lib');
+use lib File::Spec->catdir($FindBin::Bin, 't', 'lib');
use Test::Perl::Metrics::Lite;
View
@@ -0,0 +1,11 @@
+use strict;
+use warnings;
+use FindBin;
+use File::Spec;
+use lib File::Spec->catdir( $FindBin::Bin, 'lib' );
+
+use Test::Perl::Metrics::Lite ( -except_file => ['t/lib/Bad/BadClass.pm'] );
+
+BEGIN {
+ all_metrics_ok( ('t/lib') );
+}
View
@@ -0,0 +1,11 @@
+use strict;
+use warnings;
+use FindBin;
+use File::Spec;
+use lib File::Spec->catdir( $FindBin::Bin, 'lib' );
+
+use Test::Perl::Metrics::Lite (-mccabe_complexity => 300, -loc => 300);
+
+BEGIN {
+ all_metrics_ok( ('t/lib') );
+}
View
@@ -0,0 +1,217 @@
+package Bad::BadClass;
+
+sub long_method {
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+ print;
+}
+
+sub complex_method {
+ my $case = "dog";
+ if ( $case eq "1" ) {
+ }
+ elsif ( $case eq "2" ) {
+ print "hello";
+ }
+ elsif ( $case eq "2" ) {
+ print "hello";
+ }
+ elsif ( $case eq "2" ) {
+ print "hello";
+ }
+ elsif ( $case eq "2" ) {
+ print "hello";
+ }
+ elsif ( $case eq "2" ) {
+ print "hello";
+ }
+ elsif ( $case eq "2" ) {
+ print "hello";
+
+ }
+ elsif ( $case eq "2" ) {
+ print "hello";
+
+ }
+ elsif ( $case eq "2" ) {
+ print "hello";
+
+ }
+ elsif ( $case eq "2" ) {
+ print "hello";
+
+ }
+ elsif ( $case eq "2" ) {
+ print "hello";
+
+ }
+ elsif ( $case eq "2" ) {
+ print "hello";
+
+ }
+ elsif ( $case eq "2" ) {
+ print "hello";
+
+ }
+ elsif ( $case eq "2" ) {
+ print "hello";
+
+ }
+ elsif ( $case eq "2" ) {
+ print "hello";
+
+ }
+ elsif ( $case eq "2" ) {
+ print "hello";
+
+ }
+ elsif ( $case eq "2" ) {
+ print "hello";
+
+ }
+ elsif ( $case eq "2" ) {
+ print "hello";
+
+ }
+ elsif ( $case eq "2" ) {
+ print "hello";
+
+ }
+ elsif ( $case eq "2" ) {
+ print "hello";
+
+ }
+ elsif ( $case eq "2" ) {
+ print "hello";
+
+ }
+ elsif ( $case eq "2" ) {
+ print "hello";
+
+ }
+ elsif ( $case eq "2" ) {
+ print "hello";
+
+ }
+ elsif ( $case eq "2" ) {
+ print "hello";
+
+ }
+ elsif ( $case eq "2" ) {
+ print "hello";
+
+ }
+ elsif ( $case eq "2" ) {
+ print "hello";
+
+ }
+
+}
+
+1;
View
@@ -0,0 +1,11 @@
+package Good::GoodClass;
+
+sub short_method {
+ return 1;
+}
+
+sub simple_method {
+ return 1;
+}
+
+1;

0 comments on commit e51330a

Please sign in to comment.