[codingstd] Tweak c_arg_assert.t to make sure ASSERT_ARGS() is at the
From: Mark Glines <mark@glines.org>
*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
|
b
|
|
6 | 6 | use warnings; |
7 | 7 | |
8 | 8 | use lib qw( . lib ../lib ../../lib ); |
9 | | use Test::More tests => 1; |
| 9 | use Test::More tests => 2; |
10 | 10 | use Parrot::Distribution; |
11 | 11 | |
12 | 12 | =head1 NAME |
… |
… |
|
37 | 37 | my @files = @_; |
38 | 38 | my @defines; |
39 | 39 | my %usages; |
| 40 | my @offsets; |
40 | 41 | |
41 | 42 | # first, find the definitions and the usages |
42 | 43 | diag("finding definitions"); |
… |
… |
|
48 | 49 | push(@defines, $1); |
49 | 50 | } |
50 | 51 | if($line =~ /^\s+ASSERT_ARGS\(([_a-zA-Z0-9]+)\);/) { |
51 | | $usages{$1} = 1; |
| 52 | my $func = $1; |
| 53 | $usages{$func} = 1; |
| 54 | my $fulltext = join('',@lines); |
| 55 | if($fulltext !~ /\{\s*ASSERT_ARGS\($func\);/s) { |
| 56 | push(@offsets, $func); |
| 57 | } |
52 | 58 | } |
53 | 59 | } |
54 | 60 | } |
… |
… |
|
63 | 69 | } |
64 | 70 | diag(scalar(@missing) . " unused assert macros found in total."); |
65 | 71 | } |
| 72 | ok(!scalar @offsets); |
| 73 | if(scalar @offsets) { |
| 74 | diag("The following macros exist but aren't at the top of the function:"); |
| 75 | foreach my $offset (sort @offsets) { |
| 76 | diag($offset); |
| 77 | } |
| 78 | diag(scalar(@offsets) . " offset macros found in total."); |
| 79 | } |
66 | 80 | } |
67 | 81 | |
68 | 82 | # Local Variables: |