xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/ext/B/t/asmdata.t (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!./perl -Tw
2*0Sstevel@tonic-gate
3*0Sstevel@tonic-gateBEGIN {
4*0Sstevel@tonic-gate    chdir 't';
5*0Sstevel@tonic-gate    @INC = '../lib';
6*0Sstevel@tonic-gate}
7*0Sstevel@tonic-gate
8*0Sstevel@tonic-gateuse Test::More tests => 13;
9*0Sstevel@tonic-gate
10*0Sstevel@tonic-gateuse_ok('B::Asmdata', qw(%insn_data @insn_name @optype @specialsv_name));
11*0Sstevel@tonic-gate
12*0Sstevel@tonic-gate# check we got something.
13*0Sstevel@tonic-gateisnt( keys %insn_data,  0,  '%insn_data exported and populated' );
14*0Sstevel@tonic-gateisnt( @insn_name,       0,  '   @insn_name' );
15*0Sstevel@tonic-gateisnt( @optype,          0,  '   @optype' );
16*0Sstevel@tonic-gateisnt( @specialsv_name,  0,  '   @specialsv_name' );
17*0Sstevel@tonic-gate
18*0Sstevel@tonic-gate# pick an op that's not likely to go away in the future
19*0Sstevel@tonic-gatemy @data = values %insn_data;
20*0Sstevel@tonic-gateis( (grep { ref eq 'ARRAY' } @data),  @data,   '%insn_data contains arrays' );
21*0Sstevel@tonic-gate
22*0Sstevel@tonic-gate# pick one at random to test with.
23*0Sstevel@tonic-gatemy $opname = (keys %insn_data)[rand @data];
24*0Sstevel@tonic-gatemy $data = $insn_data{$opname};
25*0Sstevel@tonic-gatelike( $data->[0], qr/^\d+$/,    '   op number' );
26*0Sstevel@tonic-gateis( ref $data->[1],  'CODE',    '   PUT code ref' );
27*0Sstevel@tonic-gateok( !ref $data->[2],            '   GET method' );
28*0Sstevel@tonic-gate
29*0Sstevel@tonic-gateis( $insn_name[$data->[0]], $opname,    '@insn_name maps correctly' );
30*0Sstevel@tonic-gate
31*0Sstevel@tonic-gate
32*0Sstevel@tonic-gate# I'm going to assume that op types will all be named /OP$/.
33*0Sstevel@tonic-gate# If this changes in the future, change this test.
34*0Sstevel@tonic-gateis( grep(/OP$/, @optype), @optype,  '@optype is all /OP$/' );
35*0Sstevel@tonic-gate
36*0Sstevel@tonic-gate
37*0Sstevel@tonic-gate# comment in bytecode.pl says "Nullsv *must come first so that the
38*0Sstevel@tonic-gate# condition ($$sv == 0) can continue to be used to test (sv == Nullsv)."
39*0Sstevel@tonic-gateis( $specialsv_name[0],  'Nullsv',  'Nullsv come first in @special_sv_name' );
40*0Sstevel@tonic-gate
41*0Sstevel@tonic-gate# other than that, we can't really say much more about @specialsv_name
42*0Sstevel@tonic-gate# than it has to contain strings (on the off chance &PL_sv_undef gets
43*0Sstevel@tonic-gate# flubbed)
44*0Sstevel@tonic-gateis( grep(!ref, @specialsv_name), @specialsv_name,   '  contains all strings' );
45