1N/A#!./perl -Tw
1N/A
1N/ABEGIN {
1N/A chdir 't';
1N/A @INC = '../lib';
1N/A}
1N/A
1N/Ause Test::More tests => 13;
1N/A
1N/Ause_ok('B::Asmdata', qw(%insn_data @insn_name @optype @specialsv_name));
1N/A
1N/A# check we got something.
1N/Aisnt( keys %insn_data, 0, '%insn_data exported and populated' );
1N/Aisnt( @insn_name, 0, ' @insn_name' );
1N/Aisnt( @optype, 0, ' @optype' );
1N/Aisnt( @specialsv_name, 0, ' @specialsv_name' );
1N/A
1N/A# pick an op that's not likely to go away in the future
1N/Amy @data = values %insn_data;
1N/Ais( (grep { ref eq 'ARRAY' } @data), @data, '%insn_data contains arrays' );
1N/A
1N/A# pick one at random to test with.
1N/Amy $opname = (keys %insn_data)[rand @data];
1N/Amy $data = $insn_data{$opname};
1N/Alike( $data->[0], qr/^\d+$/, ' op number' );
1N/Ais( ref $data->[1], 'CODE', ' PUT code ref' );
1N/Aok( !ref $data->[2], ' GET method' );
1N/A
1N/Ais( $insn_name[$data->[0]], $opname, '@insn_name maps correctly' );
1N/A
1N/A
1N/A# I'm going to assume that op types will all be named /OP$/.
1N/A# If this changes in the future, change this test.
1N/Ais( grep(/OP$/, @optype), @optype, '@optype is all /OP$/' );
1N/A
1N/A
1N/A# comment in bytecode.pl says "Nullsv *must come first so that the
1N/A# condition ($$sv == 0) can continue to be used to test (sv == Nullsv)."
1N/Ais( $specialsv_name[0], 'Nullsv', 'Nullsv come first in @special_sv_name' );
1N/A
1N/A# other than that, we can't really say much more about @specialsv_name
1N/A# than it has to contain strings (on the off chance &PL_sv_undef gets
1N/A# flubbed)
1N/Ais( grep(!ref, @specialsv_name), @specialsv_name, ' contains all strings' );