Skip to content

Commit

Permalink
[codingstd] Making c_operator test specific to commas for the time be…
Browse files Browse the repository at this point in the history
…ing.

git-svn-id: https://svn.parrot.org/parrot/trunk@22875 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
paultcochrane committed Nov 18, 2007
1 parent 7745897 commit 2a43e21
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions t/codingstd/c_operator.t
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@ L<docs/pdds/pdd07_codingstd.pod>

my $DIST = Parrot::Distribution->new;
my @files = @ARGV ? @ARGV : $DIST->get_c_language_files();
my $operators = join '|' => ( ',', ';' );
check_operators(@files);

exit;

sub check_operators {
my @comma_semicolon;
my @comma_space;

foreach my $file (@_) {
my $path = @ARGV ? $file : $file->path();
Expand All @@ -58,19 +57,19 @@ sub check_operators {
my @lines = split( /\n/, $buf );
my $line_number = 1;
for my $line (@lines) {
# after a comma or semicolon there should be one space or a newline
if ( $line =~ m{ ( (?:$operators) (?! \s ) (?= .+) ) }gx ) {
push @comma_semicolon => "$path:$line_number $1\n";
# after a comma there should be one space or a newline
if ( $line =~ m{ ( (?:,) (?! \s ) (?= .+) ) }gx ) {
push @comma_space => "$path:$line_number $1\n";
}
$line_number++;
}
}

## L<PDD07/Code Formatting/"there should be one space or a newline after a comma or semicolon">
ok( !@comma_semicolon, 'Spacing after commas and semicolons' )
or diag( "incorrect spacing following a comma or semicolon found in "
. @comma_semicolon
. " instances:\n@comma_semicolon" );
## L<PDD07/Code Formatting/"there should be one space or a newline after a comma">
ok( !@comma_space, 'Spacing after commas' )
or diag( "incorrect spacing following a comma found in "
. @comma_space
. " instances:\n@comma_space" );
}

# Local Variables:
Expand Down

0 comments on commit 2a43e21

Please sign in to comment.