2 # Copyright (C) 2001-2007, The Perl Foundation.
7 t/perl/Parrot_Test.t - Parrot::Test unit tests
11 % prove t/perl/Parrot_Test.t
15 These tests cover the basic functionality of C<Parrot::Test>.
24 eval "use Test::Builder::Tester;";
26 plan( skip_all => "Test::Builder::Tester not installed\n" );
32 use lib qw( . lib ../lib ../../lib );
35 my $pre_env = exists $ENV{PARROT_TEST} ? $ENV{PARROT_TEST} : undef;
36 use_ok('Parrot::Test') or die;
38 my $post_env = exists $ENV{PARROT_TEST} ? $ENV{PARROT_TEST} : undef;
39 if ( defined $pre_env ) {
40 is( $post_env, $pre_env, 'PARROT_TEST env unchanged' );
43 is( $post_env, 1, 'PARROT_TEST env set' );
47 can_ok( 'Parrot::Test', $_ ) for qw/
48 c_output_is c_output_isnt
50 example_output_is example_output_isnt
52 language_error_output_is language_error_output_isnt
53 language_error_output_like
54 language_output_is language_output_isnt
56 pasm_error_output_is pasm_error_output_isnt
57 pasm_error_output_like pasm_error_output_unlike
58 pasm_output_is pasm_output_isnt
59 pasm_output_like pasm_output_unlike
60 pbc_error_output_is pbc_error_output_isnt
61 pbc_error_output_like pbc_error_output_unlike
62 pbc_output_is pbc_output_isnt
63 pbc_output_like pbc_output_unlike
64 pir_error_output_is pir_error_output_isnt
65 pir_error_output_like pir_error_output_unlike
66 pir_output_is pir_output_isnt
67 pir_output_like pir_output_unlike
68 pir_2_pasm_is pir_2_pasm_isnt
69 pir_2_pasm_like pir_2_pasm_unlike
70 generate_languages_functions
79 # RT#46891 test run_command()
82 is( Parrot::Test::per_test(), undef, 'per_test() no args' );
83 is( Parrot::Test::per_test( undef, 0 ), undef, 'per_test() invalid first arg' );
84 is( Parrot::Test::per_test( 0, undef ), undef, 'per_test() invalid second arg' );
85 is( Parrot::Test::per_test( undef, undef ), undef, 'per_test() two invalid args' );
87 # RT#46893 test write_code_to_file(), plan(), skip(), slurp_file()
89 # test the test functions from Parrot::Test
90 # RT#46893: test the untested test functions
91 my ( $desc, $err, $line );
94 $desc = 'pasm_output_is: success';
95 test_out("ok 1 - $desc");
96 pasm_output_is( <<'CODE', <<'OUTPUT', $desc );
104 $desc = 'pasm_output_is: failure';
105 test_out("not ok 1 - $desc");
115 pasm_output_is( <<'CODE', <<"OUTPUT", $desc );
123 $desc = 'pasm_output_isnt: success';
124 test_out("ok 1 - $desc");
125 pasm_output_isnt( <<'CODE', <<"OUTPUT", $desc );
133 $desc = 'pasm_output_isnt: failure';
134 test_out("not ok 1 - $desc");
145 pasm_output_isnt( <<'CODE', <<'OUTPUT', $desc );
153 $desc = 'pasm_output_like: success';
154 test_out("ok 1 - $desc");
155 pasm_output_like( <<'CODE', <<'OUTPUT', $desc );
163 $desc = 'pasm_output_like: failure';
164 test_out("not ok 1 - $desc");
169 # doesn't match '/not ok/
174 pasm_output_like( <<'CODE', <<"OUTPUT", $desc );
183 $desc = 'pir_output_is: success';
184 test_out("ok 1 - $desc");
185 pir_output_is( <<'CODE', <<'OUTPUT', $desc );
194 $desc = 'pir_output_is: failure';
195 test_out("not ok 1 - $desc");
205 pir_output_is( <<'CODE', <<"OUTPUT", $desc );
214 $desc = 'pir_output_isnt: success';
215 test_out("ok 1 - $desc");
216 pir_output_isnt( <<'CODE', <<"OUTPUT", $desc );
225 $desc = 'pir_output_isnt: failure';
226 test_out("not ok 1 - $desc");
237 pir_output_isnt( <<'CODE', <<'OUTPUT', $desc );
246 $desc = 'pir_output_like: success';
247 test_out("ok 1 - $desc");
248 pir_output_like( <<'CODE', <<'OUTPUT', $desc );
257 $desc = 'pir_output_like: failure';
258 test_out("not ok 1 - $desc");
263 # doesn't match '/not ok/
268 pir_output_like( <<'CODE', <<"OUTPUT", $desc );
277 $desc = 'pir_error_output_like: todo';
278 $line = line_num(+21);
280 if ($Test::Builder::VERSION <= eval '0.33') {
281 $location = "in $0 at line $line";
283 $location = "at $0 line $line";
285 test_out("not ok 1 - $desc # TODO foo");
287 # Failed (TODO) test '$desc'
289 # Expected error but exited cleanly
299 pir_error_output_like( <<'CODE', <<"OUTPUT", $desc, todo => 'foo' );
310 # cperl-indent-level: 4
313 # vim: expandtab shiftwidth=4: