Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 10th, 2012  |  syntax: None  |  size: 0.66 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/env perl
  2.  
  3. use strict;
  4. use warnings;
  5. # FILENAME: sub_main_is_not_package.t
  6. # CREATED: 02/07/12 23:07:28 by Kent Fredric (kentnl) <kentfredric@gmail.com>
  7. # ABSTRACT: A weird bug with module::metadata
  8.  
  9. use Test::More;
  10. use Module::Metadata;
  11.  
  12. my $data = <<'__EOD__';
  13.  
  14. use strict;
  15. use warnings;
  16.  
  17. package Example;
  18.  
  19. sub main {
  20.     return 1;
  21. }
  22.  
  23. sub other {
  24.     return 1;
  25. }
  26.  
  27. 1;
  28.  
  29. __EOD__
  30.  
  31. use IO::String;
  32.  
  33. my $fh  = IO::String->new( $data );
  34. my $mm = Module::Metadata->new_from_handle( $fh , 'lib/Example.pm', collect_pod => 0 );
  35.  
  36. is_deeply( [ sort $mm->packages_inside() ], [ 'Example' ] , 'Should only return \'Example\'') or
  37.     note explain $mm;
  38.  
  39. done_testing;