2 # Copyright (C) 2007-2010, Parrot Foundation.
7 use lib qw( . lib ../lib ../../lib );
9 use ExtUtils::Manifest qw(maniread);
15 t/examples/tutorial.t - Test examples in F<examples/tutorial>
19 % prove t/examples/tutorial.t
23 Test the examples in F<examples/tutorial>.
27 my $manifest = maniread('MANIFEST');
29 foreach my $file (keys %$manifest) {
30 next unless $file =~ m{examples/tutorial/.*pir$};
34 plan tests => scalar keys %files;
36 # Set up expected output for examples
38 '01_temp_var.pir' => << 'END_EXPECTED',
45 '02_local_var.pir' => << 'END_EXPECTED',
52 '03_temp_var_basic_pmcs.pir' => << 'END_EXPECTED',
58 '04_pod_comments.pir' => << 'END_EXPECTED',
62 '10_math_ops.pir' => << 'END_EXPECTED',
67 '11_math_ops_self_mod.pir' => << 'END_EXPECTED',
72 '12_math_ops_pasm.pir' => << 'END_EXPECTED',
77 '13_logical_ops.pir' => << 'END_EXPECTED',
82 '20_string_ops.pir' => << 'END_EXPECTED',
86 ##Note extra whitespace after 3rd hello
87 '21_string_ops_repeat.pir' => << 'END_EXPECTED',
91 '22_string_ops_length.pir' => << 'END_EXPECTED',
96 '23_string_ops_substr.pir' => << 'END_EXPECTED',
104 '24_string_ops_clone.pir' => << 'END_EXPECTED',
110 '30_arrays_basic.pir' => << 'END_EXPECTED',
117 '31_array_ops_split.pir' => << 'END_EXPECTED',
122 '32_array_ops_sprintf.pir' => << 'END_EXPECTED',
127 '33_hashes.pir' => << 'END_EXPECTED',
133 '34_multikey.pir' => << 'END_EXPECTED',
137 '40_file_ops.pir' => << 'END_EXPECTED',
138 The quick brown fox jumps over the lazy dog.
142 '50_goto.pir' => << 'END_EXPECTED',
147 '51_if_unless.pir' => << 'END_EXPECTED',
157 '52_if_compare.pir' => << 'END_EXPECTED',
162 '53_loop.pir' => << 'END_EXPECTED',
166 '55_iterator.pir' => << 'END_EXPECTED',
173 '56_defined.pir' => << 'END_EXPECTED',
178 '57_exists.pir' => << 'END_EXPECTED',
179 my_array[0] is defined
181 my_array[1] is not defined
183 my_array[2] is not defined
184 my_array[2] does not exist
187 '60_subroutines.pir' => << 'END_EXPECTED',
191 '61_namespaces.pir' => << 'END_EXPECTED',
195 '62_namespaces.pir' => << 'END_EXPECTED',
199 '70_class_object.pir' => << 'END_EXPECTED',
204 '81_continuation.pir' => << 'END_EXPECTED',
209 '82_coroutine.pir' => << 'END_EXPECTED',
214 '83_external_libraries.pir' => << 'END_EXPECTED',
218 '90_writing_tests.pir' => << 'END_EXPECTED',
222 ok 3 #skip skipped test
223 ok 4 # TODO todo test
228 # note any todos. if the sub returns undef or isn't present, the
231 '51_if_unless.pir' => sub {
232 'Failing on Win32' if $^O =~ /Win32/;
236 foreach my $tutorial (sort keys %files) {
237 my $file = $tutorial;
240 if (exists $expected{$file}) {
241 my $expected = $expected{$file};
242 if (exists $todo{$file}) {
243 my $reason = $todo{$file}->();
244 @todo = (todo => $reason) if defined $reason;
246 example_output_is( $tutorial, $expected, @todo );
255 # cperl-indent-level: 4
258 # vim: expandtab shiftwidth=4: