File: doc_gen.test

package info (click to toggle)
tcllib 2.0%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 83,560 kB
  • sloc: tcl: 306,798; ansic: 14,272; sh: 3,035; xml: 1,766; yacc: 1,157; pascal: 881; makefile: 124; perl: 84; f90: 84; python: 33; ruby: 13; php: 11
file content (150 lines) | stat: -rw-r--r-- 6,662 bytes parent folder | download | duplicates (2)
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
##########################################################################
# TEPAM - Tcl's Enhanced Procedure and Argument Manager
##########################################################################
#
# doc_gen.test: 
# This file is part of the TEPAM Doc Gen's regression test. It validates 
# the generate and patch commands
#
# Copyright (C) 2013 Andreas Drollinger
# 
# Id: doc_gen.test
##########################################################################
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
##########################################################################

source [file join \
   [file dirname [file dirname [file join [pwd] [info script]]]] \
   devtools testutilities.tcl]

testsNeedTcl     8.5
testsNeedTcltest 1.0

catch {namespace delete ::tepam::doc_gen}
catch {namespace delete ::tepam}
testing {
   useLocal tepam.tcl tepam
   useLocal tepam_doc_gen.tcl tepam::doc_gen
}

set Dir test_doc_dir

makeDirectory $Dir

######## Declare the test procedures ########

   tepam::procedure {display message} {
      -return            -
      -short_description "Displays a simple message box"
      -description       "This procedure allows displaying a configurable message box. It supports the following message types:
                          * Info
                          * Warning
                          * Error
                          Font, foreground and background colors are free selectable.
                          Optionally, all messages can be logged in a log file."
      -args {
         {-mtype -default Warning -choices {Info Warning Error} -description "M. type"}
         {-font -type font -default {Arial 10 italic} -description "Message font"}
         {-level -type integer -optional -range {1 10} -description "Message level"}
         {-fg -type color -default black -description "Message color"}
         {-bg -type color -optional -description "Background color"}
         {-no_border -type none -description "Use a splash window style (no border)"}
         {-log_file -type file -optional -description "Optional message log file"}
         {text -type string -multiple -description "Multiple text lines to display"}
      }
      -example {
         display message "The document hasn't yet been saved!"
         display message -fg red -bg black "Please save first the document"
      }
   } {
      puts "display message:"
      foreach var {mtype font level fg bg no_border log_file text} {
         if {[info exists $var]} {
            puts  "  $var=[set $var]"
         }
      }
   }

   tepam::procedure {display status} {
      -return            -
      -short_description "Displays the program status"
      -args {
         {-font -type font -default {Arial 10 italic} -description "Message font"}
         {-log_file -type file -optional -description "Optional message log file"}
         {text -type string -multiple -description "Multiple text lines to display"}
      }
      -example {
         display status "The program is in a critical state!"
      }
   } {
      puts "display status:"
      foreach var {font log_file text} {
         if {[info exists $var]} {
            puts  "  $var=[set $var]"
         }
      }
   }
   

######## Generate: Generate all formats ########

   # Generate all documentation, do not check the validity of the generated doc at this location
      foreach Format {TXT POD HTML DT} {

         if {$Format=="DT"} {
            set DocStructureRegexp(display_message) {.*\[section "Arguments"\].*\[section "Example"\].*}
            set DocStructureRegexp(display) {.*\[section "Example"\].*}
         } else {
            set DocStructureRegexp(display_message) {.*Name.*Synopsis.*Description.*Arguments.*Example.*}
            set DocStructureRegexp(display) {.*Name.*Synopsis.*Description.*Example.*}
            if {$Format=="TXT" || $Format=="POD"} {
               set DocStructureRegexp(display_message) [string toupper $DocStructureRegexp(display_message)]
               set DocStructureRegexp(display) [string toupper $DocStructureRegexp(display)]
            }
         }
      
         test tepam::doc_gen.nhf.all.$Format "tepam::doc_gen::generate, procedure with sub-procedures, no h/f, $Format" \
                  -body {set Doc(nhf,display,$Format) [tepam::doc_gen::generate -format $Format display]} \
                  -result $DocStructureRegexp(display) \
                  -output "" -match regexp

         test tepam::doc_gen.nhf.single.$Format "tepam::doc_gen::generate, procedure without sub-procedures, no h/f, $Format" \
                  -body {set Doc(nhf,display_message,$Format) [tepam::doc_gen::generate -format $Format {display message}]} \
                  -result $DocStructureRegexp(display_message) \
                  -output "" -match regexp

         test tepam::doc_gen.hf.all.$Format "tepam::doc_gen::generate, procedure with sub-procedures, with h/f, $Format" \
                  -body {set Doc(hf,display,$Format) [tepam::doc_gen::generate -format $Format -header_footer display]} \
                  -result $DocStructureRegexp(display) \
                  -output "" -match regexp

         test tepam::doc_gen.hf.single.$Format "tepam::doc_gen::generate, procedure without sub-procedures, with h/f, $Format" \
                  -body {set Doc(hf,display_message,$Format) [tepam::doc_gen::generate -format $Format -header_footer {display message}]} \
                  -result $DocStructureRegexp(display_message) \
                  -output "" -match regexp

         test tepam::doc_gen.file.all.$Format "tepam::doc_gen::generate, procedure with sub-procedures, safed in file, $Format" \
                  -body {tepam::doc_gen::generate -dest_file $Dir/display__hf.$Format -format $Format -header_footer display} \
                  -result "$Dir/display__hf.$Format" -output ""

         test tepam::doc_gen.file.single.$Format "tepam::doc_gen::generate, procedure without sub-procedures, safed in file, $Format" \
                  -body {tepam::doc_gen::generate -dest_file $Dir/display_message__hf.$Format -format $Format -header_footer {display message}} \
                  -result "$Dir/display_message__hf.$Format" -output ""
   }

######## Check the documentation content ########


######## That's all ########

::tcltest::cleanupTests
return

##########################################################################
# Id: doc_gen.test
# Modifications:
#
# Revision 1.1  2013/10/14 droll
# * Initial checkin
##########################################################################