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/c_struct.t - checks for struct tags in C source and headers
18 % prove t/codingstd/c_struct.t
21 % perl t/codingstd/c_struct.t src/foo.c include/parrot/bar.h
25 Checks that all C source files use struct tags, as defined in PDD07.
29 L<docs/pdds/pdd07_codingstd.pod>
33 my $DIST = Parrot::Distribution->new;
34 my @files = @ARGV ? <@ARGV> : $DIST->get_c_language_files();
37 for my $file (@files) {
38 my $path = ref $file ? $file->path : $file;
40 open my $fh, '<', $path
41 or die "Cannot open '$path' for reading: $!\n";
44 my $message = qq< $path:>;
47 # we're only interested in lines with structs
48 next unless /\btypedef\s+struct\s+{/;
53 push @struct => "$message\n"
58 # L<PDD07/Code Structure/=item Structure types must have tags>
59 ok( !scalar(@struct), "structure types must have tags" )
60 or diag( "struct without tag found in " . scalar @struct . " files:\n@struct" );
64 # cperl-indent-level: 4
67 # vim: expandtab shiftwidth=4: