Imported Robodoc.
[robodoc.git] / Source / t / items.t
1 #!perl
2 # vi: spell ff=unix
3 use strict;
4 use warnings;
5 use ROBOTestFrame;
6 use Test::More 'no_plan';
7
8 #****h* ROBODoc System Tests/Item Test
9 # FUNCTION
10 #   Tests the parsing generation of ROBODoc items.
11 #
12 #*****
13
14 #****x* Item Test/Sorting
15 # FUNCTION
16 #   Lets see if we can get items sorted according
17 #   to the order specified in a robodoc.rc file.
18 #
19 # SOURCE
20 #
21 {
22     my $source = <<'EOF';
23 /****f* Test/test
24  * FIRST
25  *   Test 1
26  * Second
27  *   Test 2
28  * THIRD
29  *   Test 3
30  * SOURCE
31  */
32
33   Test 4
34
35  /*******/
36 EOF
37
38     my $config = <<'EOF';
39 items:
40     FIRST
41     Second
42     THIRD
43     FOURTH
44 item order:
45     SOURCE
46     THIRD
47 EOF
48
49     my $config_no_sort = <<'EOF';
50 items:
51     FIRST
52     Second
53     THIRD
54     FOURTH
55 EOF
56
57     add_source( "test.c", $source );
58     add_configuration( "robodoc.rc", $config );
59     my ($out, $err) = runrobo( qw(
60         --src Src
61         --doc Doc --multidoc --ascii
62         --rc Config/robodoc.rc
63     ) );
64     is( $out, '', 'no output' );
65     is( $err, '', 'and no error' );
66     my $documentation = IO::File->new( "<Doc/test_c.txt" );
67     ok( $documentation, 'There is a doc file' );
68     my @items = ();
69     while ( my $line = <$documentation> ) {
70         if ( $line =~ m/(SOURCE|THIRD|Second|FIRST)/ ) {
71             push( @items, $1 );
72         }
73     }
74     is( $items[ 0 ], 'SOURCE', 'First item it the source item' );
75     is( $items[ 1 ], 'THIRD',  'Second item it the third item' );
76     is( $items[ 2 ], 'FIRST',  'Third item it the first item' );
77     $documentation->close();
78
79     # Now the same but without sorting
80     add_configuration( "robodoc.rc", $config_no_sort );
81     my ($out2, $err2) = runrobo( qw(
82         --src Src
83         --doc Doc --multidoc --ascii
84         --rc Config/robodoc.rc
85     ) );
86     is( $out2, '', 'no output' );
87     is( $err2, '', 'and no error' );
88
89     $documentation = IO::File->new( "<Doc/test_c.txt" );
90     ok( $documentation, 'There is a doc file' );
91     @items = ();
92     while ( my $line = <$documentation> ) {
93         if ( $line =~ m/(SOURCE|THIRD|Second|FIRST)/ ) {
94             push( @items, $1 );
95         }
96     }
97     is( $items[ 0 ], 'FIRST',  'First item it the first item' );
98     is( $items[ 1 ], 'Second', 'Second item it the second item' );
99     is( $items[ 2 ], 'THIRD',  'Third item it the third item' );
100     is( $items[ 3 ], 'SOURCE', 'Fourth item it the fourth' );
101     $documentation->close();
102
103     clean();
104 }
105 #*******
106
107