| [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 | |
|---|
| 16 | if {[lsearch [namespace children] ::tcltest] == -1} { |
|---|
| 17 | package require tcltest |
|---|
| 18 | namespace import ::tcltest::* |
|---|
| 19 | } |
|---|
| 20 | |
|---|
| 21 | #----------------------------------------------------------------------- |
|---|
| 22 | # Load the markupparser package. |
|---|
| 23 | |
|---|
| 24 | source markupparser.tcl |
|---|
| 25 | namespace import ::markupparser::* |
|---|
| 26 | |
|---|
| 27 | #----------------------------------------------------------------------- |
|---|
| 28 | # Helper routines |
|---|
| 29 | |
|---|
| 30 | proc 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 | |
|---|
| 48 | test parsing-1.1 {Normal paragraphs} {} { |
|---|
| 49 | prettyParse { |
|---|
| 50 | This is a normal paragraph. |
|---|
| 51 | It has two lines. |
|---|
| 52 | |
|---|
| 53 | This is another normal paragraph. |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | } {PRE { |
|---|
| 57 | } |
|---|
| 58 | P {: 0 {}} |
|---|
| 59 | TXT {This is a normal paragraph. |
|---|
| 60 | It has two lines. |
|---|
| 61 | } |
|---|
| 62 | /P {} |
|---|
| 63 | PRE { |
|---|
| 64 | } |
|---|
| 65 | P {: 0 {}} |
|---|
| 66 | TXT {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 | |
|---|
| 75 | test plain-1.1 {normal paragraphs} { |
|---|
| 76 | formatplain { |
|---|
| 77 | Now is the time for all good men to come to the aid of their country. |
|---|
| 78 | Now is the time for all good men to come to the aid of their country. |
|---|
| 79 | Now is the time for all good men to come to the aid of their country. |
|---|
| 80 | |
|---|
| 81 | Now is the time for all good men to come to the aid of their country. |
|---|
| 82 | Now is the time for all good men to come to the aid of their country. |
|---|
| 83 | Now is the time for all good men to come to the aid of their country. |
|---|
| 84 | } -length 30 |
|---|
| 85 | } { |
|---|
| 86 | Now is the time for all good |
|---|
| 87 | men to come to the aid of |
|---|
| 88 | their country. Now is the time |
|---|
| 89 | for all good men to come to |
|---|
| 90 | the aid of their country. Now |
|---|
| 91 | is the time for all good men |
|---|
| 92 | to come to the aid of their |
|---|
| 93 | country. |
|---|
| 94 | |
|---|
| 95 | Now is the time for all good |
|---|
| 96 | men to come to the aid of |
|---|
| 97 | their country. Now is the time |
|---|
| 98 | for all good men to come to |
|---|
| 99 | the aid of their country. Now |
|---|
| 100 | is the time for all good men |
|---|
| 101 | to come to the aid of their |
|---|
| 102 | country. |
|---|
| 103 | } |
|---|
| 104 | |
|---|
| 105 | test plain-1.2 {bulleted paragraphs} { |
|---|
| 106 | formatplain { |
|---|
| 107 | Now 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. |
|---|
| 113 | Now is the time for all good men to come to the aid of their country. |
|---|
| 114 | } -length 40 |
|---|
| 115 | } { |
|---|
| 116 | Now is the time for all good men to come |
|---|
| 117 | to 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 | |
|---|
| 135 | test plain-1.2 {indented paragraphs} { |
|---|
| 136 | formatplain { |
|---|
| 137 | Now 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. |
|---|
| 143 | Now is the time for all good men to come to the aid of their country. |
|---|
| 144 | } -length 40 |
|---|
| 145 | } { |
|---|
| 146 | Now is the time for all good men to come |
|---|
| 147 | to 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. |
|---|
| 172 | test rename-1.1 {Link renamed, otherwise unchanged.} {} { |
|---|
| 173 | renameLink { |
|---|
| 174 | For this test, we need some of everything in the markup, so that |
|---|
| 175 | we 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 | |
|---|
| 187 | Here's a <b>line</b> with <m>styled</m> <i>text</i>. |
|---|
| 188 | |
|---|
| 189 | Here's a [%Magic|Button%]. Here's a [@macro@]. |
|---|
| 190 | |
|---|
| 191 | Here's another [Old Link] to be renamed. |
|---|
| 192 | |
|---|
| 193 | #pre |
|---|
| 194 | Explicitly preformatted |
|---|
| 195 | Text |
|---|
| 196 | #unpre |
|---|
| 197 | |
|---|
| 198 | And here's some Tcl. |
|---|
| 199 | #Tcl |
|---|
| 200 | proc foo {} { bar} |
|---|
| 201 | #unTcl |
|---|
| 202 | |
|---|
| 203 | And that's it! |
|---|
| 204 | } "Old Link" "New Link" |
|---|
| 205 | } { |
|---|
| 206 | For this test, we need some of everything in the markup, so that |
|---|
| 207 | we 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 | |
|---|
| 219 | Here's a <b>line</b> with <m>styled</m> <i>text</i>. |
|---|
| 220 | |
|---|
| 221 | Here's a [%Magic|Button%]. Here's a [@macro@]. |
|---|
| 222 | |
|---|
| 223 | Here's another [New Link] to be renamed. |
|---|
| 224 | |
|---|
| 225 | #pre |
|---|
| 226 | Explicitly preformatted |
|---|
| 227 | Text |
|---|
| 228 | #unpre |
|---|
| 229 | |
|---|
| 230 | And here's some Tcl. |
|---|
| 231 | #Tcl |
|---|
| 232 | proc foo {} { bar} |
|---|
| 233 | #unTcl |
|---|
| 234 | |
|---|
| 235 | And that's it! |
|---|
| 236 | } |
|---|
| 237 | |
|---|
| 238 | |
|---|
| 239 | |
|---|
| 240 | |
|---|
| 241 | #----------------------------------------------------------------------- |
|---|
| 242 | # Clean up |
|---|
| 243 | |
|---|
| 244 | ::tcltest::cleanupTests |
|---|
| 245 | |
|---|
| 246 | |
|---|
| 247 | |
|---|
| 248 | |
|---|