Remaining nit in the deparsing of reversed foreach loops
[p5sagit/p5-mst-13.2.git] / ext / B / t / asmdata.t
1 #!./perl -Tw
2
3 BEGIN {
4     chdir 't';
5     @INC = '../lib';
6     require Config;
7     if (($Config::Config{'extensions'} !~ /\bB\b/) ){
8         print "1..0 # Skip -- Perl configured without B module\n";
9         exit 0;
10     }
11 }
12
13 use Test::More tests => 13;
14
15 use_ok('B::Asmdata', qw(%insn_data @insn_name @optype @specialsv_name));
16
17 # check we got something.
18 isnt( keys %insn_data,  0,  '%insn_data exported and populated' );
19 isnt( @insn_name,       0,  '   @insn_name' );
20 isnt( @optype,          0,  '   @optype' );
21 isnt( @specialsv_name,  0,  '   @specialsv_name' );
22
23 # pick an op that's not likely to go away in the future
24 my @data = values %insn_data;
25 is( (grep { ref eq 'ARRAY' } @data),  @data,   '%insn_data contains arrays' );
26
27 # pick one at random to test with.
28 my $opname = (keys %insn_data)[rand @data];
29 my $data = $insn_data{$opname};
30 like( $data->[0], qr/^\d+$/,    '   op number' );
31 is( ref $data->[1],  'CODE',    '   PUT code ref' );
32 ok( !ref $data->[2],            '   GET method' );
33
34 is( $insn_name[$data->[0]], $opname,    '@insn_name maps correctly' );
35
36
37 # I'm going to assume that op types will all be named /OP$/.
38 # If this changes in the future, change this test.
39 is( grep(/OP$/, @optype), @optype,  '@optype is all /OP$/' );
40
41
42 # comment in bytecode.pl says "Nullsv *must come first so that the 
43 # condition ($$sv == 0) can continue to be used to test (sv == Nullsv)."
44 is( $specialsv_name[0],  'Nullsv',  'Nullsv come first in @special_sv_name' );
45
46 # other than that, we can't really say much more about @specialsv_name
47 # than it has to contain strings (on the off chance &PL_sv_undef gets 
48 # flubbed)
49 is( grep(!ref, @specialsv_name), @specialsv_name,   '  contains all strings' );