source: tol/tolbase/lib/markupparser/markupparser.test @ a680983

1941-docker-image-to-testdevel
Last change on this file since a680983 was a680983, checked in by Jorge Pérez <josp.jorge@…>, 15 years ago

refs #1347, hipertext widget extracted from Notebook App

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@3878 be4846ae-f051-483a-831f-b64e7d08527f

  • Property mode set to 100644
File size: 6.3 KB
RevLine 
[a680983]1# -*-Tcl-*-
2#---------------------------------------------------------------------
3# TITLE:
4#       markupparser.test
5#
6# AUTHOR:
7#       Will Duquette
8#
9# DESCRIPTION:
10#       Test cases for markupparser.tcl.  Uses the ::tcltest:: harness.
11
12
13#---------------------------------------------------------------------
14# Load the tcltest package
15
16if {[lsearch [namespace children] ::tcltest] == -1} {
17    package require tcltest
18    namespace import ::tcltest::*
19}
20
21#-----------------------------------------------------------------------
22# Load the markupparser package.
23
24source markupparser.tcl
25namespace import ::markupparser::*
26
27#-----------------------------------------------------------------------
28# Helper routines
29
30proc prettyParse {markup} {
31    set taglist [parse2 $markup]
32
33    set newlist {}
34    foreach {tag value} $taglist {
35        lappend newlist [list $tag $value]
36    }
37
38    return [join $newlist "\n"]
39}
40
41
42
43#-----------------------------------------------------------------------
44# Basic Parsing
45#
46# This section needs a lot of work.
47
48test parsing-1.1 {Normal paragraphs} {} {
49    prettyParse {
50This is a normal paragraph.
51It has two lines.
52
53This is another normal paragraph.
54    }
55
56} {PRE {
57}
58P {: 0 {}}
59TXT {This is a normal paragraph.
60It has two lines.
61}
62/P {}
63PRE {
64}
65P {: 0 {}}
66TXT {This is another normal paragraph.
67    }
68/P {}}
69
70#-----------------------------------------------------------------------
71# Format as Plain Text
72#
73# This section needs a lot of work as well.
74
75test plain-1.1 {normal paragraphs} {
76    formatplain {
77Now is the time for all good men to come to the aid of their country.
78Now is the time for all good men to come to the aid of their country.
79Now is the time for all good men to come to the aid of their country.
80
81Now is the time for all good men to come to the aid of their country.
82Now is the time for all good men to come to the aid of their country.
83Now is the time for all good men to come to the aid of their country.
84    } -length 30
85} {
86Now is the time for all good
87men to come to the aid of
88their country. Now is the time
89for all good men to come to
90the aid of their country. Now
91is the time for all good men
92to come to the aid of their
93country.
94
95Now is the time for all good
96men to come to the aid of
97their country. Now is the time
98for all good men to come to
99the aid of their country. Now
100is the time for all good men
101to come to the aid of their
102country.
103}
104
105test plain-1.2 {bulleted paragraphs} {
106    formatplain {
107Now is the time for all good men to come to the aid of their country.
108* Now is the time for all good men to come to the aid of their country.
109** Now is the time for all good men to come to the aid of their country.
110*** Now is the time for all good men to come to the aid of their country.
111** Now is the time for all good men to come to the aid of their country.
112* Now is the time for all good men to come to the aid of their country.
113Now is the time for all good men to come to the aid of their country.
114    } -length 40
115} {
116Now is the time for all good men to come
117to the aid of their country.
118  * Now is the time for all good men to
119    come to the aid of their country.
120      * Now is the time for all good men
121        to come to the aid of their
122        country.
123          * Now is the time for all good
124            men to come to the aid of
125            their country.
126      * Now is the time for all good men
127        to come to the aid of their
128        country.
129  * Now is the time for all good men to
130    come to the aid of their country.
131    Now is the time for all good men to
132    come to the aid of their country.
133}
134
135test plain-1.2 {indented paragraphs} {
136    formatplain {
137Now is the time for all good men to come to the aid of their country.
138: Now is the time for all good men to come to the aid of their country.
139:: Now is the time for all good men to come to the aid of their country.
140::: Now is the time for all good men to come to the aid of their country.
141:: Now is the time for all good men to come to the aid of their country.
142: Now is the time for all good men to come to the aid of their country.
143Now is the time for all good men to come to the aid of their country.
144    } -length 40
145} {
146Now is the time for all good men to come
147to the aid of their country.
148    Now is the time for all good men to
149    come to the aid of their country.
150        Now is the time for all good men
151        to come to the aid of their
152        country.
153            Now is the time for all good
154            men to come to the aid of
155            their country.
156        Now is the time for all good men
157        to come to the aid of their
158        country.
159    Now is the time for all good men to
160    come to the aid of their country.
161    Now is the time for all good men to
162    come to the aid of their country.
163}
164
165
166
167#-----------------------------------------------------------------------
168# Rename Links in Page
169
170# The essential property here is that ONLY the specified link is
171# changed.  All other markup remains the same.
172test rename-1.1 {Link renamed, otherwise unchanged.} {} {
173    renameLink {
174For this test, we need some of everything in the markup, so that
175we can see that it's rebuilt the same  Here's an [Old Link].
176
177 Here's some
178   indented preformatted text.
179     which contains an [Old Link] that shouldn't be changed.
180*   Bullet 1
181**  Bullet 2 that's on
182    two lines.
183:   Normal indented text
184:: With eccentric leading
185      and multiple lines.
186
187Here's a <b>line</b> with <m>styled</m> <i>text</i>.
188
189Here's a [%Magic|Button%]. Here's a [@macro@].
190
191Here's another [Old Link] to be renamed.
192
193#pre
194Explicitly preformatted
195   Text
196#unpre
197
198And here's some Tcl.
199#Tcl
200proc foo {} { bar}
201#unTcl
202
203And that's it!   
204    } "Old Link" "New Link"
205} {
206For this test, we need some of everything in the markup, so that
207we can see that it's rebuilt the same  Here's an [New Link].
208
209 Here's some
210   indented preformatted text.
211     which contains an [Old Link] that shouldn't be changed.
212*   Bullet 1
213**  Bullet 2 that's on
214    two lines.
215:   Normal indented text
216:: With eccentric leading
217      and multiple lines.
218
219Here's a <b>line</b> with <m>styled</m> <i>text</i>.
220
221Here's a [%Magic|Button%]. Here's a [@macro@].
222
223Here's another [New Link] to be renamed.
224
225#pre
226Explicitly preformatted
227   Text
228#unpre
229
230And here's some Tcl.
231#Tcl
232proc foo {} { bar}
233#unTcl
234
235And that's it!   
236    }
237
238
239
240
241#-----------------------------------------------------------------------
242# Clean up
243
244::tcltest::cleanupTests
245
246
247
248
Note: See TracBrowser for help on using the repository browser.