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