Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: book/Acme-MetaSyntactic
base: 11c480cb1b
...
head fork: book/Acme-MetaSyntactic
compare: d3c722f915
Checking mergeability… Don't worry, you can still create the pull request.
  • 6 commits
  • 7 files changed
  • 0 commit comments
  • 1 contributor
View
48 lib/Test/MetaSyntactic.pm
@@ -30,13 +30,14 @@ sub theme_ok {
$tb->subtest(
$theme,
sub {
- $tb->subtest( "load $theme", sub { subtest_load(@args); } );
- $tb->subtest( "format $theme", sub { subtest_format(@args); } );
- $tb->subtest( "uniq $theme", sub { subtest_uniq(@args); } );
- $tb->subtest( "length $theme", sub { subtest_length(@args); } );
- $tb->subtest( "data $theme", sub { subtest_data(@args); } );
- $tb->subtest( "import $theme", sub { subtest_import(@args); } );
- $tb->subtest( "theme $theme", sub { subtest_theme(@args); } );
+ $tb->subtest( "load $theme", sub { subtest_load(@args); } );
+ $tb->subtest( "format $theme", sub { subtest_format(@args); } );
+ $tb->subtest( "uniq $theme", sub { subtest_uniq(@args); } );
+ $tb->subtest( "length $theme", sub { subtest_length(@args); } );
+ $tb->subtest( "data $theme", sub { subtest_data(@args); } );
+ $tb->subtest( "import $theme", sub { subtest_import(@args); } );
+ $tb->subtest( "noimport $theme", sub { subtest_noimport(@args); } );
+ $tb->subtest( "theme $theme", sub { subtest_theme(@args); } );
$tb->done_testing;
}
);
@@ -134,13 +135,20 @@ sub subtest_theme {
sub subtest_import {
my ($theme) = @_;
my $tb = __PACKAGE__->builder;
- $tb->plan( tests => 1 );
+ $tb->plan( tests => 2 );
if( $theme =~ /^(?:any|random)$/) {
- $tb->skip( "Not testing import for theme $theme", 1 );
+ $tb->skip( "Not testing import for theme $theme" );
+ $tb->skip( "Not testing import for theme $theme" );
}
else {
my %seen = map { $_ => 1 } _theme_items( $theme );
+
+ no strict 'refs';
+ $tb->ok( exists ${"Test::MetaSyntactic::SCRATCH\::"}{"meta$theme"},
+ "meta$theme exported"
+ );
+
package Test::MetaSyntactic::SCRATCH;
no strict 'refs';
my @names = "meta$theme"->();
@@ -148,6 +156,20 @@ sub subtest_import {
}
}
+# t/18import.t
+sub subtest_noimport {
+ my ($theme) = @_;
+ my $tb = __PACKAGE__->builder;
+ $tb->plan( tests => 1 );
+
+ eval "package Test::MetaSyntactic::EMPTY; use Acme::MetaSyntactic::$theme (); 1;"
+ or __PACKAGE__->builder->diag("$theme $@");
+
+ # meta$theme should not exist
+ eval "package Test::MetaSyntatic::EMPTY; meta$theme(1);";
+ $tb->ok( $@ =~ /^Undefined subroutine &Test::MetaSyntatic::EMPTY::meta$theme called/, "meta$theme function not exported" );
+}
+
# t/21format.t
sub subtest_format {
my ($theme) = @_;
@@ -305,7 +327,13 @@ properly formatted.
=head2 subtest_import( $theme )
-Checks that the exported C<meta$theme> function returns an item from C<$theme>.
+Checks that the exported C<meta$theme> function returns an item from
+C<$theme>.
+
+=head2 subtest_noimport( $theme )
+
+Checks that C<use Acme::MetaSyntactic::I<$theme> ()> does not export
+the C<meta$theme> function.
=head2 subtest_theme( $theme )
View
2  t/11namespace.t
@@ -1,5 +1,5 @@
use Test::More tests => 1;
-use Acme::MetaSyntactic::donmartin;
+use Acme::MetaSyntactic::summerwine;
# check that metaname is not exported into Acme::MetaSyntactic::List
ok(
View
4 t/12fail.t
@@ -1,7 +1,7 @@
use Test::More tests => 1;
require Acme::MetaSyntactic;
-eval { import Acme::MetaSyntactic 'xyzzy'; };
-like( $@, qr!^Can't locate Acme/MetaSyntactic/xyzzy.pm in \@INC!,
+eval { import Acme::MetaSyntactic 'this_theme_does_not_exist'; };
+like( $@, qr!^Can't locate Acme/MetaSyntactic/this_theme_does_not_exist.pm in \@INC!,
"No such theme");
View
18 t/15func2.t
@@ -1,18 +0,0 @@
-use Test::More;
-use strict;
-use Acme::MetaSyntactic::batman;
-
-plan tests => 2;
-
-# the default list
-no warnings;
-my @names = metabatman();
-my %seen = map { $_ => 1 } @Acme::MetaSyntactic::batman::List;
-ok( exists $seen{$names[0]}, "metabatman" );
-
-is_deeply(
- [ sort grep { /^meta\w+$/ } keys %:: ],
- [qw( metabatman )],
- "Default exported function"
-);
-
View
4 t/16import.t
@@ -1,11 +1,11 @@
use Test::More;
use strict;
-use Acme::MetaSyntactic 'batman';
+use Acme::MetaSyntactic 'summerwine';
plan tests => 4;
my @names = metaname();
-my %seen = map { $_ => 1 } @Acme::MetaSyntactic::batman::List;
+my %seen = map { $_ => 1 } @Acme::MetaSyntactic::summerwine::List;
ok( exists $seen{$names[0]}, "metaname" );
my @bots = qw( purl url sarko bender );
View
19 t/18import.t
@@ -1,19 +0,0 @@
-use Test::More tests => 2;
-use Acme::MetaSyntactic::batman ();
-use Acme::MetaSyntactic::haddock ();
-
-# metabatman should not exist
-eval { metabatman(1) };
-like(
- $@,
- qr/^Undefined subroutine &main::metabatman called/,
- "Function not exported"
-);
-
-# metahaddock should not exist
-eval { metahaddock(1) };
-like(
- $@,
- qr/^Undefined subroutine &main::metahaddock called/,
- "Function not exported"
-);
View
12 t/20theme.t
@@ -12,12 +12,12 @@ my @themes = Acme::MetaSyntactic->themes;
# try has_theme
ok( !Acme::MetaSyntactic->has_theme( ), "has no theme?" );
-ok( Acme::MetaSyntactic->has_theme( 'batman' ), "has batman" );
-ok( ! Acme::MetaSyntactic->has_theme( 'bots' ), "but no nbots" );
+ok( Acme::MetaSyntactic->has_theme( 'summerwine' ), "has summerwine" );
+ok( ! Acme::MetaSyntactic->has_theme( 'bots' ), "but no bots" );
# try to overwrite a theme
-eval { Acme::MetaSyntactic->add_theme( batman => [ @bots ] ); };
-like( $@, qr/^The theme batman already exists!/, "Do not overwrite a theme" );
+eval { Acme::MetaSyntactic->add_theme( summerwine => [ @bots ] ); };
+like( $@, qr/^The theme summerwine already exists!/, "Do not overwrite a theme" );
# try badnames
eval { Acme::MetaSyntactic->add_theme( zlonk => [ qw( 123 bam $c ) ] ); };
@@ -38,12 +38,12 @@ my %seen = map { $_ => 1 } @names;
is_deeply( \%seen, { map { $_ => 1 } @bots }, "Got the whole list");
# the new method exists
-$meta = Acme::MetaSyntactic->new( 'batman' );
+$meta = Acme::MetaSyntactic->new( 'summerwine' );
@names = $meta->name( bots => 2 );
ok( exists( $seen{$_} ), "the name() method accepts bots" ) for @names;
# and the new function exists as well
-$meta = Acme::MetaSyntactic->new( 'batman' );
+$meta = Acme::MetaSyntactic->new( 'summerwine' );
@names = metabots( 2 );
ok( exists( $seen{$_} ), "the metabots() function" ) for @names;

No commit comments for this range

Something went wrong with that request. Please try again.