2 # Copyright (C) 2006-2009, Parrot Foundation.
7 use lib qw( . lib ../lib ../../lib );
8 use Test::More tests => 1;
9 use Parrot::Distribution;
13 t/codingstd/tabs.t - checks for tab indents in C source and headers
18 % prove t/codingstd/tabs.t
21 % perl t/codingstd/tabs.t src/foo.c include/parrot/bar.h
25 Checks that files do not use tabs to indent.
29 L<docs/pdds/pdd07_codingstd.pod>
33 my $DIST = Parrot::Distribution->new;
34 my @files = @ARGV ? <@ARGV> : $DIST->get_c_language_files();
37 foreach my $file (@files) {
39 # if we have command line arguments, the file is the full path
40 # otherwise, use the relevant Parrot:: path method
41 my $path = @ARGV ? $file : $file->path;
43 open my $fh, '<', $path
44 or die "Cannot open '$path' for reading: $!\n";
48 # search each line for leading tabs
50 if ( $_ =~ m/^ *\t/ ) {
51 push @tabs => "$path:$line\n";
59 ## L<PDD07/Code Formatting/"Indentation must consist only of spaces">
60 ok( !scalar(@tabs), "tabs in leading whitespace" )
62 diag( "Found tab in leading whitespace " . scalar(@tabs) . " instances. Lines found:\n@tabs" );
66 # cperl-indent-level: 4
69 # vim: expandtab shiftwidth=4: