Imported Robodoc.
[robodoc.git] / Source / t / ascii.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/ASCII Generator
8 # FUNCTION
9 #   Test ROBODoc ASCII generator.
10 #
11 #****
12
13
14 #****v* ASCII 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* ASCII 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* ASCII Generator/smoke test
81 # FUNCTION
82 #   Try different combination of options.
83 #   This should not cause any asserts().
84 #
85 # SOURCE
86 {
87     my @sources = ( \$dummy_header_1, \$dummy_header_2 );
88
89     foreach my $source_ref ( @sources ) {
90         foreach my $mode_1 qw( --sections --toc --index --nopre ) {
91             foreach my $mode_2 qw( --singledoc --multidoc ) {
92                 mkdocdir();
93                 add_source( "test.c", $$source_ref );
94                 my ( $out, $err ) = runrobo(
95                     qw(--src Src
96                     --doc Doc/test
97                     --ascii
98                     ), $mode_1, $mode_2 );
99                 # expected results:
100                 is( $out, '', 'No ouput' );
101                 is( $err, '', '... and no error' );
102                 my $file_name;
103                 # Docments names differ for the different
104                 # modes.
105                 if ( $mode_2 eq "--multidoc" ) {
106                     $file_name = "Doc/test/test_c.txt";
107                 } else {
108                     $file_name = "Doc/test.txt";
109                 }
110                 file_exists_ok( $file_name, 
111                     'there should be documentation' );
112                 clean();
113             }
114         }
115     }
116 }
117 #****
118