Imported Robodoc.
[robodoc.git] / Source / t / latex.t
1 use strict;
2 use warnings;
3 use ROBOTestFrame;
4 use Test::More 'no_plan';
5 use Test::File;
6
7 #****h* ROBODoc System Tests/LaTeX Generator
8 # FUNCTION
9 #   Test ROBODoc LaTeX generator.
10 #
11 #****
12
13
14 #****v* LaTeX Generator/dummy_header_1
15 # FUNCTION
16 #   A dummy header to put into dummy source files.
17 # SOURCE
18 #
19     my $dummy_header_1 = <<'EOF';
20 C     ****f* Lib/Func
21 C     NAME
22 C       Func -- useless
23 C       Computes the value:
24 C        |latex \begin{equation}
25 C        |latex x = 0
26 C        |latex \end{equation}
27 C        app
28 C
29 C     SYNOPSIS
30 C       Func = Func (n)
31 C       Computes the value:
32 C        |latex \begin{equation}
33 C        |latex x = 0
34 C        |latex \end{equation}
35 C     BUGS
36 C       Generates screwy TeX
37 C     ***
38       real function Func(n)
39         Func = 0
40       end function Func
41
42 EOF
43
44 #****
45
46
47 #****v* LaTeX Generator/dummy_header_2
48 # FUNCTION
49 #   A dummy header to put into dummy source files.
50 # SOURCE
51 #
52     my $dummy_header_2 = <<'EOF';
53 C     ****f* Lib/Func
54 C     NAME
55 C       Func -- useless
56 C     SYNOPSIS
57 C       Example:
58 C         Foo foo foo
59 C         foo
60 C
61 C       Test paragraph.
62 C       Do da diddi do da dom dom.
63 C
64 C     BUGS
65 C       A list test:
66 C       * item 1
67 C       * item 2
68 C       * item 3
69 C
70 C     ***
71       real function Func(n)
72         Func = 0
73       end function Func
74
75 EOF
76
77 #****
78
79
80 #****x* LaTeX Generator/latex is balanced
81 # FUNCTION
82 #   This function tests whether a generated latex file is balanced
83 #   or not.  That is every 
84 #     /begin{xxx} 
85 #   should end with a 
86 #     /end{xxx}
87 #   at the same level.
88 #
89 #   This is tested with several headers and in different modes.
90 #
91 # SOURCE
92 {
93     my @sources = ( \$dummy_header_1, \$dummy_header_2 );
94
95     foreach my $source_ref ( @sources ) {
96         foreach my $mode_1 qw( --sections --toc --index ) {
97             foreach my $mode_2 qw( --nopre --altlatex ) {
98                 mkdocdir();
99                 add_source( "test.c", $$source_ref );
100                 my ( $out, $err ) = runrobo(
101                     qw(--src Src
102                     --doc Doc/test
103                     --singledoc
104                     --latex
105                     ), $mode_1, $mode_2 );
106                 # expected results:
107                 is( $out, '', 'No ouput' );
108                 is( $err, '', '... and no error' );
109                 file_exists_ok( "Doc/test.tex", 'there should be documentation' );
110                 is( is_latex_balanced( "Doc/test.tex" ), 1, 'latex is balanced' );
111                 clean();
112             }
113         }
114     }
115 }
116 #****
117