2 # Copyright (C) 2001-2010, Parrot Foundation.
7 use lib qw( . lib ../lib ../../lib );
8 use Test::More tests => 1;
12 t/perl/opcode_doc.t - check opcode documentation
16 % prove t/perl/opcode_doc.t
20 Checks whether all opcodes are documented.
29 open my $FILE, '<', "$filename" or die "can't open '$filename' for reading";
36 my ( $filename, $ops ) = @_;
40 foreach my $op ( keys %$ops ) {
41 my $args = $ops->{$op};
42 next if $op =~ /^DELETED/;
43 next if $op =~ /^isgt/; # doced but rewritten
44 next if $op =~ /^isge/;
45 foreach my $arg ( keys %$args ) {
46 my $e = $args->{$arg};
47 my $val = $e->{status};
48 next if $val == 3; # doc & impl
49 $file{ $e->{def} } = "no documentation for $op($arg)" if exists $e->{def};
50 $file{ $e->{doc} } = "no definition of $op($arg)" if exists $e->{doc};
54 foreach my $line ( sort { $a <=> $b } keys %file ) {
55 push @docerr, "$filename:$line: $file{$line}\n";
62 my @file = slurp($filename);
66 foreach my $line (@file) {
68 if ( my ($item) = $line =~ /^=item\s+(.+\(.*)/ ) {
69 if ( $item =~ /^([BC])\<(.*)\>\s*\((.*?)\)/ ) {
70 print "$filename:$lineno: use B<...> instead of C<...>\n"
72 my ( $op, $args ) = ( $2, $3 );
73 $args =~ s!\s*/\*.*?\*/!!; # del C comment in args
74 $op{$op}{$args}{doc} = $lineno;
75 $op{$op}{$args}{status} |= 1;
78 elsif ( $line =~ /^(inline )?\s*op\s*(\S+)\s*\((.*?)\)/ ) {
79 $op{$2}{$3}{def} = $lineno;
80 $op{$2}{$3}{status} |= 2;
83 analyse( $filename, \%op );
86 foreach my $file (<src/ops/*.ops>) {
90 ok( !@docerr, 'opcode documentation' ) or diag("Opcode documentation errors:\n@docerr");
94 # cperl-indent-level: 4
97 # vim: expandtab shiftwidth=4: