[codingstd] Tweak c_arg_assert.t to make sure ASSERT_ARGS() is at the From: Mark Glines *top* of the function. --- t/codingstd/c_arg_assert.t | 18 ++++++++++++++++-- 1 files changed, 16 insertions(+), 2 deletions(-) diff --git a/t/codingstd/c_arg_assert.t b/t/codingstd/c_arg_assert.t index 6a3cda6..49b839c 100644 --- a/t/codingstd/c_arg_assert.t +++ b/t/codingstd/c_arg_assert.t @@ -6,7 +6,7 @@ use strict; use warnings; use lib qw( . lib ../lib ../../lib ); -use Test::More tests => 1; +use Test::More tests => 2; use Parrot::Distribution; =head1 NAME @@ -37,6 +37,7 @@ sub check_asserts { my @files = @_; my @defines; my %usages; + my @offsets; # first, find the definitions and the usages diag("finding definitions"); @@ -48,7 +49,12 @@ sub check_asserts { push(@defines, $1); } if($line =~ /^\s+ASSERT_ARGS\(([_a-zA-Z0-9]+)\);/) { - $usages{$1} = 1; + my $func = $1; + $usages{$func} = 1; + my $fulltext = join('',@lines); + if($fulltext !~ /\{\s*ASSERT_ARGS\($func\);/s) { + push(@offsets, $func); + } } } } @@ -63,6 +69,14 @@ sub check_asserts { } diag(scalar(@missing) . " unused assert macros found in total."); } + ok(!scalar @offsets); + if(scalar @offsets) { + diag("The following macros exist but aren't at the top of the function:"); + foreach my $offset (sort @offsets) { + diag($offset); + } + diag(scalar(@offsets) . " offset macros found in total."); + } } # Local Variables: