Skip to content

Commit 2fcee5a

Browse files
committed
todo test for PPI::Normal->register to prevent duplicate registrations
1 parent 97943c3 commit 2fcee5a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

t/09_normal.t

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# (only very basic at this point)
55

66
use t::lib::PPI::Test::pragmas;
7-
use Test::More tests => 13 + ($ENV{AUTHOR_TESTING} ? 1 : 0);
7+
use Test::More tests => 17 + ($ENV{AUTHOR_TESTING} ? 1 : 0);
88

99
use File::Spec::Functions ':ALL';
1010
use PPI;
@@ -51,3 +51,13 @@ SCOPE: {
5151
is( $Normal1->equal( $Normal2 ), 1, '->equal returns true for equivalent code' );
5252
is( $Normal1->equal( $Normal3 ), '', '->equal returns false for different code' );
5353
}
54+
55+
NO_DOUBLE_REG: {
56+
sub just_a_test_sub { "meep" }
57+
ok( PPI::Normal->register( "main::just_a_test_sub", 2 ), "can add subs" );
58+
is $PPI::Normal::LAYER{2}[-1], "main::just_a_test_sub", "and find subs at right layer";
59+
my $size = @{ $PPI::Normal::LAYER{2} };
60+
ok( PPI::Normal->register( "main::just_a_test_sub", 2 ), "can add subs again" );
61+
local $TODO = 'prevent duplicate registrations of normals';
62+
is scalar @{ $PPI::Normal::LAYER{2} }, $size, "but sub isn't added twice";
63+
}

0 commit comments

Comments
 (0)