2 # Copyright (C) 2006-2009, Parrot Foundation.
8 use lib qw( . lib ../lib ../../lib );
9 use Test::More tests => 1;
10 use Parrot::Distribution;
14 t/codingstd/c_returns.t - checks for possible use of C<return (foo);> from functions
19 % prove t/codingstd/c_returns.t
22 % perl t/codingstd/c_returns.t src/foo.c include/parrot/bar.h
26 Checks that all C language source files return using C<return foo;> rather
31 This test was hacked from the C<check_returns> sub in
32 C<tools/dev/check_source_standards.pl>, which is no longer part of the Parrot
37 L<docs/pdds/pdd07_codingstd.pod>
41 my $DIST = Parrot::Distribution->new;
42 my @files = @ARGV ? <@ARGV> : $DIST->get_c_language_files();
45 foreach my $file (@files) {
48 ## get the full path of the file
49 # if we have command line arguments, the file is the full path
54 # otherwise, use the relevant Parrot:: path method
59 my $buf = $DIST->slurp($path);
61 # look for instances of return(
62 push @paren_return => "$path\n"
63 if ( $buf =~ m/[^_.]return\(/ );
66 ok( !scalar(@paren_return), 'Correctly formed return statement' )
67 or diag( "Possible use of C<return(foo);> rather than C<return foo;> in "
68 . scalar @paren_return
69 . " files:\n@paren_return" );
73 # cperl-indent-level: 4
76 # vim: expandtab shiftwidth=4: