Ticket #2121: tt2121.patch

File tt2121.patch, 12.4 KB (added by soh_cah_toa, 11 years ago)
  • lib/Parrot/Test.pm

    diff --git a/lib/Parrot/Test.pm b/lib/Parrot/Test.pm
    index 8206264..9067096 100644
    a b  
    2323 
    2424This module provides various Parrot-specific test functions. 
    2525 
    26 =head2 Functions 
     26=head2 Function Parameters 
     27 
     28=over 4 
     29 
     30=item C<$language> 
     31 
     32The language of the code being tested. 
     33 
     34=item C<$code> 
    2735 
    28 The parameter C<$language> is the language of the code. 
    29 The parameter C<$code> is the code that should be executed or transformed. 
    30 The parameter C<$expected> is the expected result. 
    31 The parameter C<$unexpected> is the unexpected result. 
    32 The parameter C<$description> should describe the test. 
     36The code that should be executed or transformed. 
    3337 
    34 Any optional parameters can follow.  For example, to mark a test as a TODO test 
    35 (where you know the implementation does not yet work), pass: 
     38=item C<$expected> 
     39 
     40The expected result. 
     41 
     42=item C<$unexpected> 
     43 
     44The unexpected result. 
     45 
     46=item C<$description> 
     47 
     48A short description of the test. 
     49 
     50=back 
     51 
     52Any optional parameters can follow. For example, to mark a test as a TODO test 
     53(where you know the implementation does not work yet), pass: 
    3654 
    3755    todo => 'reason to consider this TODO' 
    3856 
    39 at the end of the argument list.  Valid reasons include C<bug>, 
     57at the end of the argument list. Valid reasons include C<bug>, 
    4058C<unimplemented>, and so on. 
    4159 
    4260B<Note:> you I<must> use a C<$description> with TODO tests. 
    4361 
     62=head2 Functions 
     63 
    4464=over 4 
    4565 
    46 =item C<language_output_is( $language, $code, $expected, $description)> 
     66=item C<language_output_is($language, $code, $expected, $description)> 
    4767 
    48 =item C<language_error_output_is( $language, $code, $expected, $description)> 
     68=item C<language_error_output_is($language, $code, $expected, $description)> 
    4969 
    5070Runs a language test and passes the test if a string comparison 
    51 of the output with the expected result it true. 
    52 For C<language_error_output_is()> the exit code also has to be non-zero. 
     71of the output with the expected result is true. For 
     72C<language_error_output_is()>, the exit code also has to be non-zero. 
    5373 
    54 =item C<language_output_like( $language, $code, $expected, $description)> 
     74=item C<language_output_like($language, $code, $expected, $description)> 
    5575 
    56 =item C<language_error_output_like( $language, $code, $expected, $description)> 
     76=item C<language_error_output_like($language, $code, $expected, $description)> 
    5777 
    5878Runs a language test and passes the test if the output matches the expected 
    59 result. 
    60 For C<language_error_output_like()> the exit code also has to be non-zero. 
     79result. For C<language_error_output_like()>, the exit code also has to be 
     80non-zero. 
    6181 
    62 =item C<language_output_isnt( $language, $code, $expected, $description)> 
     82=item C<language_output_isnt($language, $code, $expected, $description)> 
    6383 
    64 =item C<language_error_output_isnt( $language, $code, $expected, $description)> 
     84=item C<language_error_output_isnt($language, $code, $expected, $description)> 
    6585 
    6686Runs a language test and passes the test if a string comparison 
    67 if a string comparison of the output with the unexpected result is false. 
    68 For C<language_error_output_isnt()> the exit code also has to be non-zero. 
     87of the output with the unexpected result is false. For 
     88C<language_error_output_isnt()>, the exit code also has to be non-zero. 
    6989 
    7090=item C<pasm_output_is($code, $expected, $description)> 
    7191 
    72 Runs the Parrot Assembler code and passes the test if a string comparison of 
    73 the output with the expected result it true. 
     92Runs the PASM code and passes the test if a string comparison of 
     93the output with the expected result is true. 
    7494 
    7595=item C<pasm_error_output_is($code, $expected, $description)> 
    7696 
    77 Runs the Parrot Assembler code and passes the test if a string comparison of 
    78 the output with the expected result it true I<and> if Parrot exits with a 
     97Runs the PASM code and passes the test if a string comparison of 
     98the output with the expected result is true I<and> if Parrot exits with a 
    7999non-zero exit code. 
    80100 
    81101=item C<pasm_output_like($code, $expected, $description)> 
    82102 
    83 Runs the Parrot Assembler code and passes the test if the output matches 
     103Runs the PASM code and passes the test if the output matches 
    84104C<$expected>. 
    85105 
    86106=item C<pasm_error_output_like($code, $expected, $description)> 
    87107 
    88 Runs the Parrot Assembler code and passes the test if the output matches 
     108Runs the PASM code and passes the test if the output matches 
    89109C<$expected> I<and> if Parrot exits with a non-zero exit code. 
    90110 
    91111=item C<pasm_output_isnt($code, $unexpected, $description)> 
    92112 
    93 Runs the Parrot Assembler code and passes the test if a string comparison of 
     113Runs the PASM code and passes the test if a string comparison of 
    94114the output with the unexpected result is false. 
    95115 
    96116=item C<pasm_error_output_isnt($code, $unexpected, $description)> 
    97117 
    98 Runs the Parrot Assembler code and passes the test if a string comparison of 
     118Runs the PASM code and passes the test if a string comparison of 
    99119the output with the unexpected result is false I<and> if Parrot exits with a 
    100120non-zero exit code. 
    101121 
     
    106126 
    107127=item C<pir_output_is($code, $expected, $description)> 
    108128 
    109 Runs the PIR code and passes the test if a string comparison of output with the 
    110 expected result is true. 
     129Runs the PIR code and passes the test if a string comparison of the output 
     130with the expected result is true. 
    111131 
    112132=item C<pir_error_output_is($code, $expected, $description)> 
    113133 
    114 Runs the PIR code and passes the test if a string comparison of output with the 
    115 expected result is true I<and> if Parrot exits with a non-zero exit code. 
     134Runs the PIR code and passes the test if a string comparison of the output 
     135with the expected result is true I<and> if Parrot exits with a non-zero exit 
     136code. 
    116137 
    117138=item C<pir_output_like($code, $expected, $description)> 
    118139 
    119 Runs the PIR code and passes the test if output matches the expected result. 
     140Runs the PIR code and passes the test if the output matches the expected 
     141result. 
    120142 
    121143=item C<pir_error_output_like($code, $expected, $description)> 
    122144 
    123 Runs the PIR code and passes the test if output matches the expected result 
     145Runs the PIR code and passes the test if the output matches the expected result 
    124146I<and> if Parrot exits with a non-zero exit code. 
    125147 
    126148=item C<pir_output_isnt($code, $unexpected, $description)> 
     
    141163 
    142164=item C<pbc_output_is($code, $expected, $description)> 
    143165 
    144 Runs the Parrot Bytecode and passes the test if a string comparison of output 
    145 with the expected result is true. 
     166Runs the Parrot bytecode and passes the test if a string comparison of the 
     167output with the expected result is true. 
    146168 
    147169=item C<pbc_error_output_is($code, $expected, $description)> 
    148170 
    149 Runs the Parrot Bytecode and passes the test if a string comparison of the output 
    150 with the expected result is true I<and> if Parrot exits with a non-zero exit code. 
     171Runs the Parrot bytecode and passes the test if a string comparison of the 
     172output with the expected result is true I<and> if Parrot exits with a non-zero 
     173exit code. 
    151174 
    152175=item C<pbc_output_like($code, $expected, $description)> 
    153176 
    154 Runs the Parrot Bytecode and passes the test if output matches the expected 
     177Runs the Parrot bytecode and passes the test if the output matches the expected 
    155178result. 
    156179 
    157180=item C<pbc_error_output_like($code, $expected, $description)> 
    158181 
    159 Runs the Parrot Bytecode and passes the test if output matches the expected 
     182Runs the Parrot bytecode and passes the test if the output matches the expected 
    160183result I<and> if Parrot exits with a non-zero exit code. 
    161184 
    162185=item C<pbc_output_isnt($code, $unexpected, $description)> 
    163186 
    164 Runs the Parrot Bytecode and passes the test if a string comparison of output 
    165 with the unexpected result is false. 
     187Runs the Parrot bytecode and passes the test if a string comparison of the 
     188output with the unexpected result is false. 
    166189 
    167190=item C<pbc_error_output_isnt($code, $unexpected, $description)> 
    168191 
    169 Runs the Parrot Bytecode and passes the test if a string comparison of output 
    170 with the unexpected result is false I<and> if Parrot exits with a non-zero exit 
    171 code. 
     192Runs the Parrot bytecode and passes the test if a string comparison of the 
     193output with the unexpected result is false I<and> if Parrot exits with a 
     194non-zero exit code. 
    172195 
    173196=item C<pbc_exit_code_is($code, $exit_code, $description)> 
    174197 
    175 Runs the Parrot Bytecode and passes the test if the exit code equals $exit_code, 
     198Runs the Parrot bytecode and passes the test if the exit code equals $exit_code, 
    176199fails the test otherwise. 
    177200 
    178201=item C<c_output_is($code, $expected, $description, %options)> 
    179202 
    180 Compiles and runs the C code, passing the test if a string comparison of output 
    181 with the expected result it true.  Valid options are 'todo' => 'reason' to mark 
    182 a TODO test. 
     203Compiles and runs the C code, passing the test if a string comparison of the 
     204output with the expected result is true. Valid options are 'todo' => 'reason' 
     205to mark a TODO test. 
    183206 
    184207=item C<c_output_like($code, $expected, $description, %options)> 
    185208 
    186 Compiles and runs the C code, passing the test if output matches the expected 
    187 result. Valid options are 'todo' => 'reason' to mark a TODO test. 
     209Compiles and runs the C code, passing the test if the output matches the 
     210expected result. Valid options are 'todo' => 'reason' to mark a TODO test. 
    188211 
    189212=item C<c_output_isnt($code, $unexpected, $description, %options)> 
    190213 
    191 Compiles and runs the C code, passing the test if a string comparison of output 
    192 with the unexpected result is false.  Valid options are 'todo' => 'reason' to 
    193 mark a TODO test. 
     214Compiles and runs the C code, passing the test if a string comparison of the 
     215output with the unexpected result is false. Valid options are 
     216'todo' => 'reason' to mark a TODO test. 
    194217 
    195 =item C<example_output_is( $example_f, $expected, @todo )> 
     218=item C<example_output_is($example_f, $expected, @todo)> 
    196219 
    197 =item C<example_output_like( $example_f, $expected, @todo )> 
     220=item C<example_output_like($example_f, $expected, @todo)> 
    198221 
    199 =item C<example_output_isnt( $example_f, $expected, @todo )> 
     222=item C<example_output_isnt($example_f, $expected, @todo)> 
    200223 
    201224Determines the language, PIR or PASM, from the extension of C<$example_f> and runs 
    202 the appropriate C<^language_output_(is|like|isnt)> sub. 
    203 C<$example_f> is used as a description, so don't pass one. 
     225the appropriate C<language_output_(is|like|isnt)> subroutine. C<$example_f> is 
     226used as a description, so don't pass one. 
    204227 
    205228=item C<skip($why, $how_many)> 
    206229 
     
    224247 
    225248=item C<slurp_file($file_name)> 
    226249 
    227 Read the whole file $file_name and return the content as a string.  This is 
     250Read the whole file $file_name and return the content as a string. This is 
    228251just an alias for C<Parrot::BuildUtil::slurp_file>. 
    229252 
    230253=item C<convert_line_endings($text)> 
    231254 
    232 Convert Win32 style line endins with Unix style line endings. 
     255Convert Win32 style line endings with Unix style line endings. 
    233256 
    234257=item C<path_to_parrot()> 
    235258 
    236 Construct an absolute path to the parrot root dir. 
     259Construct an absolute path to the Parrot root directory. 
    237260 
    238 =item C<per_test( $ext, $test_no )> 
     261=item C<per_test($ext, $test_no)> 
    239262 
    240 Construct a path for a temporary files. 
    241 Takes C<$0> into account. 
     263Construct a path for temporary files. Takes C<$0> into account. 
    242264 
    243265=item C<write_code_to_file($code, $code_f)> 
    244266 
    245267Writes C<$code> into the file C<$code_f>. 
    246268 
    247 =item C<generate_languages_functions> 
     269=item C<generate_languages_functions()> 
    248270 
    249 Generate functions that are only used by a couple of 
    250 Parrot::Test::<lang> modules. 
    251 This implementation is experimental and currently only works 
    252 for languages/pipp. 
     271Generate functions that are only used by a couple of Parrot::Test::<lang> 
     272modules. This implementation is experimental and currently only works for 
     273languages/pipp. 
    253274 
    254275=back 
    255276 
     
    621642    Test::More::like($result, $expected_output, $description); 
    622643} 
    623644 
    624 # The following methods are private.  They should not be used by modules 
     645# The following methods are private. They should not be used by modules 
    625646# inheriting from Parrot::Test. 
    626647 
    627648sub _handle_error_output { 
     
    775796            my $args                               = $ENV{TEST_PROG_ARGS} || ''; 
    776797 
    777798            # Due to ongoing changes in PBC format, all tests in 
    778             # t/native_pbc/*.t are currently being SKIPped.  This means we 
     799            # t/native_pbc/*.t are currently being SKIPped. This means we 
    779800            # have no tests on which to model tests of the following block. 
    780801            # Hence, test coverage will be lacking. 
    781802            if ( $func =~ /^pbc_output_/ && $args =~ /-r / ) {