1#!perl
2# Copyright (C) 2005-2006, Parrot Foundation.
3
4use strict;
5use warnings;
6use lib qw( . lib ../lib ../../lib );
7use Test::More;
8use Parrot::Test tests => 4;
9use Parrot::Config;
10
11=head1 NAME
12
13t/examples/library.t - Test examples in F<examples/library>
14
15=head1 SYNOPSIS
16
17    % prove t/examples/library.t
18
19=head1 DESCRIPTION
20
21Test the examples in F<examples/library>.
22
23=head1 SEE ALSO
24
25F<t/examples/japh.t>
26
27=cut
28
29# Set up expected output of the examples
30my %expected = (
31    'getopt_demo.pir' => <<'END_EXPECTED',
32Hi, I am 'getopt_demo.pir'.
33
34You haven't passed the option '--bool'. This is fine with me.
35You haven't passed the option '--string'. This is fine with me.
36You haven't passed the option '--integer'. This is fine with me.
37All args have been parsed.
38END_EXPECTED
39
40    # '
41);
42
43while ( my ( $example, $expected ) = each %expected ) {
44    example_output_is( "examples/library/$example", $expected );
45}
46
47my $PARROT = File::Spec->catfile( File::Spec->curdir(), $PConfig{test_prog} );
48
49# For testing md5sum.pir we need to pass a filename
50{
51    my $md5sum_fn = File::Spec->catfile(qw( examples library md5sum.pir ));
52    my $sample_fn = File::Spec->catfile(qw( t library perlhistory.txt ));
53    my $sum       = `$PARROT $md5sum_fn $sample_fn`;
54    is( $sum, "fb171bd1a17bf6cd08d73105ad738a35\t$sample_fn\n", $md5sum_fn );
55}
56
57SKIP:
58{
59    skip( 'no pcre-config', 1 ); # Original check for PCRE flawed (TT #406)
60
61    my $pcre_fn  = File::Spec->catfile(qw( examples library pcre.pir ));
62    my $test_out = `$PARROT $pcre_fn asdf as`;
63    is( $test_out, <<'END_EXPECTED', $pcre_fn );
64asdf =~ /as/
651 match(es):
66as
67END_EXPECTED
68}
69
70TODO:
71{
72    local $TODO = 'ncurses_life.pir not testable yet';
73    fail('ncurses_life.pir');
74}
75
76# Local Variables:
77#   mode: cperl
78#   cperl-indent-level: 4
79#   fill-column: 100
80# End:
81# vim: expandtab shiftwidth=4:
82