diff --git a/lib/Parrot/Test.pm b/lib/Parrot/Test.pm
index 8206264..9067096 100644
|
a
|
b
|
|
| 23 | 23 | |
| 24 | 24 | This module provides various Parrot-specific test functions. |
| 25 | 25 | |
| 26 | | =head2 Functions |
| | 26 | =head2 Function Parameters |
| | 27 | |
| | 28 | =over 4 |
| | 29 | |
| | 30 | =item C<$language> |
| | 31 | |
| | 32 | The language of the code being tested. |
| | 33 | |
| | 34 | =item C<$code> |
| 27 | 35 | |
| 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. |
| | 36 | The code that should be executed or transformed. |
| 33 | 37 | |
| 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 | |
| | 40 | The expected result. |
| | 41 | |
| | 42 | =item C<$unexpected> |
| | 43 | |
| | 44 | The unexpected result. |
| | 45 | |
| | 46 | =item C<$description> |
| | 47 | |
| | 48 | A short description of the test. |
| | 49 | |
| | 50 | =back |
| | 51 | |
| | 52 | Any 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: |
| 36 | 54 | |
| 37 | 55 | todo => 'reason to consider this TODO' |
| 38 | 56 | |
| 39 | | at the end of the argument list. Valid reasons include C<bug>, |
| | 57 | at the end of the argument list. Valid reasons include C<bug>, |
| 40 | 58 | C<unimplemented>, and so on. |
| 41 | 59 | |
| 42 | 60 | B<Note:> you I<must> use a C<$description> with TODO tests. |
| 43 | 61 | |
| | 62 | =head2 Functions |
| | 63 | |
| 44 | 64 | =over 4 |
| 45 | 65 | |
| 46 | | =item C<language_output_is( $language, $code, $expected, $description)> |
| | 66 | =item C<language_output_is($language, $code, $expected, $description)> |
| 47 | 67 | |
| 48 | | =item C<language_error_output_is( $language, $code, $expected, $description)> |
| | 68 | =item C<language_error_output_is($language, $code, $expected, $description)> |
| 49 | 69 | |
| 50 | 70 | Runs 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. |
| | 71 | of the output with the expected result is true. For |
| | 72 | C<language_error_output_is()>, the exit code also has to be non-zero. |
| 53 | 73 | |
| 54 | | =item C<language_output_like( $language, $code, $expected, $description)> |
| | 74 | =item C<language_output_like($language, $code, $expected, $description)> |
| 55 | 75 | |
| 56 | | =item C<language_error_output_like( $language, $code, $expected, $description)> |
| | 76 | =item C<language_error_output_like($language, $code, $expected, $description)> |
| 57 | 77 | |
| 58 | 78 | Runs 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. |
| | 79 | result. For C<language_error_output_like()>, the exit code also has to be |
| | 80 | non-zero. |
| 61 | 81 | |
| 62 | | =item C<language_output_isnt( $language, $code, $expected, $description)> |
| | 82 | =item C<language_output_isnt($language, $code, $expected, $description)> |
| 63 | 83 | |
| 64 | | =item C<language_error_output_isnt( $language, $code, $expected, $description)> |
| | 84 | =item C<language_error_output_isnt($language, $code, $expected, $description)> |
| 65 | 85 | |
| 66 | 86 | Runs 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. |
| | 87 | of the output with the unexpected result is false. For |
| | 88 | C<language_error_output_isnt()>, the exit code also has to be non-zero. |
| 69 | 89 | |
| 70 | 90 | =item C<pasm_output_is($code, $expected, $description)> |
| 71 | 91 | |
| 72 | | Runs the Parrot Assembler code and passes the test if a string comparison of |
| 73 | | the output with the expected result it true. |
| | 92 | Runs the PASM code and passes the test if a string comparison of |
| | 93 | the output with the expected result is true. |
| 74 | 94 | |
| 75 | 95 | =item C<pasm_error_output_is($code, $expected, $description)> |
| 76 | 96 | |
| 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 |
| | 97 | Runs the PASM code and passes the test if a string comparison of |
| | 98 | the output with the expected result is true I<and> if Parrot exits with a |
| 79 | 99 | non-zero exit code. |
| 80 | 100 | |
| 81 | 101 | =item C<pasm_output_like($code, $expected, $description)> |
| 82 | 102 | |
| 83 | | Runs the Parrot Assembler code and passes the test if the output matches |
| | 103 | Runs the PASM code and passes the test if the output matches |
| 84 | 104 | C<$expected>. |
| 85 | 105 | |
| 86 | 106 | =item C<pasm_error_output_like($code, $expected, $description)> |
| 87 | 107 | |
| 88 | | Runs the Parrot Assembler code and passes the test if the output matches |
| | 108 | Runs the PASM code and passes the test if the output matches |
| 89 | 109 | C<$expected> I<and> if Parrot exits with a non-zero exit code. |
| 90 | 110 | |
| 91 | 111 | =item C<pasm_output_isnt($code, $unexpected, $description)> |
| 92 | 112 | |
| 93 | | Runs the Parrot Assembler code and passes the test if a string comparison of |
| | 113 | Runs the PASM code and passes the test if a string comparison of |
| 94 | 114 | the output with the unexpected result is false. |
| 95 | 115 | |
| 96 | 116 | =item C<pasm_error_output_isnt($code, $unexpected, $description)> |
| 97 | 117 | |
| 98 | | Runs the Parrot Assembler code and passes the test if a string comparison of |
| | 118 | Runs the PASM code and passes the test if a string comparison of |
| 99 | 119 | the output with the unexpected result is false I<and> if Parrot exits with a |
| 100 | 120 | non-zero exit code. |
| 101 | 121 | |
| … |
… |
|
| 106 | 126 | |
| 107 | 127 | =item C<pir_output_is($code, $expected, $description)> |
| 108 | 128 | |
| 109 | | Runs the PIR code and passes the test if a string comparison of output with the |
| 110 | | expected result is true. |
| | 129 | Runs the PIR code and passes the test if a string comparison of the output |
| | 130 | with the expected result is true. |
| 111 | 131 | |
| 112 | 132 | =item C<pir_error_output_is($code, $expected, $description)> |
| 113 | 133 | |
| 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. |
| | 134 | Runs the PIR code and passes the test if a string comparison of the output |
| | 135 | with the expected result is true I<and> if Parrot exits with a non-zero exit |
| | 136 | code. |
| 116 | 137 | |
| 117 | 138 | =item C<pir_output_like($code, $expected, $description)> |
| 118 | 139 | |
| 119 | | Runs the PIR code and passes the test if output matches the expected result. |
| | 140 | Runs the PIR code and passes the test if the output matches the expected |
| | 141 | result. |
| 120 | 142 | |
| 121 | 143 | =item C<pir_error_output_like($code, $expected, $description)> |
| 122 | 144 | |
| 123 | | Runs the PIR code and passes the test if output matches the expected result |
| | 145 | Runs the PIR code and passes the test if the output matches the expected result |
| 124 | 146 | I<and> if Parrot exits with a non-zero exit code. |
| 125 | 147 | |
| 126 | 148 | =item C<pir_output_isnt($code, $unexpected, $description)> |
| … |
… |
|
| 141 | 163 | |
| 142 | 164 | =item C<pbc_output_is($code, $expected, $description)> |
| 143 | 165 | |
| 144 | | Runs the Parrot Bytecode and passes the test if a string comparison of output |
| 145 | | with the expected result is true. |
| | 166 | Runs the Parrot bytecode and passes the test if a string comparison of the |
| | 167 | output with the expected result is true. |
| 146 | 168 | |
| 147 | 169 | =item C<pbc_error_output_is($code, $expected, $description)> |
| 148 | 170 | |
| 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. |
| | 171 | Runs the Parrot bytecode and passes the test if a string comparison of the |
| | 172 | output with the expected result is true I<and> if Parrot exits with a non-zero |
| | 173 | exit code. |
| 151 | 174 | |
| 152 | 175 | =item C<pbc_output_like($code, $expected, $description)> |
| 153 | 176 | |
| 154 | | Runs the Parrot Bytecode and passes the test if output matches the expected |
| | 177 | Runs the Parrot bytecode and passes the test if the output matches the expected |
| 155 | 178 | result. |
| 156 | 179 | |
| 157 | 180 | =item C<pbc_error_output_like($code, $expected, $description)> |
| 158 | 181 | |
| 159 | | Runs the Parrot Bytecode and passes the test if output matches the expected |
| | 182 | Runs the Parrot bytecode and passes the test if the output matches the expected |
| 160 | 183 | result I<and> if Parrot exits with a non-zero exit code. |
| 161 | 184 | |
| 162 | 185 | =item C<pbc_output_isnt($code, $unexpected, $description)> |
| 163 | 186 | |
| 164 | | Runs the Parrot Bytecode and passes the test if a string comparison of output |
| 165 | | with the unexpected result is false. |
| | 187 | Runs the Parrot bytecode and passes the test if a string comparison of the |
| | 188 | output with the unexpected result is false. |
| 166 | 189 | |
| 167 | 190 | =item C<pbc_error_output_isnt($code, $unexpected, $description)> |
| 168 | 191 | |
| 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. |
| | 192 | Runs the Parrot bytecode and passes the test if a string comparison of the |
| | 193 | output with the unexpected result is false I<and> if Parrot exits with a |
| | 194 | non-zero exit code. |
| 172 | 195 | |
| 173 | 196 | =item C<pbc_exit_code_is($code, $exit_code, $description)> |
| 174 | 197 | |
| 175 | | Runs the Parrot Bytecode and passes the test if the exit code equals $exit_code, |
| | 198 | Runs the Parrot bytecode and passes the test if the exit code equals $exit_code, |
| 176 | 199 | fails the test otherwise. |
| 177 | 200 | |
| 178 | 201 | =item C<c_output_is($code, $expected, $description, %options)> |
| 179 | 202 | |
| 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. |
| | 203 | Compiles and runs the C code, passing the test if a string comparison of the |
| | 204 | output with the expected result is true. Valid options are 'todo' => 'reason' |
| | 205 | to mark a TODO test. |
| 183 | 206 | |
| 184 | 207 | =item C<c_output_like($code, $expected, $description, %options)> |
| 185 | 208 | |
| 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. |
| | 209 | Compiles and runs the C code, passing the test if the output matches the |
| | 210 | expected result. Valid options are 'todo' => 'reason' to mark a TODO test. |
| 188 | 211 | |
| 189 | 212 | =item C<c_output_isnt($code, $unexpected, $description, %options)> |
| 190 | 213 | |
| 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. |
| | 214 | Compiles and runs the C code, passing the test if a string comparison of the |
| | 215 | output with the unexpected result is false. Valid options are |
| | 216 | 'todo' => 'reason' to mark a TODO test. |
| 194 | 217 | |
| 195 | | =item C<example_output_is( $example_f, $expected, @todo )> |
| | 218 | =item C<example_output_is($example_f, $expected, @todo)> |
| 196 | 219 | |
| 197 | | =item C<example_output_like( $example_f, $expected, @todo )> |
| | 220 | =item C<example_output_like($example_f, $expected, @todo)> |
| 198 | 221 | |
| 199 | | =item C<example_output_isnt( $example_f, $expected, @todo )> |
| | 222 | =item C<example_output_isnt($example_f, $expected, @todo)> |
| 200 | 223 | |
| 201 | 224 | Determines 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. |
| | 225 | the appropriate C<language_output_(is|like|isnt)> subroutine. C<$example_f> is |
| | 226 | used as a description, so don't pass one. |
| 204 | 227 | |
| 205 | 228 | =item C<skip($why, $how_many)> |
| 206 | 229 | |
| … |
… |
|
| 224 | 247 | |
| 225 | 248 | =item C<slurp_file($file_name)> |
| 226 | 249 | |
| 227 | | Read the whole file $file_name and return the content as a string. This is |
| | 250 | Read the whole file $file_name and return the content as a string. This is |
| 228 | 251 | just an alias for C<Parrot::BuildUtil::slurp_file>. |
| 229 | 252 | |
| 230 | 253 | =item C<convert_line_endings($text)> |
| 231 | 254 | |
| 232 | | Convert Win32 style line endins with Unix style line endings. |
| | 255 | Convert Win32 style line endings with Unix style line endings. |
| 233 | 256 | |
| 234 | 257 | =item C<path_to_parrot()> |
| 235 | 258 | |
| 236 | | Construct an absolute path to the parrot root dir. |
| | 259 | Construct an absolute path to the Parrot root directory. |
| 237 | 260 | |
| 238 | | =item C<per_test( $ext, $test_no )> |
| | 261 | =item C<per_test($ext, $test_no)> |
| 239 | 262 | |
| 240 | | Construct a path for a temporary files. |
| 241 | | Takes C<$0> into account. |
| | 263 | Construct a path for temporary files. Takes C<$0> into account. |
| 242 | 264 | |
| 243 | 265 | =item C<write_code_to_file($code, $code_f)> |
| 244 | 266 | |
| 245 | 267 | Writes C<$code> into the file C<$code_f>. |
| 246 | 268 | |
| 247 | | =item C<generate_languages_functions> |
| | 269 | =item C<generate_languages_functions()> |
| 248 | 270 | |
| 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. |
| | 271 | Generate functions that are only used by a couple of Parrot::Test::<lang> |
| | 272 | modules. This implementation is experimental and currently only works for |
| | 273 | languages/pipp. |
| 253 | 274 | |
| 254 | 275 | =back |
| 255 | 276 | |
| … |
… |
|
| 621 | 642 | Test::More::like($result, $expected_output, $description); |
| 622 | 643 | } |
| 623 | 644 | |
| 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 |
| 625 | 646 | # inheriting from Parrot::Test. |
| 626 | 647 | |
| 627 | 648 | sub _handle_error_output { |
| … |
… |
|
| 775 | 796 | my $args = $ENV{TEST_PROG_ARGS} || ''; |
| 776 | 797 | |
| 777 | 798 | # 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 |
| 779 | 800 | # have no tests on which to model tests of the following block. |
| 780 | 801 | # Hence, test coverage will be lacking. |
| 781 | 802 | if ( $func =~ /^pbc_output_/ && $args =~ /-r / ) { |