[svn:parrot] r48249 - in branches/tt1725_headerizer_documentation: . lib/Parrot t/perl

jkeenan at svn.parrot.org jkeenan at svn.parrot.org
Mon Aug 2 01:56:05 UTC 2010


Author: jkeenan
Date: Mon Aug  2 01:56:05 2010
New Revision: 48249
URL: https://trac.parrot.org/parrot/changeset/48249

Log:
As a step toward writing better docs for the headerizer, write some tests for Parrot::Headerizer.

Added:
   branches/tt1725_headerizer_documentation/t/perl/Parrot_Headerizer.t   (contents, props changed)
      - copied, changed from r48248, branches/tt1725_headerizer_documentation/t/perl/Parrot_Distribution.t
Modified:
   branches/tt1725_headerizer_documentation/MANIFEST
   branches/tt1725_headerizer_documentation/lib/Parrot/Headerizer.pm

Modified: branches/tt1725_headerizer_documentation/MANIFEST
==============================================================================
--- branches/tt1725_headerizer_documentation/MANIFEST	Mon Aug  2 01:38:45 2010	(r48248)
+++ branches/tt1725_headerizer_documentation/MANIFEST	Mon Aug  2 01:56:05 2010	(r48249)
@@ -1,7 +1,7 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools/dev/mk_manifest_and_skip.pl Sat Jul 31 17:37:19 2010 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Mon Aug  2 01:55:16 2010 UT
 #
 # See below for documentation on the format of this file.
 #
@@ -1833,6 +1833,7 @@
 t/op/vivify.t                                               [test]
 t/perl/Parrot_Distribution.t                                [test]
 t/perl/Parrot_Docs.t                                        [test]
+t/perl/Parrot_Headerizer.t                                  [test]
 t/perl/Parrot_IO.t                                          [test]
 t/perl/Parrot_Test.t                                        [test]
 t/perl/README                                               []doc

Modified: branches/tt1725_headerizer_documentation/lib/Parrot/Headerizer.pm
==============================================================================
--- branches/tt1725_headerizer_documentation/lib/Parrot/Headerizer.pm	Mon Aug  2 01:38:45 2010	(r48248)
+++ branches/tt1725_headerizer_documentation/lib/Parrot/Headerizer.pm	Mon Aug  2 01:56:05 2010	(r48249)
@@ -29,9 +29,8 @@
 
 =item C<new()>
 
-TODO
-
-Contructor of headerizer objects
+Parrot::Headerizer constructor.  Contains within a list of valid Parrot
+macros.
 
 =cut
 

Copied and modified: branches/tt1725_headerizer_documentation/t/perl/Parrot_Headerizer.t (from r48248, branches/tt1725_headerizer_documentation/t/perl/Parrot_Distribution.t)
==============================================================================
--- branches/tt1725_headerizer_documentation/t/perl/Parrot_Distribution.t	Mon Aug  2 01:38:45 2010	(r48248, copy source)
+++ branches/tt1725_headerizer_documentation/t/perl/Parrot_Headerizer.t	Mon Aug  2 01:56:05 2010	(r48249)
@@ -4,97 +4,34 @@
 
 use strict;
 use warnings;
-use lib qw( . lib ../lib ../../lib );
+use lib qw( lib );
 
-use Test::More tests => 26;
-use File::Spec;
+use Test::More qw(no_plan); # tests => 26;
 
 =head1 NAME
 
-t/perl/Parrot_Distribution.t - Parrot::Distribution unit tests
+t/perl/Parrot_Headerizer.t - Parrot::Headerizer unit tests
 
 =head1 SYNOPSIS
 
-    % prove t/perl/Parrot_Distribution.t
+    % prove t/perl/Parrot_Headerizer.t
 
 =head1 DESCRIPTION
 
-Test individual Parrot::Distribution methods.
+Test individual Parrot::Headerizer methods.
 
 =cut
 
-BEGIN { use_ok('Parrot::Distribution') }
+BEGIN { use_ok('Parrot::Headerizer') }
 
-die "Run these tests from the distribution root\n" unless -d 't/perl';
-
-# search upwards
-chdir 't/perl';
-my $d = Parrot::Distribution->new();
-isa_ok( $d, 'Parrot::Docs::Directory' );
-ok( $d == Parrot::Distribution->new(), 'Parrot::Distribution is a singleton' );
-
-ok( $d->c_source_file_with_name('pf_items'), 'C source file' );
-ok( !$d->c_source_file_with_name('moomoo'), 'C source file not there' );
-
-ok( $d->c_header_file_with_name('parrot'), 'C header file' );
-ok( !$d->c_header_file_with_name('moomoo'), 'C header file not there' );
-
-ok( $d->pmc_source_file_with_name('parrotinterpreter'), 'PMC code' );
-ok( !$d->pmc_source_file_with_name('moomoo'), 'PMC code file not there' );
-
-ok( $d->yacc_source_file_with_name('imcc'), 'Yacc code' );
-ok( !$d->yacc_source_file_with_name('moomoo'), 'Yacc code file not there' );
-
-ok( $d->lex_source_file_with_name('imcc'), 'Lex code' );
-ok( !$d->lex_source_file_with_name('moomoo'), 'Lex code file not there' );
-
-ok( $d->file_for_perl_module('Parrot::Docs::Section::Parrot'), 'Perl module file' );
-ok( !$d->file_for_perl_module('Parrot::Dummy'), 'Perl module file not there' );
-
-my %pmc_source_file_directories = map { $_->path => 1 } $d->pmc_source_file_directories();
-
-my @old_directory_list = (
-    map { File::Spec->catdir( 'src', $_ ) } qw(dynpmc pmc)
-);
-
-for my $dir (@old_directory_list) {
-    my $path = $d->directory_with_name($dir)->path();
-    ok( exists $pmc_source_file_directories{$path},
-        "Directory from hardcoded list $dir found through MANIFEST" )
-        or diag( "Missing $dir\n" );
-}
-
-## perl files and exemptions
-{
-    my @perl_files = $d->get_perl_language_files();
-    ok( @perl_files, 'Got some perl files' );
-
-    ok( $d->perl_source_file_with_name('ops2c.pl'),        'Perl source file (.pl)' );
-    ok( $d->perl_source_file_with_name('Distribution.pm'), 'Perl source file (.pm)' );
-    ok( $d->perl_source_file_with_name('perlcritic.t'),    'Perl source file (.t)' );
-    ok( !$d->perl_source_file_with_name('p5rx.t'),         'Not a Perl source file (.t)' );
-
-    my $perl_exemption_regexp = $d->get_perl_exemption_regexp();
-    ok( $perl_exemption_regexp, 'Got perl exemption regexp' );
-
-    # we are in 't/perl'
-    {
-        my $dummy_fn = '../../lib/DumbLink.pm';
-        my $not_exempted_file = Parrot::IO::File->new($dummy_fn);
-        ok( !$d->is_perl_exemption($not_exempted_file), 'DumbLink.pm is not exempted' );
-        unlike( $not_exempted_file->path(), $perl_exemption_regexp, 'DumbLink.pm is not matched' );
-        unlink $dummy_fn;
-    }
-
-    # check that no exemptions turn up in the main file list
-    my @exemptions_in_perl_list = grep { $_ =~ $perl_exemption_regexp }
-        map { $_->path } @perl_files;
-
-    ok( !@exemptions_in_perl_list, 'No exemptions in Perl source list' );
-    foreach (@exemptions_in_perl_list) {
-        diag("got exempted perl file: $_");
-    }
-}
+my $headerizer = Parrot::Headerizer->new();
+isa_ok( $headerizer, 'Parrot::Headerizer' );
+ok( $headerizer->valid_macro( 'PARROT_CAN_RETURN_NULL' ),
+    'valid macro reported' );
+ok( ! $headerizer->valid_macro( 'IMAGINARY_MACRO_FOO_BAR_BAZ' ),
+    'invalid macro reported' );
+my @valid_macros = $headerizer->valid_macros();
+ok( @valid_macros, 'sanity check: at least one valid macro exists' );
 
 # Local Variables:
 #   mode: cperl


More information about the parrot-commits mailing list