File: code.t

package info (click to toggle)
libpod-pom-perl 2.01-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 800 kB
  • sloc: perl: 2,756; makefile: 7
file content (85 lines) | stat: -rw-r--r-- 1,524 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/perl -w                                         # -*- perl -*-

use strict;
use lib qw( ./lib ../lib );
use Pod::POM::Test;
use Pod::POM::View::Text;

my $DEBUG = 1;

my $text;
{  local $/ = undef;
   $text = <DATA>;
}

ntests(17);

my ($parser, $podpom, @warn, @warnings);
my ($h1, $code);
my $textview = Pod::POM::View::Text->new();

$parser = Pod::POM->new( );
$podpom = $parser->parse_text( $text );
assert( $podpom );

$h1 = $podpom->head1();
match( scalar @$h1, 3 );
match( $textview->print($h1->[0]->title()), 'NAME' );

$code = $podpom->code();
ok( ! @$code );

$parser = Pod::POM->new( code => 1 );
$podpom = $parser->parse_text( $text );
assert( $podpom );
ok( $parser->{ CODE } == 1 );

$h1 = $podpom->head1();
match( scalar @$h1, 3 );
match( $textview->print($h1->[0]->title()), 'NAME' );

$code = $podpom->code();
ok( defined $code );
match( scalar @$code, 1 );
match( $textview->print($code->[0]->{ text }), "This is some code\n\n" );
match( $code->[0]->{ text }, "This is some code\n\n" );
match( $code->[0], "This is some code\n\n" );

$h1 = $podpom->head1->[1];
assert( $h1 );
$code = $h1->code();
match( scalar @$code, 2 );
match( $textview->print($code->[0]), "Some more code here\n\n" );
match( $textview->print($code->[1]), "even more code\n\n" );


__DATA__
This is some code

=head1 NAME

A test Pod document.

=head1 DESCRIPTION

This document has mixed code/Pod

=cut

Some more code here

=pod

Some more description

=cut

even more code

=head1 SYNOPSIS

    use Blah;

=cut

The end.