This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make Config.t warnings and strictures clean
[perl5.git] / ext / B / t / asmdata.t
CommitLineData
9dfdc05f
MS
1#!./perl -Tw
2
3BEGIN {
4 chdir 't';
5 @INC = '../lib';
9cd8f857
NC
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 }
9dfdc05f
MS
11}
12
13use Test::More tests => 13;
14
15use_ok('B::Asmdata', qw(%insn_data @insn_name @optype @specialsv_name));
16
17# check we got something.
18isnt( keys %insn_data, 0, '%insn_data exported and populated' );
19isnt( @insn_name, 0, ' @insn_name' );
20isnt( @optype, 0, ' @optype' );
21isnt( @specialsv_name, 0, ' @specialsv_name' );
22
23# pick an op that's not likely to go away in the future
24my @data = values %insn_data;
25is( (grep { ref eq 'ARRAY' } @data), @data, '%insn_data contains arrays' );
26
27# pick one at random to test with.
28my $opname = (keys %insn_data)[rand @data];
29my $data = $insn_data{$opname};
30like( $data->[0], qr/^\d+$/, ' op number' );
31is( ref $data->[1], 'CODE', ' PUT code ref' );
32ok( !ref $data->[2], ' GET method' );
33
34is( $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.
39is( 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)."
44is( $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)
49is( grep(!ref, @specialsv_name), @specialsv_name, ' contains all strings' );