From: Michael G. Schwern Date: Fri, 14 Dec 2001 19:36:12 +0000 (-0500) Subject: B::Asmdata test X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9dfdc05faed89bb4c359b3472c6541a069ad50a6;p=p5sagit%2Fp5-mst-13.2.git B::Asmdata test Message-ID: <20011215003611.GA28596@blackrider> p4raw-id: //depot/perl@13696 --- diff --git a/MANIFEST b/MANIFEST index 50dc7e8..176c8eb 100644 --- a/MANIFEST +++ b/MANIFEST @@ -91,6 +91,7 @@ ext/B/ramblings/magic Compiler ramblings: notes on magic ext/B/ramblings/reg.alloc Compiler ramblings: register allocation ext/B/ramblings/runtime.porting Compiler ramblings: porting PP enging ext/B/README Compiler backend README +ext/B/t/asmdata.t See if B::Asmdata works ext/B/t/b.t See if B works ext/B/t/debug.t See if B::Debug works ext/B/t/deparse.t See if B::Deparse works diff --git a/ext/B/t/asmdata.t b/ext/B/t/asmdata.t new file mode 100644 index 0000000..5730cca --- /dev/null +++ b/ext/B/t/asmdata.t @@ -0,0 +1,44 @@ +#!./perl -Tw + +BEGIN { + chdir 't'; + @INC = '../lib'; +} + +use Test::More tests => 13; + +use_ok('B::Asmdata', qw(%insn_data @insn_name @optype @specialsv_name)); + +# check we got something. +isnt( keys %insn_data, 0, '%insn_data exported and populated' ); +isnt( @insn_name, 0, ' @insn_name' ); +isnt( @optype, 0, ' @optype' ); +isnt( @specialsv_name, 0, ' @specialsv_name' ); + +# pick an op that's not likely to go away in the future +my @data = values %insn_data; +is( (grep { ref eq 'ARRAY' } @data), @data, '%insn_data contains arrays' ); + +# pick one at random to test with. +my $opname = (keys %insn_data)[rand @data]; +my $data = $insn_data{$opname}; +like( $data->[0], qr/^\d+$/, ' op number' ); +is( ref $data->[1], 'CODE', ' PUT code ref' ); +ok( !ref $data->[2], ' GET method' ); + +is( $insn_name[$data->[0]], $opname, '@insn_name maps correctly' ); + + +# I'm going to assume that op types will all be named /OP$/. +# If this changes in the future, change this test. +is( grep(/OP$/, @optype), @optype, '@optype is all /OP$/' ); + + +# comment in bytecode.pl says "Nullsv *must come first so that the +# condition ($$sv == 0) can continue to be used to test (sv == Nullsv)." +is( $specialsv_name[0], 'Nullsv', 'Nullsv come first in @special_sv_name' ); + +# other than that, we can't really say much more about @specialsv_name +# than it has to contain strings (on the off chance &PL_sv_undef gets +# flubbed) +is( grep(!ref, @specialsv_name), @specialsv_name, ' contains all strings' );