Merge remote branch 'kc/new/bug_5386' into kcmaster
authorChris Cormack <chrisc@catalyst.net.nz>
Thu, 11 Nov 2010 17:41:25 +0000 (06:41 +1300)
committerChris Cormack <chrisc@catalyst.net.nz>
Thu, 11 Nov 2010 17:41:25 +0000 (06:41 +1300)
t/00-deprecated.t [new file with mode: 0755]

diff --git a/t/00-deprecated.t b/t/00-deprecated.t
new file mode 100755 (executable)
index 0000000..6eba09d
--- /dev/null
@@ -0,0 +1,27 @@
+#!/usr/bin/perl
+#
+# Tests usage of deprecated Perl syntax. Deprecated could be extended to the
+# sense of 'not allowed'.
+#
+use warnings;
+use strict;
+use Test::More tests => 1;
+use File::Find;
+use Cwd;
+
+my @files_with_switch = do {
+    my @files;
+    local $/ = undef;
+    find( sub {
+        my $dir = getcwd();
+        return if $dir =~ /blib/;
+        return unless /\.(pl|pm)$/; # Don't inspect non-Perl files
+        open my $fh, "<", $_;
+        my $content = <$fh>;
+        push @files, "$dir/$_"  if $content =~ /switch\s*\(.*{/;
+      }, ( '.' ) );
+    @files;
+};
+ok( !@files_with_switch, "Perl syntax: no use of switch statement" )
+    or diag( "Files list: " . join(', ', @files_with_switch) );
+