Skip to content

Instantly share code, notes, and snippets.

@kentfredric
Created February 7, 2012 10:14
Show Gist options
  • Save kentfredric/1758943 to your computer and use it in GitHub Desktop.
Save kentfredric/1758943 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
# FILENAME: sub_main_is_not_package.t
# CREATED: 02/07/12 23:07:28 by Kent Fredric (kentnl) <kentfredric@gmail.com>
# ABSTRACT: A weird bug with module::metadata
use Test::More;
use Module::Metadata;
my $data = <<'__EOD__';
use strict;
use warnings;
package Example;
sub main {
return 1;
}
sub other {
return 1;
}
1;
__EOD__
use IO::String;
my $fh = IO::String->new( $data );
my $mm = Module::Metadata->new_from_handle( $fh , 'lib/Example.pm', collect_pod => 0 );
is_deeply( [ sort $mm->packages_inside() ], [ 'Example' ] , 'Should only return \'Example\'') or
note explain $mm;
done_testing;
not ok 1 - Should only return 'Example'
# Failed test 'Should only return 'Example''
# at sub_main_is_not_package.t line 36.
# Structures begin differing at:
# $got->[1] = 'main'
# $expected->[1] = Does not exist
# bless( {
# 'collect_pod' => 0,
# 'filename' => '/tmp/lib/Example.pm',
# 'inc' => undef,
# 'module' => 'Example',
# 'packages' => [
# 'main',
# 'Example'
# ],
# 'pod' => {},
# 'pod_headings' => [],
# 'version' => undef,
# 'versions' => {
# 'Example' => undef,
# 'main' => ''
# }
# }, 'Module::Metadata' )
1..1
# Looks like you failed 1 test of 1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment