[cage] Fix pgegrep, which was merely an innocent bystander in the Great Namespace...
[parrot.git] / t / perl / Parrot_Distribution.t
blobec99fc5649fdbc5125732e95b86e9101d2519fcb
1 #! perl
2 # Copyright (C) 2001-2009, Parrot Foundation.
3 # $Id$
5 use strict;
6 use warnings;
7 use lib qw( . lib ../lib ../../lib );
9 use Test::More tests => 26;
10 use File::Spec;
12 =head1 NAME
14 t/perl/Parrot_Distribution.t - Parrot::Distribution unit tests
16 =head1 SYNOPSIS
18     % prove t/perl/Parrot_Distribution.t
20 =head1 DESCRIPTION
22 Test individual Parrot::Distribution methods.
24 =cut
26 BEGIN { use_ok('Parrot::Distribution') }
28 die "Run these tests from the distribution root\n" unless -d 't/perl';
30 # search upwards
31 chdir 't/perl';
32 my $d = Parrot::Distribution->new();
33 isa_ok( $d, 'Parrot::Docs::Directory' );
34 ok( $d == Parrot::Distribution->new(), 'Parrot::Distribution is a singleton' );
36 ok( $d->c_source_file_with_name('pf_items'), 'C source file' );
37 ok( !$d->c_source_file_with_name('moomoo'), 'C source file not there' );
39 ok( $d->c_header_file_with_name('parrot'), 'C header file' );
40 ok( !$d->c_header_file_with_name('moomoo'), 'C header file not there' );
42 ok( $d->pmc_source_file_with_name('parrotinterpreter'), 'PMC code' );
43 ok( !$d->pmc_source_file_with_name('moomoo'), 'PMC code file not there' );
45 ok( $d->yacc_source_file_with_name('imcc'), 'Yacc code' );
46 ok( !$d->yacc_source_file_with_name('moomoo'), 'Yacc code file not there' );
48 ok( $d->lex_source_file_with_name('imcc'), 'Lex code' );
49 ok( !$d->lex_source_file_with_name('moomoo'), 'Lex code file not there' );
51 ok( $d->file_for_perl_module('Parrot::Docs::Section::Parrot'), 'Perl module file' );
52 ok( !$d->file_for_perl_module('Parrot::Dummy'), 'Perl module file not there' );
54 my %pmc_source_file_directories = map { $_->path => 1 } $d->pmc_source_file_directories();
56 my @old_directory_list = (
57     map { File::Spec->catdir( 'src', $_ ) } qw(dynpmc pmc)
60 for my $dir (@old_directory_list) {
61     my $path = $d->directory_with_name($dir)->path();
62     ok( exists $pmc_source_file_directories{$path},
63         "Directory from hardcoded list $dir found through MANIFEST" )
64         or diag( "Missing $dir\n" );
67 ## perl files and exemptions
69     my @perl_files = $d->get_perl_language_files();
70     ok( @perl_files, 'Got some perl files' );
72     ok( $d->perl_source_file_with_name('ops2c.pl'),        'Perl source file (.pl)' );
73     ok( $d->perl_source_file_with_name('Distribution.pm'), 'Perl source file (.pm)' );
74     ok( $d->perl_source_file_with_name('perlcritic.t'),    'Perl source file (.t)' );
75     ok( !$d->perl_source_file_with_name('p5rx.t'),         'Not a Perl source file (.t)' );
77     my $perl_exemption_regexp = $d->get_perl_exemption_regexp();
78     ok( $perl_exemption_regexp, 'Got perl exemption regexp' );
80     # we are in 't/perl'
81     {
82         my $dummy_fn = '../../lib/DumbLink.pm';
83         my $not_exempted_file = Parrot::IO::File->new($dummy_fn);
84         ok( !$d->is_perl_exemption($not_exempted_file), 'DumbLink.pm is not exempted' );
85         unlike( $not_exempted_file->path(), $perl_exemption_regexp, 'DumbLink.pm is not matched' );
86         unlink $dummy_fn;
87     }
89     # check that no exemptions turn up in the main file list
90     my @exemptions_in_perl_list = grep { $_ =~ $perl_exemption_regexp }
91         map { $_->path } @perl_files;
93     ok( !@exemptions_in_perl_list, 'No exemptions in Perl source list' );
94     foreach (@exemptions_in_perl_list) {
95         diag("got exempted perl file: $_");
96     }
99 # Local Variables:
100 #   mode: cperl
101 #   cperl-indent-level: 4
102 #   fill-column: 100
103 # End:
104 # vim: expandtab shiftwidth=4: