fix codetest failure - ASSERT_ARGS does not have a ; after and
[parrot.git] / t / codingstd / c_cppcomments.t
blob690ea29e4a792ca0462f51378156f5dbb35d24ce
1 #! perl
2 # Copyright (C) 2001-2010, Parrot Foundation.
3 # $Id$
5 use strict;
6 use warnings;
8 use lib qw( . lib ../lib ../../lib );
9 use Test::More tests => 1;
10 use Parrot::Distribution;
11 use Parrot::Test::Util::Runloop;
13 =head1 NAME
15 t/codingstd/c_cppcomments.t - checks for C++ style comments
17 =head1 SYNOPSIS
19     # test all files
20     % prove t/codingstd/c_cppcomments.t
22     # test specific files
23     % perl t/codingstd/c_cppcoments.t src/foo.t include/parrot/bar.h
25 =head1 DESCRIPTION
27 Checks that no source file in the distribution uses C++ style comments.
29 =head1 SEE ALSO
31 L<docs/pdds/pdd07_codingstd.pod>
33 =cut
35 my @files;
36 if ( @ARGV ) {
37     @files = <@ARGV>;
39 else {
40     my $DIST = Parrot::Distribution->new();
41     @files = $DIST->get_c_language_files();
42     @files = grep { $_->name !~ /.l$/ } @files;
45 Parrot::Test::Util::Runloop->testloop(
46     name        => 'no c++ comments',
47     files       => [@files],
48     per_file    => \&check_cppcomments,
49     diag_prefix => 'C++ comments found'
52 # TT # 414 (https://trac.parrot.org/parrot/ticket/414):
53 # In the POD inside a C source code file, a hyperlink such as
54 # https://trac.parrot.org will be inaccurately reported as a C++-style
55 # comment.
56 # Quick fix added
57 sub check_cppcomments {
58     my $buf = shift;
59     $buf =~ s{ (?:
60                    (?: ' (?: \\\\ | \\' | [^'] )* ' )  # remove ' string
61                  | (?: " (?: \\\\ | \\" | [^"] )* " )  # remove " string
62                  | /\* .*? \*/                         # remove C comment
63                  | https?:\/\/                         # TT # 414 quick fix
64                )
65              }{}gsx;
67     return $buf !~ m{ ( .*? // .* ) }x;
70 # Local Variables:
71 #   mode: cperl
72 #   cperl-indent-level: 4
73 #   fill-column: 100
74 # End:
75 # vim: expandtab shiftwidth=4: