2 # Copyright (C) 2009, Parrot Foundation
7 t/tools/pbc_disassemble.t - test the Parrot Bytecode (PBC) Disassembler
11 % prove t/tools/pbc_disassemble.t
15 Tests the C<pbc_disassemble> tool by providing it with a number of source
16 files, and running through it with various commands.
18 We never actually check the I<full> output of pbc_disassemble. We simply check
19 several smaller components to avoid a test file that is far too unwieldy.
24 This test script requires you to build pbc_disassemble, by typing
25 "make parrot_utils" (using a suitable make tool for your platform).
26 If this requirement has not been met, all tests will be skipped.
43 $path = File::Spec->catfile( ".", "pbc_disassemble" );
44 my $exefile = $path . $PConfig{exe};
45 unless ( -f $exefile ) {
46 plan skip_all => "pbc_disassemble hasn't been built. Run make parrot_utils";
52 disassemble_output_like( <<PIR, "pir", qr/PMC_CONST.*set_n_nc.*print_n/ms, 'pbc_disassemble numeric ops');
60 disassemble_output_like( <<PIR, "pir", qr/PMC_CONST.*set_i_ic.*print_i/ms, 'pbc_disassemble integer ops');
68 disassemble_output_like( <<PIR, "pir", qr/PMC_CONST.*new_p_sc.*"ResizablePMCArray".*set_p_kic_ic\s*P.*set_i_p_kic\s*I.*/ms, 'pbc_disassemble pmc ops');
70 \$P0 = new 'ResizablePMCArray'
76 disassemble_output_like( <<PIR, "pir", qr/PMC_CONST.*set_s_sc\s*S.*print_s\s*S.*print_sc/ms, 'pbc_disassemble string ops');
78 \$S0 = "Wheels within wheels"
84 =head1 HELPER SUBROUTINES
86 =head2 disassemble_output_like
88 disassemble_output_like(<<PASM, "pasm", "some output", "running $file");
90 Takes 3-4 arguments: a file to run,
91 the filename-extension of the file (probably "pir" or "pasm"),
92 an arrayref or single regex string to match within pbc_disassemble's output,
93 and the optional test diagnostic.
97 sub disassemble_output_like {
98 pbc_postprocess_output_like($path, @_ );
103 # cperl-indent-level: 4
106 # vim: expandtab shiftwidth=4: