Fixed `$metadata->contains_pod`. Because $#x is -1 origin.
[p5sagit/Module-Metadata.git] / t / contains_pod.t
diff --git a/t/contains_pod.t b/t/contains_pod.t
new file mode 100644 (file)
index 0000000..3edfe43
--- /dev/null
@@ -0,0 +1,49 @@
+use strict;
+use warnings;
+use Test::More tests => 3;
+use Module::Metadata;
+
+{
+    my $src = <<'...';
+package Foo;
+1;
+...
+
+    open my $fh, '<', \$src;
+    my $module = Module::Metadata->new_from_handle($fh, 'Foo.pm');
+    ok(!$module->contains_pod(), 'This module does not contains POD');
+}
+
+{
+    my $src = <<'...';
+package Foo;
+1;
+
+=head1 NAME
+
+Foo - bar
+...
+
+    open my $fh, '<', \$src;
+    my $module = Module::Metadata->new_from_handle($fh, 'Foo.pm');
+    ok($module->contains_pod(), 'This module contains POD');
+}
+
+{
+    my $src = <<'...';
+package Foo;
+1;
+
+=head1 NAME
+
+Foo - bar
+
+=head1 AUTHORS
+
+Tokuhiro Matsuno
+...
+
+    open my $fh, '<', \$src;
+    my $module = Module::Metadata->new_from_handle($fh, 'Foo.pm');
+    ok($module->contains_pod(), 'This module contains POD');
+}