Skip to content

Commit

Permalink
Merge branch 'master' into one
Browse files Browse the repository at this point in the history
Conflicts:
	MANIFEST
	lib/Acme/MetaSyntactic.pm
	lib/Acme/MetaSyntactic/pause_id.pm
	lib/Test/MetaSyntactic.pm
  • Loading branch information
book committed May 3, 2012
2 parents a88e15d + afef334 commit 23a452d
Show file tree
Hide file tree
Showing 51 changed files with 352 additions and 279 deletions.
5 changes: 5 additions & 0 deletions Changes
@@ -1,8 +1,13 @@
Revision history for Acme-MetaSyntactic

0.99_04 Wed Apr 11 01:34:50 CEST 2012
[TESTS]
- improved version of Test::MetaSyntactic, with more subtests

0.99_03 Sat Mar 31 19:41:22 CEST 2012
[TESTS]
- moved all tests common to all themes in the Test::MetaSyntactic module
- remove possible duplicates in unicode theme

0.99_02 Fri Nov 11 00:06:24 CET 2011
[TESTS]
Expand Down
46 changes: 24 additions & 22 deletions MANIFEST
Expand Up @@ -18,7 +18,6 @@ README
script/meta
script/metafy
t/00load.t
t/02fixme.t
t/05class.t
t/07data.t
t/10meta.t
Expand All @@ -35,35 +34,38 @@ t/32multi.t
t/33locale.t
t/33locale_territory.t
t/33locale_win32.t
t/34data.t
t/35remote.t
t/35remote2.t
t/40inc.t
t/50usecase.t
t/90up2date.t
t/Acme/MetaSyntactic/digits.pm
t/batcase1
t/batcase2
t/batcase3
t/batcase4
t/batcase5
t/batcase6
t/batcase7
t/batcase8
t/colcase1
t/colcase2
t/colcase3
t/haddockcase_en3
t/haddockcase_en4
t/haddockcase_en5
t/haddockcase_fr1
t/haddockcase_fr2
t/haddockcase_fr3
t/haddockcase_fr4
t/haddockcase_fr5
t/haddockcase_fr6
t/lib/Acme/MetaSyntactic/test_ams_alias.pm
t/lib/Acme/MetaSyntactic/test_ams_list.pm
t/lib/Acme/MetaSyntactic/test_ams_locale.pm
t/NoLang.pm
t/pod-coverage.t
t/pod.t
t/remote
t/remote1
t/remote2
t/usecase_alias1
t/usecase_alias2
t/usecase_alias3
t/usecase_list1
t/usecase_list2
t/usecase_list3
t/usecase_list4
t/usecase_list5
t/usecase_list6
t/usecase_list7
t/usecase_list8
t/usecase_locale_en3
t/usecase_locale_en4
t/usecase_locale_en5
t/usecase_locale_fr1
t/usecase_locale_fr2
t/usecase_locale_fr3
t/usecase_locale_fr4
t/usecase_locale_fr5
t/usecase_locale_fr6
4 changes: 3 additions & 1 deletion lib/Acme/MetaSyntactic/MultiList.pm
Expand Up @@ -9,8 +9,10 @@ our @ISA = qw( Acme::MetaSyntactic::RemoteList );
our $VERSION = '1.000';

sub init {
my ($self, $data) = @_;
my $class = caller(0);
my $data = Acme::MetaSyntactic->load_data($class);

$data ||= Acme::MetaSyntactic->load_data($class);
no strict 'refs';

# note: variables mentioned twice to avoid a warning
Expand Down
83 changes: 58 additions & 25 deletions lib/Test/MetaSyntactic.pm
Expand Up @@ -33,13 +33,14 @@ sub theme_ok {
$tb->subtest(
$theme,
sub {
$tb->subtest( "$theme fixme", sub { subtest_fixme(@args); } );
$tb->subtest( "$theme load", sub { subtest_load(@args); } )
or return;
$tb->subtest( "$theme version", sub { subtest_version(@args); } );
$tb->subtest( "$theme data", sub { subtest_data(@args); } );
$tb->subtest( "$theme format", sub { subtest_format(@args); } );
$tb->subtest( "$theme uniq", sub { subtest_uniq(@args); } );
$tb->subtest( "$theme length", sub { subtest_length(@args); } );
$tb->subtest( "$theme data", sub { subtest_data(@args); } );
$tb->subtest( "$theme import", sub { subtest_import(@args); } );
$tb->subtest( "$theme noimport", sub { subtest_noimport(@args); } );
$tb->subtest( "$theme theme", sub { subtest_theme(@args); } );
Expand Down Expand Up @@ -120,6 +121,32 @@ sub _theme_items {
return @items;
}

sub _check_file_lines {
my ($theme, $file, $mesg, $cb ) = @_;
my $tb = __PACKAGE__->builder;
$tb->plan( tests => 1 );
local $Test::Builder::Level = $Test::Builder::Level + 1;

SKIP: {
my ($fh, $skip);
if ( $file ) {
open $fh, $file or do { $skip="Can't open $file: $!"; };
}
else {
$skip = "This test needs the source file for $theme";
}
if( $skip ) {
$tb->skip($skip);
last SKIP;
}

my @lines = $cb->( <$fh> );
$tb->is_num( scalar @lines, 0, $mesg );
$tb->diag( "Failed lines:\n", map " $_\n", @lines ) if @lines;
close $fh;
}
}

#
# individual subtest functions
#
Expand All @@ -136,6 +163,17 @@ sub subtest_load {
$tb->diag($error) if $error;
}

# t/02fixme.t
sub subtest_fixme {
my ( $theme, $file ) = @_;
$file = '' if !defined $file;
_check_file_lines(
$theme, $file,
"No FIXME found in $file",
sub { grep /\bFIXME\b/, @_ }
);
}

# t/08theme.t
sub subtest_theme {
my ($theme) = @_;
Expand Down Expand Up @@ -253,31 +291,22 @@ sub subtest_length {
# t/24data.t
sub subtest_data {
my ( $theme, $file ) = @_;
my $tb = __PACKAGE__->builder;
$tb->plan( tests => 1 );

SKIP: {
if ( !$file ) {
$tb->skip( "This test needs the source file for $theme", 1 );
last SKIP;
}
open my $fh, $file or do {
$tb->skip( "Can't open $file: $!", 1 );
last SKIP;
};

my ( $fail, $in_data ) = ( 0, 0 );
my @lines;
while (<$fh>) {
$in_data++ if /^__DATA__$/;
next if !$in_data;
$fail++, push @lines, $.
if /^#/ && !/^# ?(?:names(?: +[-\w]+)*|default)\s*$/;
$file = '' if !defined $file;
_check_file_lines(
$theme, $file,
"__DATA__ section for $file",
sub {
my @lines;
my $in_data;
for my $line (@_) {
$in_data++ if $line =~ /^__DATA__$/;
next if !$in_data;
push @lines, $line
if /^#/ && !/^# ?(?:names(?: +[-\w]+)*|default)\s*$/;
}
return @lines;
}
$tb->is_num( $fail, 0, "__DATA__ section for $file" );
$tb->diag("Failed lines: @lines") if @lines;
close $fh;
}
);
}

sub subtest_version {
Expand Down Expand Up @@ -332,6 +361,10 @@ If the C<subtest_load()> test fails, no further test will be run.
The individual tests are run as subtests. All substests but C<subtest_load()>
assume that the module can be successfully loaded.
=head2 subtest_fixme( $theme, $source )
Checks that the theme source file does not contain the word "FIXME".
=head2 subtest_load( $theme )
Tries to load the theme module.
Expand Down
23 changes: 0 additions & 23 deletions t/02fixme.t

This file was deleted.

17 changes: 10 additions & 7 deletions t/12live.t
@@ -1,15 +1,18 @@
use Test::More tests => 3;
use Acme::MetaSyntactic;
use File::Spec::Functions;
my $dir;
BEGIN { $dir = catdir qw( t lib ); }

my $meta = Acme::MetaSyntactic->new( 'coverhack' );
my $meta = Acme::MetaSyntactic->new( 'test_ams_cover' );
eval { my $name = $meta->name; };
like( $@, qr!^Metasyntactic list coverhack does not exist!, "So there!" );
like( $@, qr!^Metasyntactic list test_ams_cover does not exist!, "So there!" );

$meta = Acme::MetaSyntactic->new();
eval { $meta->name( digits => 2 ); };
like( $@, qr!^Metasyntactic list digits does not exist!, "AMS::digits not there yet" );
eval { $meta->name( test_ams_list => 2 ); };
like( $@, qr!^Metasyntactic list test_ams_list does not exist!, "AMS::test_ams_list not there yet" );

push @INC, 't';
eval { $meta->name( digits => 2 ); };
is( $@, '', 'AMS::digits in @INC now' );
push @INC, $dir;
eval { $meta->name( test_ams_list => 2 ); };
is( $@, '', 'AMS::test_ams_list in @INC now' );

0 comments on commit 23a452d

Please sign in to comment.