2 # Copyright (C) 2001-2008, The Perl Foundation.
7 use lib qw( . lib ../lib ../../lib );
8 use Test::More tests => 35;
13 t/perl/Parrot_Distribution.t - Parrot::Distribution unit tests
17 % prove t/perl/Parrot_Distribution.t
23 BEGIN { use_ok('Parrot::Distribution') }
25 die "Run these tests from the distribution root\n" unless -d 't/perl';
29 my $d = Parrot::Distribution->new();
30 isa_ok( $d, 'Parrot::Docs::Directory' );
31 ok( $d == Parrot::Distribution->new(), 'Parrot::Distribution is a singleton' );
33 ok( $d->c_source_file_with_name('pf_items'), 'C source file' );
34 ok( !$d->c_source_file_with_name('moomoo'), 'C source file not there' );
36 ok( $d->c_header_file_with_name('parrot'), 'C header file' );
37 ok( !$d->c_header_file_with_name('moomoo'), 'C header file not there' );
39 ok( $d->pmc_source_file_with_name('parrotinterpreter'), 'PMC code' );
40 ok( !$d->pmc_source_file_with_name('moomoo'), 'PMC code file not there' );
42 ok( $d->yacc_source_file_with_name('imcc'), 'Yacc code' );
43 ok( !$d->yacc_source_file_with_name('moomoo'), 'Yacc code file not there' );
45 ok( $d->lex_source_file_with_name('imcc'), 'Lex code' );
46 ok( !$d->lex_source_file_with_name('moomoo'), 'Lex code file not there' );
48 ok( $d->file_for_perl_module('Parrot::Docs::Section::Parrot'), 'Perl module file' );
49 ok( !$d->file_for_perl_module('Parrot::Dummy'), 'Perl module file not there' );
51 my %pmc_source_file_directories = map { $_->path => 1 } $d->pmc_source_file_directories();
53 my @old_directory_list = (
54 'compilers/bcg/src/pmc', 'languages/APL/src/pmc',
55 'languages/WMLScript/pmc',
56 'languages/dotnet/pmc', 'languages/lua/src/pmc',
57 'languages/perl6/src/pmc', 'languages/tcl/src/pmc',
58 map { File::Spec->catdir( 'src', $_ ) } qw(dynpmc pmc)
61 for my $dir (@old_directory_list) {
62 my $path = $d->directory_with_name($dir)->path();
63 ok( exists $pmc_source_file_directories{$path},
64 "Directory from hardcoded list $dir found through MANIFEST" )
65 or diag( "Missing $dir\n" );
68 ## perl files and exemptions
70 my @perl_files = $d->get_perl_language_files();
71 ok( @perl_files, 'Got some perl files' );
73 ok( $d->perl_source_file_with_name('ops2c.pl'), 'Perl source file (.pl)' );
74 ok( $d->perl_source_file_with_name('Distribution.pm'), 'Perl source file (.pm)' );
75 ok( $d->perl_source_file_with_name('perlcritic.t'), 'Perl source file (.t)' );
76 ok( !$d->perl_source_file_with_name('p5rx.t'), 'Not a Perl source file (.t)' );
78 my $perl_exemption_regexp = $d->get_perl_exemption_regexp();
79 ok( $perl_exemption_regexp, 'Got perl exemption regexp' );
81 my $exempted_file = Parrot::IO::File->new('../../lib/SmartLink.pm');
82 ok( $d->is_perl_exemption($exempted_file), 'SmartLink.pm is exempted' );
83 like( $exempted_file->path(), $perl_exemption_regexp, 'SmartLink.pm is matched' );
87 my $dummy_fn = '../../lib/DumbLink.pm';
88 my $not_exempted_file = Parrot::IO::File->new($dummy_fn);
89 ok( !$d->is_perl_exemption($not_exempted_file), 'DumbLink.pm is not exempted' );
90 unlike( $not_exempted_file->path(), $perl_exemption_regexp, 'DumbLink.pm is not matched' );
94 # check that no exemptions turn up in the main file list
95 my @exemptions_in_perl_list = grep { $_ =~ $perl_exemption_regexp }
96 map { $_->path } @perl_files;
98 ok( !@exemptions_in_perl_list, 'No exemptions in Perl source list' );
99 foreach (@exemptions_in_perl_list) {
100 diag("got exempted perl file: $_");
106 # cperl-indent-level: 4
109 # vim: expandtab shiftwidth=4: