Fossil SCM
Collected orthogonal tests in test/th1.test so they run inside a single child process instead of needing a separate spawn per. Even on Linux, where this is ultra-fast, it cuts a second off the total run time for this piece of the test suite. Under ASAN, it can cut multiple seconds off the test run.
Commit
7bda23362a63c21e304071ad492e446e54678e0d81ef9cec5edf8ede14c47a1a
Parent
250e1b140df3c3f…
1 file changed
+319
-880
+319
-880
| --- test/th1.test | ||
| +++ test/th1.test | ||
| @@ -23,29 +23,59 @@ | ||
| 23 | 23 | ############################################################################### |
| 24 | 24 | |
| 25 | 25 | set th1Tcl [is_tcl_usable_by_fossil] |
| 26 | 26 | set th1Hooks [are_th1_hooks_usable_by_fossil] |
| 27 | 27 | |
| 28 | -############################################################################### | |
| 29 | - | |
| 30 | -fossil test-th-eval --open-config "setting abc" | |
| 31 | -test th1-setting-1 {$RESULT eq ""} | |
| 28 | +# Evaluate TH1 case triples {name body expected ...}. catch restores the | |
| 29 | +# TH_ERROR: prefix that test-th-eval prints for a top-level error. | |
| 30 | +# | |
| 31 | +proc th1_cases {args} { | |
| 32 | + set opts {} | |
| 33 | + while {[llength $args] > 0 && [string match -* [lindex $args 0]]} { | |
| 34 | + lappend opts [lindex $args 0] | |
| 35 | + set args [lrange $args 1 end] | |
| 36 | + } | |
| 37 | + if {[llength $args] != 1} { | |
| 38 | + error "th1_cases ?options? {name body expected ...}" | |
| 39 | + } | |
| 40 | + set cases [lindex $args 0] | |
| 41 | + if {[llength $cases] % 3} { | |
| 42 | + error "th1_cases: cases must be name body expected triples" | |
| 43 | + } | |
| 44 | + set script "set out {}\n" | |
| 45 | + set names {} | |
| 46 | + set expecteds {} | |
| 47 | + foreach {name body expected} $cases { | |
| 48 | + lappend names $name | |
| 49 | + lappend expecteds $expected | |
| 50 | + append script "set rc \[catch [list $body] msg\]\n" | |
| 51 | + append script "if {\$rc} {\n" | |
| 52 | + append script " lappend out \"TH_ERROR: \$msg\"\n" | |
| 53 | + append script "} else {\n" | |
| 54 | + append script " lappend out \$msg\n" | |
| 55 | + append script "}\n" | |
| 56 | + } | |
| 57 | + append script "set out" | |
| 58 | + fossil test-th-eval {*}$opts $script | |
| 59 | + set results [normalize_result] | |
| 60 | + if {[llength $results] != [llength $names]} { | |
| 61 | + test [lindex $names 0] {0} | |
| 62 | + return | |
| 63 | + } | |
| 64 | + foreach name $names expected $expecteds actual $results { | |
| 65 | + test_eq $name $actual $expected | |
| 66 | + } | |
| 67 | +} | |
| 32 | 68 | |
| 33 | 69 | ############################################################################### |
| 34 | 70 | |
| 35 | -fossil test-th-eval --open-config "setting -- abc" | |
| 36 | -test th1-setting-2 {$RESULT eq ""} | |
| 37 | - | |
| 38 | -############################################################################### | |
| 39 | - | |
| 40 | -fossil test-th-eval --open-config "setting -strict abc" | |
| 41 | -test th1-setting-3 {$RESULT eq {TH_ERROR: no value for setting "abc"}} | |
| 42 | - | |
| 43 | -############################################################################### | |
| 44 | - | |
| 45 | -fossil test-th-eval --open-config "setting -strict -- abc" | |
| 46 | -test th1-setting-4 {$RESULT eq {TH_ERROR: no value for setting "abc"}} | |
| 71 | +th1_cases --open-config { | |
| 72 | + th1-setting-1 {setting abc} {} | |
| 73 | + th1-setting-2 {setting -- abc} {} | |
| 74 | + th1-setting-3 {setting -strict abc} {TH_ERROR: no value for setting "abc"} | |
| 75 | + th1-setting-4 {setting -strict -- abc} {TH_ERROR: no value for setting "abc"} | |
| 76 | +} | |
| 47 | 77 | |
| 48 | 78 | ############################################################################### |
| 49 | 79 | |
| 50 | 80 | fossil test-th-eval --open-config "setting autosync" |
| 51 | 81 | test th1-setting-5 {$RESULT eq 0 || $RESULT eq 1 || $RESULT eq "on"} |
| @@ -55,71 +85,31 @@ | ||
| 55 | 85 | fossil test-th-eval --open-config "setting -strict autosync" |
| 56 | 86 | test th1-setting-6 {$RESULT eq 0 || $RESULT eq 1 || $RESULT eq "on"} |
| 57 | 87 | |
| 58 | 88 | ############################################################################### |
| 59 | 89 | |
| 60 | -fossil test-th-eval --open-config "setting --" | |
| 61 | -test th1-setting-7 {$RESULT eq \ | |
| 62 | -{TH_ERROR: wrong # args: should be "setting ?-strict? ?--? name"}} | |
| 63 | - | |
| 64 | -############################################################################### | |
| 65 | - | |
| 66 | -fossil test-th-eval --open-config "setting -strict --" | |
| 67 | -test th1-setting-8 {$RESULT eq \ | |
| 68 | -{TH_ERROR: wrong # args: should be "setting ?-strict? ?--? name"}} | |
| 69 | - | |
| 70 | -############################################################################### | |
| 71 | - | |
| 72 | -fossil test-th-eval --open-config "setting -- --" | |
| 73 | -test th1-setting-9 {$RESULT eq {}} | |
| 74 | - | |
| 75 | -############################################################################### | |
| 76 | - | |
| 77 | -fossil test-th-eval --open-config "setting -strict -- --" | |
| 78 | -test th1-setting-10 {$RESULT eq {TH_ERROR: no value for setting "--"}} | |
| 79 | - | |
| 80 | -############################################################################### | |
| 81 | - | |
| 82 | -fossil test-th-eval "expr 42/0" | |
| 83 | -test th1-divide-by-zero-1 {$RESULT eq {TH_ERROR: Divide by 0: 42}} | |
| 84 | - | |
| 85 | -############################################################################### | |
| 86 | - | |
| 87 | -fossil test-th-eval "expr 42/0.0" | |
| 88 | -test th1-divide-by-zero-2 {$RESULT eq {TH_ERROR: Divide by 0: 42}} | |
| 89 | - | |
| 90 | -############################################################################### | |
| 91 | - | |
| 92 | -fossil test-th-eval "expr 42.0/0" | |
| 93 | -test th1-divide-by-zero-3 {$RESULT eq {TH_ERROR: Divide by 0: 42.0}} | |
| 94 | - | |
| 95 | -############################################################################### | |
| 96 | - | |
| 97 | -fossil test-th-eval "expr 42.0/0.0" | |
| 98 | -test th1-divide-by-zero-4 {$RESULT eq {TH_ERROR: Divide by 0: 42.0}} | |
| 99 | - | |
| 100 | -############################################################################### | |
| 101 | - | |
| 102 | -fossil test-th-eval "expr 42%0" | |
| 103 | -test th1-modulus-by-zero-1 {$RESULT eq {TH_ERROR: Modulo by 0: 42}} | |
| 104 | - | |
| 105 | -############################################################################### | |
| 106 | - | |
| 107 | -fossil test-th-eval "expr 42%0.0" | |
| 108 | -test th1-modulus-by-zero-2 {$RESULT eq {TH_ERROR: expected integer, got: "0.0"}} | |
| 109 | - | |
| 110 | -############################################################################### | |
| 111 | - | |
| 112 | -fossil test-th-eval "expr 42.0%0" | |
| 113 | -test th1-modulus-by-zero-3 {$RESULT eq \ | |
| 114 | -{TH_ERROR: expected integer, got: "42.0"}} | |
| 115 | - | |
| 116 | -############################################################################### | |
| 117 | - | |
| 118 | -fossil test-th-eval "expr 42.0%0.0" | |
| 119 | -test th1-modulus-by-zero-4 {$RESULT eq \ | |
| 120 | -{TH_ERROR: expected integer, got: "42.0"}} | |
| 90 | +th1_cases --open-config { | |
| 91 | + th1-setting-7 {setting --} \ | |
| 92 | + {TH_ERROR: wrong # args: should be "setting ?-strict? ?--? name"} | |
| 93 | + th1-setting-8 {setting -strict --} \ | |
| 94 | + {TH_ERROR: wrong # args: should be "setting ?-strict? ?--? name"} | |
| 95 | + th1-setting-9 {setting -- --} {} | |
| 96 | + th1-setting-10 {setting -strict -- --} {TH_ERROR: no value for setting "--"} | |
| 97 | +} | |
| 98 | + | |
| 99 | +############################################################################### | |
| 100 | + | |
| 101 | +th1_cases { | |
| 102 | + th1-divide-by-zero-1 {expr 42/0} {TH_ERROR: Divide by 0: 42} | |
| 103 | + th1-divide-by-zero-2 {expr 42/0.0} {TH_ERROR: Divide by 0: 42} | |
| 104 | + th1-divide-by-zero-3 {expr 42.0/0} {TH_ERROR: Divide by 0: 42.0} | |
| 105 | + th1-divide-by-zero-4 {expr 42.0/0.0} {TH_ERROR: Divide by 0: 42.0} | |
| 106 | + th1-modulus-by-zero-1 {expr 42%0} {TH_ERROR: Modulo by 0: 42} | |
| 107 | + th1-modulus-by-zero-2 {expr 42%0.0} {TH_ERROR: expected integer, got: "0.0"} | |
| 108 | + th1-modulus-by-zero-3 {expr 42.0%0} {TH_ERROR: expected integer, got: "42.0"} | |
| 109 | + th1-modulus-by-zero-4 {expr 42.0%0.0} {TH_ERROR: expected integer, got: "42.0"} | |
| 110 | +} | |
| 121 | 111 | |
| 122 | 112 | ############################################################################### |
| 123 | 113 | |
| 124 | 114 | fossil test-th-eval "set var 1; info exists var" |
| 125 | 115 | test th1-info-exists-1 {$RESULT eq {1}} |
| @@ -219,471 +209,175 @@ | ||
| 219 | 209 | fossil test-th-eval "set gv(1) 1; upvar 0 gv(1) gv2; unset gv(1); unset gv2" |
| 220 | 210 | test th1-unset-8 {$RESULT eq {TH_ERROR: no such variable: gv2}} |
| 221 | 211 | |
| 222 | 212 | ############################################################################### |
| 223 | 213 | |
| 224 | -fossil test-th-eval "string first {} {}" | |
| 225 | -test th1-string-first-1 {$RESULT eq {-1}} | |
| 226 | - | |
| 227 | -############################################################################### | |
| 228 | - | |
| 229 | -fossil test-th-eval "string first {} {a}" | |
| 230 | -test th1-string-first-2 {$RESULT eq {-1}} | |
| 231 | - | |
| 232 | -############################################################################### | |
| 233 | - | |
| 234 | -fossil test-th-eval "string first {a} {}" | |
| 235 | -test th1-string-first-3 {$RESULT eq {-1}} | |
| 236 | - | |
| 237 | -############################################################################### | |
| 238 | - | |
| 239 | -fossil test-th-eval "string first {a} {a}" | |
| 240 | -test th1-string-first-4 {$RESULT eq {0}} | |
| 241 | - | |
| 242 | -############################################################################### | |
| 243 | - | |
| 244 | -fossil test-th-eval "string first {a} {aa}" | |
| 245 | -test th1-string-first-5 {$RESULT eq {0}} | |
| 246 | - | |
| 247 | -############################################################################### | |
| 248 | - | |
| 249 | -fossil test-th-eval "string first {aa} {a}" | |
| 250 | -test th1-string-first-6 {$RESULT eq {-1}} | |
| 251 | - | |
| 252 | -############################################################################### | |
| 253 | - | |
| 254 | -fossil test-th-eval "string first {ab} {abc}" | |
| 255 | -test th1-string-first-7 {$RESULT eq {0}} | |
| 256 | - | |
| 257 | -############################################################################### | |
| 258 | - | |
| 259 | -fossil test-th-eval "string first {bc} {abc}" | |
| 260 | -test th1-string-first-8 {$RESULT eq {1}} | |
| 261 | - | |
| 262 | -############################################################################### | |
| 263 | - | |
| 264 | -fossil test-th-eval "string first {AB} {abc}" | |
| 265 | -test th1-string-first-9 {$RESULT eq {-1}} | |
| 266 | - | |
| 267 | -############################################################################### | |
| 268 | - | |
| 269 | -fossil test-th-eval "string last {} {}" | |
| 270 | -test th1-string-last-1 {$RESULT eq {-1}} | |
| 271 | - | |
| 272 | -############################################################################### | |
| 273 | - | |
| 274 | -fossil test-th-eval "string last {} {a}" | |
| 275 | -test th1-string-last-2 {$RESULT eq {-1}} | |
| 276 | - | |
| 277 | -############################################################################### | |
| 278 | - | |
| 279 | -fossil test-th-eval "string last {a} {}" | |
| 280 | -test th1-string-last-3 {$RESULT eq {-1}} | |
| 281 | - | |
| 282 | -############################################################################### | |
| 283 | - | |
| 284 | -fossil test-th-eval "string last {a} {a}" | |
| 285 | -test th1-string-last-4 {$RESULT eq {0}} | |
| 286 | - | |
| 287 | -############################################################################### | |
| 288 | - | |
| 289 | -fossil test-th-eval "string last {a} {aa}" | |
| 290 | -test th1-string-last-5 {$RESULT eq {1}} | |
| 291 | - | |
| 292 | -############################################################################### | |
| 293 | - | |
| 294 | -fossil test-th-eval "string last {aa} {a}" | |
| 295 | -test th1-string-last-6 {$RESULT eq {-1}} | |
| 296 | - | |
| 297 | -############################################################################### | |
| 298 | - | |
| 299 | -fossil test-th-eval "string last {ab} {abc}" | |
| 300 | -test th1-string-last-7 {$RESULT eq {0}} | |
| 301 | - | |
| 302 | -############################################################################### | |
| 303 | - | |
| 304 | -fossil test-th-eval "string last {bc} {abc}" | |
| 305 | -test th1-string-last-8 {$RESULT eq {1}} | |
| 306 | - | |
| 307 | -############################################################################### | |
| 308 | - | |
| 309 | -fossil test-th-eval "string last {AB} {abc}" | |
| 310 | -test th1-string-last-9 {$RESULT eq {-1}} | |
| 311 | - | |
| 312 | -############################################################################### | |
| 313 | - | |
| 314 | -fossil test-th-eval "expr -2147483649.0" | |
| 315 | -test th1-expr-1 {$RESULT eq {-2147483649.0}} | |
| 316 | - | |
| 317 | -############################################################################### | |
| 318 | - | |
| 319 | -fossil test-th-eval "expr -2147483649" | |
| 320 | -test th1-expr-2 {$RESULT eq {2147483647}} | |
| 321 | - | |
| 322 | -############################################################################### | |
| 323 | - | |
| 324 | -fossil test-th-eval "expr -2147483648" | |
| 325 | -test th1-expr-3 {$RESULT eq {-2147483648}} | |
| 326 | - | |
| 327 | -############################################################################### | |
| 328 | - | |
| 329 | -fossil test-th-eval "expr -2147483647" | |
| 330 | -test th1-expr-4 {$RESULT eq {-2147483647}} | |
| 331 | - | |
| 332 | -############################################################################### | |
| 333 | - | |
| 334 | -fossil test-th-eval "expr -1" | |
| 335 | -test th1-expr-5 {$RESULT eq {-1}} | |
| 336 | - | |
| 337 | -############################################################################### | |
| 338 | - | |
| 339 | -fossil test-th-eval "expr 0" | |
| 340 | -test th1-expr-6 {$RESULT eq {0}} | |
| 341 | - | |
| 342 | -############################################################################### | |
| 343 | - | |
| 344 | -fossil test-th-eval "expr 0.0" | |
| 345 | -test th1-expr-7 {$RESULT eq {0.0}} | |
| 346 | - | |
| 347 | -############################################################################### | |
| 348 | - | |
| 349 | -fossil test-th-eval "expr 1" | |
| 350 | -test th1-expr-8 {$RESULT eq {1}} | |
| 351 | - | |
| 352 | -############################################################################### | |
| 353 | - | |
| 354 | -fossil test-th-eval "expr 2147483647" | |
| 355 | -test th1-expr-9 {$RESULT eq {2147483647}} | |
| 356 | - | |
| 357 | -############################################################################### | |
| 358 | - | |
| 359 | -fossil test-th-eval "expr 2147483648" | |
| 360 | -test th1-expr-10 {$RESULT eq {2147483648}} | |
| 361 | - | |
| 362 | -############################################################################### | |
| 363 | - | |
| 364 | -fossil test-th-eval "expr 2147483649" | |
| 365 | -test th1-expr-11 {$RESULT eq {2147483649}} | |
| 366 | - | |
| 367 | -############################################################################### | |
| 368 | - | |
| 369 | -fossil test-th-eval "expr +2147483649" | |
| 370 | -test th1-expr-12 {$RESULT eq {-2147483647}} | |
| 371 | - | |
| 372 | -############################################################################### | |
| 373 | - | |
| 374 | -fossil test-th-eval "expr +2147483649.0" | |
| 375 | -test th1-expr-13 {$RESULT eq {2147483649.0}} | |
| 376 | - | |
| 377 | -############################################################################### | |
| 378 | - | |
| 379 | -fossil test-th-eval "expr ~(-1)" | |
| 380 | -test th1-expr-14 {$RESULT eq {0}} | |
| 381 | - | |
| 382 | -############################################################################### | |
| 383 | - | |
| 384 | -fossil test-th-eval "expr ~-1" | |
| 385 | -test th1-expr-15 {$RESULT eq {0}} | |
| 386 | - | |
| 387 | -############################################################################### | |
| 388 | - | |
| 389 | -fossil test-th-eval "expr ~0" | |
| 390 | -test th1-expr-16 {$RESULT eq {-1}} | |
| 391 | - | |
| 392 | -############################################################################### | |
| 393 | - | |
| 394 | -fossil test-th-eval "expr ~+0" | |
| 395 | -test th1-expr-17 {$RESULT eq {-1}} | |
| 396 | - | |
| 397 | -############################################################################### | |
| 398 | - | |
| 399 | -fossil test-th-eval "expr ~-0" | |
| 400 | -test th1-expr-18 {$RESULT eq {-1}} | |
| 401 | - | |
| 402 | -############################################################################### | |
| 403 | - | |
| 404 | -fossil test-th-eval "expr ~(+0)" | |
| 405 | -test th1-expr-19 {$RESULT eq {-1}} | |
| 406 | - | |
| 407 | -############################################################################### | |
| 408 | - | |
| 409 | -fossil test-th-eval "expr ~(-0)" | |
| 410 | -test th1-expr-20 {$RESULT eq {-1}} | |
| 411 | - | |
| 412 | -############################################################################### | |
| 413 | - | |
| 414 | -fossil test-th-eval "expr ~1" | |
| 415 | -test th1-expr-21 {$RESULT eq {-2}} | |
| 416 | - | |
| 417 | -############################################################################### | |
| 418 | - | |
| 419 | -fossil test-th-eval "expr ~+1" | |
| 420 | -test th1-expr-22 {$RESULT eq {-2}} | |
| 421 | - | |
| 422 | -############################################################################### | |
| 423 | - | |
| 424 | -fossil test-th-eval "expr ~(+1)" | |
| 425 | -test th1-expr-23 {$RESULT eq {-2}} | |
| 426 | - | |
| 427 | -############################################################################### | |
| 428 | - | |
| 429 | -fossil test-th-eval "expr 0+0b11" | |
| 430 | -test th1-expr-24 {$RESULT eq 3} | |
| 431 | - | |
| 432 | -############################################################################### | |
| 433 | - | |
| 434 | -fossil test-th-eval "expr 0+0o15" | |
| 435 | -test th1-expr-25 {$RESULT eq 13} | |
| 436 | - | |
| 437 | -############################################################################### | |
| 438 | - | |
| 439 | -fossil test-th-eval "expr 0+0x15" | |
| 440 | -test th1-expr-26 {$RESULT eq 21} | |
| 441 | - | |
| 442 | -############################################################################### | |
| 443 | - | |
| 444 | -fossil test-th-eval "expr 0+0b2" | |
| 445 | -test th1-expr-27 {$RESULT eq {TH_ERROR: expected number, got: "0b2"}} | |
| 446 | - | |
| 447 | -############################################################################### | |
| 448 | - | |
| 449 | -fossil test-th-eval "expr 0+0o8" | |
| 450 | -test th1-expr-28 {$RESULT eq {TH_ERROR: expected number, got: "0o8"}} | |
| 451 | - | |
| 452 | -############################################################################### | |
| 453 | - | |
| 454 | -fossil test-th-eval "expr 0+0xg" | |
| 455 | -test th1-expr-29 {$RESULT eq {TH_ERROR: syntax error in expression: "0+0xg"}} | |
| 456 | - | |
| 457 | -############################################################################### | |
| 458 | - | |
| 459 | -fossil test-th-eval "expr 0+0b1." | |
| 460 | -test th1-expr-30 {$RESULT eq {TH_ERROR: syntax error in expression: "0+0b1."}} | |
| 461 | - | |
| 462 | -############################################################################### | |
| 463 | - | |
| 464 | -fossil test-th-eval "expr 0+0o1." | |
| 465 | -test th1-expr-31 {$RESULT eq {TH_ERROR: syntax error in expression: "0+0o1."}} | |
| 466 | - | |
| 467 | -############################################################################### | |
| 468 | - | |
| 469 | -fossil test-th-eval "expr 0+0x1." | |
| 470 | -test th1-expr-32 {$RESULT eq {TH_ERROR: syntax error in expression: "0+0x1."}} | |
| 471 | - | |
| 472 | -############################################################################### | |
| 473 | - | |
| 474 | -fossil test-th-eval "expr 0ne5" | |
| 475 | -test th1-expr-33 {$RESULT eq {1}} | |
| 476 | - | |
| 477 | -############################################################################### | |
| 478 | - | |
| 479 | -fossil test-th-eval "expr 0b1+5" | |
| 480 | -test th1-expr-34 {$RESULT eq {6}} | |
| 481 | - | |
| 482 | -############################################################################### | |
| 483 | - | |
| 484 | -fossil test-th-eval "expr 0+0b" | |
| 485 | -test th1-expr-35 {$RESULT eq {TH_ERROR: expected number, got: "0b"}} | |
| 486 | - | |
| 487 | -############################################################################### | |
| 488 | - | |
| 489 | -fossil test-th-eval "expr (-1)+1" | |
| 490 | -test th1-expr-36 {$RESULT eq {0}} | |
| 491 | - | |
| 492 | -############################################################################### | |
| 493 | - | |
| 494 | -fossil test-th-eval "expr (((-1)))" | |
| 495 | -test th1-expr-37 {$RESULT eq {-1}} | |
| 496 | - | |
| 497 | -############################################################################### | |
| 498 | - | |
| 499 | -fossil test-th-eval "expr (((1)))" | |
| 500 | -test th1-expr-38 {$RESULT eq {1}} | |
| 501 | - | |
| 502 | -############################################################################### | |
| 503 | - | |
| 504 | -fossil test-th-eval "expr (((1))" | |
| 505 | -test th1-expr-39 {$RESULT eq {TH_ERROR: syntax error in expression: "(((1))"}} | |
| 506 | - | |
| 507 | -############################################################################### | |
| 508 | - | |
| 509 | -fossil test-th-eval "expr ((1)))" | |
| 510 | -test th1-expr-40 {$RESULT eq {TH_ERROR: syntax error in expression: "((1)))"}} | |
| 511 | - | |
| 512 | -############################################################################### | |
| 513 | - | |
| 514 | -fossil test-th-eval "expr (((1)*2)*2)" | |
| 515 | -test th1-expr-41 {$RESULT eq {4}} | |
| 516 | - | |
| 517 | -############################################################################### | |
| 518 | - | |
| 519 | -fossil test-th-eval "expr +" | |
| 520 | -test th1-expr-42 {$RESULT eq {TH_ERROR: syntax error in expression: "+"}} | |
| 521 | - | |
| 522 | -############################################################################### | |
| 523 | - | |
| 524 | -fossil test-th-eval "expr -" | |
| 525 | -test th1-expr-43 {$RESULT eq {TH_ERROR: syntax error in expression: "-"}} | |
| 526 | - | |
| 527 | -############################################################################### | |
| 528 | - | |
| 529 | -fossil test-th-eval "expr ++" | |
| 530 | -test th1-expr-44 {$RESULT eq {TH_ERROR: syntax error in expression: "++"}} | |
| 531 | - | |
| 532 | -############################################################################### | |
| 533 | - | |
| 534 | -fossil test-th-eval "expr --" | |
| 535 | -test th1-expr-45 {$RESULT eq {TH_ERROR: syntax error in expression: "--"}} | |
| 536 | - | |
| 537 | -############################################################################### | |
| 538 | - | |
| 539 | -fossil test-th-eval "lindex list +" | |
| 540 | -test th1-lindex-bad-1 {$RESULT eq {TH_ERROR: expected integer, got: "+"}} | |
| 541 | - | |
| 542 | -############################################################################### | |
| 543 | - | |
| 544 | -fossil test-th-eval "lindex list -" | |
| 545 | -test th1-lindex-bad-2 {$RESULT eq {TH_ERROR: expected integer, got: "-"}} | |
| 546 | - | |
| 547 | -############################################################################### | |
| 548 | - | |
| 549 | -fossil test-th-eval "lindex list +0x" | |
| 550 | -test th1-lindex-bad-3 {$RESULT eq {TH_ERROR: expected integer, got: "+0x"}} | |
| 551 | - | |
| 552 | -############################################################################### | |
| 553 | - | |
| 554 | -fossil test-th-eval "lindex list -0x" | |
| 555 | -test th1-lindex-bad-4 {$RESULT eq {TH_ERROR: expected integer, got: "-0x"}} | |
| 214 | +th1_cases { | |
| 215 | + th1-string-first-1 {string first {} {}} -1 | |
| 216 | + th1-string-first-2 {string first {} {a}} -1 | |
| 217 | + th1-string-first-3 {string first {a} {}} -1 | |
| 218 | + th1-string-first-4 {string first {a} {a}} 0 | |
| 219 | + th1-string-first-5 {string first {a} {aa}} 0 | |
| 220 | + th1-string-first-6 {string first {aa} {a}} -1 | |
| 221 | + th1-string-first-7 {string first {ab} {abc}} 0 | |
| 222 | + th1-string-first-8 {string first {bc} {abc}} 1 | |
| 223 | + th1-string-first-9 {string first {AB} {abc}} -1 | |
| 224 | + th1-string-last-1 {string last {} {}} -1 | |
| 225 | + th1-string-last-2 {string last {} {a}} -1 | |
| 226 | + th1-string-last-3 {string last {a} {}} -1 | |
| 227 | + th1-string-last-4 {string last {a} {a}} 0 | |
| 228 | + th1-string-last-5 {string last {a} {aa}} 1 | |
| 229 | + th1-string-last-6 {string last {aa} {a}} -1 | |
| 230 | + th1-string-last-7 {string last {ab} {abc}} 0 | |
| 231 | + th1-string-last-8 {string last {bc} {abc}} 1 | |
| 232 | + th1-string-last-9 {string last {AB} {abc}} -1 | |
| 233 | +} | |
| 234 | + | |
| 235 | +############################################################################### | |
| 236 | + | |
| 237 | +th1_cases { | |
| 238 | + th1-expr-1 {expr -2147483649.0} -2147483649.0 | |
| 239 | + th1-expr-2 {expr -2147483649} 2147483647 | |
| 240 | + th1-expr-3 {expr -2147483648} -2147483648 | |
| 241 | + th1-expr-4 {expr -2147483647} -2147483647 | |
| 242 | + th1-expr-5 {expr -1} -1 | |
| 243 | + th1-expr-6 {expr 0} 0 | |
| 244 | + th1-expr-7 {expr 0.0} 0.0 | |
| 245 | + th1-expr-8 {expr 1} 1 | |
| 246 | + th1-expr-9 {expr 2147483647} 2147483647 | |
| 247 | + th1-expr-10 {expr 2147483648} 2147483648 | |
| 248 | + th1-expr-11 {expr 2147483649} 2147483649 | |
| 249 | + th1-expr-12 {expr +2147483649} -2147483647 | |
| 250 | + th1-expr-13 {expr +2147483649.0} 2147483649.0 | |
| 251 | + th1-expr-14 {expr ~(-1)} 0 | |
| 252 | + th1-expr-15 {expr ~-1} 0 | |
| 253 | + th1-expr-16 {expr ~0} -1 | |
| 254 | + th1-expr-17 {expr ~+0} -1 | |
| 255 | + th1-expr-18 {expr ~-0} -1 | |
| 256 | + th1-expr-19 {expr ~(+0)} -1 | |
| 257 | + th1-expr-20 {expr ~(-0)} -1 | |
| 258 | + th1-expr-21 {expr ~1} -2 | |
| 259 | + th1-expr-22 {expr ~+1} -2 | |
| 260 | + th1-expr-23 {expr ~(+1)} -2 | |
| 261 | + th1-expr-24 {expr 0+0b11} 3 | |
| 262 | + th1-expr-25 {expr 0+0o15} 13 | |
| 263 | + th1-expr-26 {expr 0+0x15} 21 | |
| 264 | + th1-expr-27 {expr 0+0b2} {TH_ERROR: expected number, got: "0b2"} | |
| 265 | + th1-expr-28 {expr 0+0o8} {TH_ERROR: expected number, got: "0o8"} | |
| 266 | + th1-expr-29 {expr 0+0xg} {TH_ERROR: syntax error in expression: "0+0xg"} | |
| 267 | + th1-expr-30 {expr 0+0b1.} {TH_ERROR: syntax error in expression: "0+0b1."} | |
| 268 | + th1-expr-31 {expr 0+0o1.} {TH_ERROR: syntax error in expression: "0+0o1."} | |
| 269 | + th1-expr-32 {expr 0+0x1.} {TH_ERROR: syntax error in expression: "0+0x1."} | |
| 270 | + th1-expr-33 {expr 0ne5} 1 | |
| 271 | + th1-expr-34 {expr 0b1+5} 6 | |
| 272 | + th1-expr-35 {expr 0+0b} {TH_ERROR: expected number, got: "0b"} | |
| 273 | + th1-expr-36 {expr (-1)+1} 0 | |
| 274 | + th1-expr-37 {expr (((-1)))} -1 | |
| 275 | + th1-expr-38 {expr (((1)))} 1 | |
| 276 | + th1-expr-39 {expr (((1))} {TH_ERROR: syntax error in expression: "(((1))"} | |
| 277 | + th1-expr-40 {expr ((1)))} {TH_ERROR: syntax error in expression: "((1)))"} | |
| 278 | + th1-expr-41 {expr (((1)*2)*2)} 4 | |
| 279 | + th1-expr-42 {expr +} {TH_ERROR: syntax error in expression: "+"} | |
| 280 | + th1-expr-43 {expr -} {TH_ERROR: syntax error in expression: "-"} | |
| 281 | + th1-expr-44 {expr ++} {TH_ERROR: syntax error in expression: "++"} | |
| 282 | + th1-expr-45 {expr --} {TH_ERROR: syntax error in expression: "--"} | |
| 283 | + th1-lindex-bad-1 {lindex list +} {TH_ERROR: expected integer, got: "+"} | |
| 284 | + th1-lindex-bad-2 {lindex list -} {TH_ERROR: expected integer, got: "-"} | |
| 285 | + th1-lindex-bad-3 {lindex list +0x} {TH_ERROR: expected integer, got: "+0x"} | |
| 286 | + th1-lindex-bad-4 {lindex list -0x} {TH_ERROR: expected integer, got: "-0x"} | |
| 287 | +} | |
| 288 | + | |
| 289 | +############################################################################### | |
| 290 | + | |
| 291 | +# NOTE: The 'd' permission is no longer used. Skip "reader" (u) and | |
| 292 | +# "developer" (v) meta-permissions. | |
| 293 | +set th1_cap_perms { | |
| 294 | + a b c e f g h i j k l m n o p q r s t w x y z | |
| 295 | + A D | |
| 296 | + 2 3 4 5 6 7 | |
| 297 | +} | |
| 298 | + | |
| 299 | +set cases {} | |
| 300 | +foreach perm $th1_cap_perms { | |
| 301 | + lappend cases th1-anycap-no-$perm-1 "anycap $perm" 0 | |
| 302 | + lappend cases th1-hascap-no-$perm-1 "hascap $perm" 0 | |
| 303 | + lappend cases th1-anoncap-no-$perm-1 "anoncap $perm" 0 | |
| 304 | +} | |
| 305 | +lappend cases \ | |
| 306 | + th1-anycap-no-multiple-1 {anycap oh} 0 \ | |
| 307 | + th1-hascap-no-multiple-1 {hascap oh} 0 \ | |
| 308 | + th1-hascap-no-multiple-2 {hascap o h} 0 \ | |
| 309 | + th1-anoncap-no-multiple-1 {anoncap oh} 0 \ | |
| 310 | + th1-anoncap-no-multiple-2 {anoncap o h} 0 | |
| 311 | +th1_cases $cases | |
| 556 | 312 | |
| 557 | 313 | ############################################################################### |
| 558 | 314 | |
| 559 | 315 | set skip_anycap 1 |
| 560 | 316 | if {$::outside_fossil_repo} { |
| 561 | 317 | test_skip_part "th1-anycap-*-1 perm tests: not in Fossil repo checkout." |
| 562 | -} elseif ($::dirty_ckout) { | |
| 318 | +} elseif {$::dirty_ckout} { | |
| 563 | 319 | test_skip_part "th1-anycap-*-1 perm tests: uncommitted changes in\ |
| 564 | 320 | Fossil checkout." |
| 565 | 321 | } else { |
| 566 | 322 | set skip_anycap 0 |
| 567 | 323 | } |
| 568 | 324 | |
| 569 | -# NOTE: The 'd' permission is no longer used. | |
| 570 | -foreach perm [list \ | |
| 571 | - a b c e f g h i j k l m n o p q r s t u v w x y z \ | |
| 572 | - A D \ | |
| 573 | - 2 3 4 5 6 7 ] { | |
| 574 | - if {$perm eq "u"} continue; # NOTE: Skip "reader" meta-permission. | |
| 575 | - if {$perm eq "v"} continue; # NOTE: Skip "developer" meta-permission. | |
| 576 | - | |
| 577 | - set ::env(TH1_TEST_USER_CAPS) sxy | |
| 578 | - fossil test-th-eval "anycap $perm" | |
| 579 | - test th1-anycap-no-$perm-1 {$RESULT eq {0}} | |
| 580 | - | |
| 581 | - fossil test-th-eval "hascap $perm" | |
| 582 | - test th1-hascap-no-$perm-1 {$RESULT eq {0}} | |
| 583 | - | |
| 584 | - fossil test-th-eval "anoncap $perm" | |
| 585 | - test th1-anoncap-no-$perm-1 {$RESULT eq {0}} | |
| 586 | - | |
| 587 | - if {$skip_anycap} { continue } | |
| 588 | - | |
| 589 | - run_in_checkout { | |
| 590 | - set ::env(TH1_TEST_USER_CAPS) sxy | |
| 591 | - fossil test-th-eval --set-user-caps "anycap $perm" | |
| 592 | - test th1-anycap-yes-$perm-1 {$RESULT eq {1}} | |
| 593 | - | |
| 594 | - set ::env(TH1_TEST_USER_CAPS) 1; # NOTE: Bad permission. | |
| 595 | - fossil test-th-eval --set-user-caps "anycap $perm" | |
| 596 | - test th1-anycap-no-$perm-2 {$RESULT eq {0}} | |
| 597 | - | |
| 598 | - set ::env(TH1_TEST_USER_CAPS) sxy | |
| 599 | - fossil test-th-eval --set-user-caps "hascap $perm" | |
| 600 | - test th1-hascap-yes-$perm-1 {$RESULT eq {1}} | |
| 601 | - | |
| 602 | - set ::env(TH1_TEST_USER_CAPS) 1; # NOTE: Bad permission. | |
| 603 | - fossil test-th-eval --set-user-caps "hascap $perm" | |
| 604 | - test th1-hascap-no-$perm-2 {$RESULT eq {0}} | |
| 605 | - unset ::env(TH1_TEST_USER_CAPS) | |
| 606 | - | |
| 607 | - set ::env(TH1_TEST_ANON_CAPS) sxy | |
| 608 | - fossil test-th-eval --set-anon-caps "anoncap $perm" | |
| 609 | - test th1-anoncap-yes-$perm-1 {$RESULT eq {1}} | |
| 610 | - | |
| 611 | - set ::env(TH1_TEST_ANON_CAPS) 1; # NOTE: Bad permission. | |
| 612 | - fossil test-th-eval --set-anon-caps "anoncap $perm" | |
| 613 | - test th1-anoncap-no-$perm-2 {$RESULT eq {0}} | |
| 614 | - unset ::env(TH1_TEST_ANON_CAPS) | |
| 615 | - } | |
| 616 | -} | |
| 617 | - | |
| 618 | -############################################################################### | |
| 619 | - | |
| 620 | -fossil test-th-eval "anycap oh" | |
| 621 | -test th1-anycap-no-multiple-1 {$RESULT eq {0}} | |
| 622 | - | |
| 623 | -############################################################################### | |
| 624 | - | |
| 625 | -fossil test-th-eval "hascap oh" | |
| 626 | -test th1-hascap-no-multiple-1 {$RESULT eq {0}} | |
| 627 | - | |
| 628 | -############################################################################### | |
| 629 | - | |
| 630 | -fossil test-th-eval "hascap o h" | |
| 631 | -test th1-hascap-no-multiple-2 {$RESULT eq {0}} | |
| 632 | - | |
| 633 | -############################################################################### | |
| 634 | - | |
| 635 | -fossil test-th-eval "anoncap oh" | |
| 636 | -test th1-anoncap-no-multiple-1 {$RESULT eq {0}} | |
| 637 | - | |
| 638 | -############################################################################### | |
| 639 | - | |
| 640 | -fossil test-th-eval "anoncap o h" | |
| 641 | -test th1-anoncap-no-multiple-2 {$RESULT eq {0}} | |
| 642 | - | |
| 643 | -############################################################################### | |
| 644 | - | |
| 645 | -test_block_in_checkout "test-anoncap-*" { | |
| 646 | - fossil test-th-eval --set-user-caps "anycap oh" | |
| 647 | - test th1-anycap-yes-multiple-1 {$RESULT eq {1}} | |
| 648 | - | |
| 649 | - set ::env(TH1_TEST_USER_CAPS) o | |
| 650 | - fossil test-th-eval --set-user-caps "anycap oh" | |
| 651 | - test th1-anycap-yes-multiple-2 {$RESULT eq {1}} | |
| 652 | - unset ::env(TH1_TEST_USER_CAPS) | |
| 653 | - | |
| 654 | - fossil test-th-eval --set-user-caps "hascap oh" | |
| 655 | - test th1-hascap-yes-multiple-1 {$RESULT eq {1}} | |
| 656 | - | |
| 657 | - set ::env(TH1_TEST_USER_CAPS) o | |
| 658 | - fossil test-th-eval --set-user-caps "hascap oh" | |
| 659 | - test th1-hascap-no-multiple-3 {$RESULT eq {0}} | |
| 660 | - unset ::env(TH1_TEST_USER_CAPS) | |
| 661 | - | |
| 662 | - fossil test-th-eval --set-user-caps "hascap o h" | |
| 663 | - test th1-hascap-yes-multiple-2 {$RESULT eq {1}} | |
| 664 | - | |
| 665 | - set ::env(TH1_TEST_USER_CAPS) o | |
| 666 | - fossil test-th-eval --set-user-caps "hascap o h" | |
| 667 | - test th1-hascap-no-multiple-4 {$RESULT eq {0}} | |
| 668 | - unset ::env(TH1_TEST_USER_CAPS) | |
| 669 | - | |
| 670 | - fossil test-th-eval --set-anon-caps "anoncap oh" | |
| 671 | - test th1-anoncap-yes-multiple-1 {$RESULT eq {1}} | |
| 672 | - | |
| 673 | - set ::env(TH1_TEST_ANON_CAPS) o | |
| 674 | - fossil test-th-eval --set-anon-caps "anoncap oh" | |
| 675 | - test th1-anoncap-no-multiple-3 {$RESULT eq {0}} | |
| 676 | - unset ::env(TH1_TEST_ANON_CAPS) | |
| 677 | - | |
| 678 | - fossil test-th-eval --set-anon-caps "anoncap o h" | |
| 679 | - test th1-anoncap-yes-multiple-2 {$RESULT eq {1}} | |
| 680 | - | |
| 681 | - set ::env(TH1_TEST_ANON_CAPS) o | |
| 682 | - fossil test-th-eval --set-anon-caps "anoncap o h" | |
| 683 | - test th1-anoncap-no-multiple-4 {$RESULT eq {0}} | |
| 684 | - unset ::env(TH1_TEST_ANON_CAPS) | |
| 325 | +if {!$skip_anycap} { | |
| 326 | + run_in_checkout { | |
| 327 | + set cases {} | |
| 328 | + foreach perm $th1_cap_perms { | |
| 329 | + lappend cases th1-anycap-yes-$perm-1 "anycap $perm" 1 | |
| 330 | + lappend cases th1-hascap-yes-$perm-1 "hascap $perm" 1 | |
| 331 | + } | |
| 332 | + lappend cases \ | |
| 333 | + th1-anycap-yes-multiple-1 {anycap oh} 1 \ | |
| 334 | + th1-hascap-yes-multiple-1 {hascap oh} 1 \ | |
| 335 | + th1-hascap-yes-multiple-2 {hascap o h} 1 | |
| 336 | + set ::env(TH1_TEST_USER_CAPS) sxy | |
| 337 | + th1_cases --set-user-caps $cases | |
| 338 | + | |
| 339 | + set cases {} | |
| 340 | + foreach perm $th1_cap_perms { | |
| 341 | + lappend cases th1-anycap-no-$perm-2 "anycap $perm" 0 | |
| 342 | + lappend cases th1-hascap-no-$perm-2 "hascap $perm" 0 | |
| 343 | + } | |
| 344 | + set ::env(TH1_TEST_USER_CAPS) 1; # NOTE: Bad permission. | |
| 345 | + th1_cases --set-user-caps $cases | |
| 346 | + | |
| 347 | + set ::env(TH1_TEST_USER_CAPS) o | |
| 348 | + th1_cases --set-user-caps { | |
| 349 | + th1-anycap-yes-multiple-2 {anycap oh} 1 | |
| 350 | + th1-hascap-no-multiple-3 {hascap oh} 0 | |
| 351 | + th1-hascap-no-multiple-4 {hascap o h} 0 | |
| 352 | + } | |
| 353 | + unset ::env(TH1_TEST_USER_CAPS) | |
| 354 | + | |
| 355 | + set cases {} | |
| 356 | + foreach perm $th1_cap_perms { | |
| 357 | + lappend cases th1-anoncap-yes-$perm-1 "anoncap $perm" 1 | |
| 358 | + } | |
| 359 | + lappend cases \ | |
| 360 | + th1-anoncap-yes-multiple-1 {anoncap oh} 1 \ | |
| 361 | + th1-anoncap-yes-multiple-2 {anoncap o h} 1 | |
| 362 | + set ::env(TH1_TEST_ANON_CAPS) sxy | |
| 363 | + th1_cases --set-anon-caps $cases | |
| 364 | + | |
| 365 | + set cases {} | |
| 366 | + foreach perm $th1_cap_perms { | |
| 367 | + lappend cases th1-anoncap-no-$perm-2 "anoncap $perm" 0 | |
| 368 | + } | |
| 369 | + set ::env(TH1_TEST_ANON_CAPS) 1; # NOTE: Bad permission. | |
| 370 | + th1_cases --set-anon-caps $cases | |
| 371 | + | |
| 372 | + set ::env(TH1_TEST_ANON_CAPS) o | |
| 373 | + th1_cases --set-anon-caps { | |
| 374 | + th1-anoncap-no-multiple-3 {anoncap oh} 0 | |
| 375 | + th1-anoncap-no-multiple-4 {anoncap o h} 0 | |
| 376 | + } | |
| 377 | + unset ::env(TH1_TEST_ANON_CAPS) | |
| 378 | + } | |
| 685 | 379 | } |
| 686 | 380 | |
| 687 | 381 | ############################################################################### |
| 688 | 382 | |
| 689 | 383 | test_in_checkout th1-checkout-1 { |
| @@ -1189,365 +883,113 @@ | ||
| 1189 | 883 | fossil test-th-eval "set foo(x) 2; unset foo(x); array names foo" |
| 1190 | 884 | test th1-array-names-6 {$RESULT eq ""} |
| 1191 | 885 | |
| 1192 | 886 | ############################################################################### |
| 1193 | 887 | |
| 1194 | -fossil test-th-eval "lsearch" | |
| 1195 | -test th1-lsearch-1 {$RESULT eq \ | |
| 1196 | - {TH_ERROR: wrong # args: should be "lsearch list string"}} | |
| 1197 | - | |
| 1198 | -############################################################################### | |
| 1199 | - | |
| 1200 | -fossil test-th-eval "lsearch a" | |
| 1201 | -test th1-lsearch-2 {$RESULT eq \ | |
| 1202 | - {TH_ERROR: wrong # args: should be "lsearch list string"}} | |
| 1203 | - | |
| 1204 | -############################################################################### | |
| 1205 | - | |
| 1206 | -fossil test-th-eval "lsearch a a a" | |
| 1207 | -test th1-lsearch-3 {$RESULT eq \ | |
| 1208 | - {TH_ERROR: wrong # args: should be "lsearch list string"}} | |
| 1209 | - | |
| 1210 | -############################################################################### | |
| 1211 | - | |
| 1212 | -fossil test-th-eval "lsearch {a b c} a" | |
| 1213 | -test th1-lsearch-4 {$RESULT eq "0"} | |
| 1214 | - | |
| 1215 | -############################################################################### | |
| 1216 | - | |
| 1217 | -fossil test-th-eval "lsearch {a b c} b" | |
| 1218 | -test th1-lsearch-5 {$RESULT eq "1"} | |
| 1219 | - | |
| 1220 | -############################################################################### | |
| 1221 | - | |
| 1222 | -fossil test-th-eval "lsearch {a b c} c" | |
| 1223 | -test th1-lsearch-6 {$RESULT eq "2"} | |
| 1224 | - | |
| 1225 | -############################################################################### | |
| 1226 | - | |
| 1227 | -fossil test-th-eval "lsearch {a b c} d" | |
| 1228 | -test th1-lsearch-7 {$RESULT eq "-1"} | |
| 1229 | - | |
| 1230 | -############################################################################### | |
| 1231 | - | |
| 1232 | -fossil test-th-eval "lsearch {a b c} aa" | |
| 1233 | -test th1-lsearch-8 {$RESULT eq "-1"} | |
| 1234 | - | |
| 1235 | -############################################################################### | |
| 1236 | - | |
| 1237 | -fossil test-th-eval "lsearch {aa b c} a" | |
| 1238 | -test th1-lsearch-9 {$RESULT eq "-1"} | |
| 888 | +th1_cases { | |
| 889 | + th1-lsearch-1 {lsearch} \ | |
| 890 | + {TH_ERROR: wrong # args: should be "lsearch list string"} | |
| 891 | + th1-lsearch-2 {lsearch a} \ | |
| 892 | + {TH_ERROR: wrong # args: should be "lsearch list string"} | |
| 893 | + th1-lsearch-3 {lsearch a a a} \ | |
| 894 | + {TH_ERROR: wrong # args: should be "lsearch list string"} | |
| 895 | + th1-lsearch-4 {lsearch {a b c} a} 0 | |
| 896 | + th1-lsearch-5 {lsearch {a b c} b} 1 | |
| 897 | + th1-lsearch-6 {lsearch {a b c} c} 2 | |
| 898 | + th1-lsearch-7 {lsearch {a b c} d} -1 | |
| 899 | + th1-lsearch-8 {lsearch {a b c} aa} -1 | |
| 900 | + th1-lsearch-9 {lsearch {aa b c} a} -1 | |
| 901 | +} | |
| 1239 | 902 | |
| 1240 | 903 | ############################################################################### |
| 1241 | 904 | |
| 1242 | 905 | fossil test-th-eval "lsearch \"\{aa b c\" a" |
| 1243 | 906 | test th1-lsearch-10 {$RESULT eq "TH_ERROR: Expected list, got: \"\{aa b c\""} |
| 1244 | 907 | |
| 1245 | 908 | ############################################################################### |
| 1246 | 909 | |
| 1247 | -fossil test-th-eval "glob_match" | |
| 1248 | -test th1-glob-match-1 {$RESULT eq \ | |
| 1249 | -{TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} | |
| 1250 | - | |
| 1251 | -############################################################################### | |
| 1252 | - | |
| 1253 | -fossil test-th-eval "glob_match -one" | |
| 1254 | -test th1-glob-match-2 {$RESULT eq \ | |
| 1255 | -{TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} | |
| 1256 | - | |
| 1257 | -############################################################################### | |
| 1258 | - | |
| 1259 | -fossil test-th-eval "glob_match --" | |
| 1260 | -test th1-glob-match-3 {$RESULT eq \ | |
| 1261 | -{TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} | |
| 1262 | - | |
| 1263 | -############################################################################### | |
| 1264 | - | |
| 1265 | -fossil test-th-eval "glob_match -one --" | |
| 1266 | -test th1-glob-match-4 {$RESULT eq \ | |
| 1267 | -{TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} | |
| 1268 | - | |
| 1269 | -############################################################################### | |
| 1270 | - | |
| 1271 | -fossil test-th-eval "glob_match -one -- 1" | |
| 1272 | -test th1-glob-match-5 {$RESULT eq \ | |
| 1273 | -{TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} | |
| 1274 | - | |
| 1275 | -############################################################################### | |
| 1276 | - | |
| 1277 | -fossil test-th-eval "glob_match -one -- 1 2 3" | |
| 1278 | -test th1-glob-match-6 {$RESULT eq \ | |
| 1279 | -{TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} | |
| 1280 | - | |
| 1281 | -############################################################################### | |
| 1282 | - | |
| 1283 | -fossil test-th-eval {list [glob_match a A] [glob_match A a]} | |
| 1284 | -test th1-glob-match-7 {$RESULT eq "0 0"} | |
| 1285 | - | |
| 1286 | -############################################################################### | |
| 1287 | - | |
| 1288 | -fossil test-th-eval {list [glob_match a,b a] [glob_match a,b b]} | |
| 1289 | -test th1-glob-match-8 {$RESULT eq "1 2"} | |
| 1290 | - | |
| 1291 | -############################################################################### | |
| 1292 | - | |
| 1293 | -fossil test-th-eval {list [glob_match -one a,b a] [glob_match -one a,b b]} | |
| 1294 | -test th1-glob-match-9 {$RESULT eq "0 0"} | |
| 1295 | - | |
| 1296 | -############################################################################### | |
| 1297 | - | |
| 1298 | -fossil test-th-eval {list [glob_match -one a,b a,b] [glob_match -one a b,a]} | |
| 1299 | -test th1-glob-match-10 {$RESULT eq "1 0"} | |
| 1300 | - | |
| 1301 | -############################################################################### | |
| 1302 | - | |
| 1303 | -fossil test-th-eval {list [glob_match a*c abc] [glob_match abc a*c]} | |
| 1304 | -test th1-glob-match-11 {$RESULT eq "1 0"} | |
| 1305 | - | |
| 1306 | -############################################################################### | |
| 1307 | - | |
| 1308 | -fossil test-th-eval {list [glob_match a?c abc] [glob_match abc a?c]} | |
| 1309 | -test th1-glob-match-12 {$RESULT eq "1 0"} | |
| 1310 | - | |
| 1311 | -############################################################################### | |
| 1312 | - | |
| 1313 | -fossil test-th-eval {list [glob_match {a[bd]c} abc] [glob_match abc {a[bd]c}]} | |
| 1314 | -test th1-glob-match-13 {$RESULT eq "1 0"} | |
| 1315 | - | |
| 1316 | -############################################################################### | |
| 1317 | - | |
| 1318 | -fossil test-th-eval {string is} | |
| 1319 | -test th1-string-is-1 {$RESULT eq \ | |
| 1320 | -{TH_ERROR: wrong # args: should be "string is class string"}} | |
| 1321 | - | |
| 1322 | -############################################################################### | |
| 1323 | - | |
| 1324 | -fossil test-th-eval {string is something} | |
| 1325 | -test th1-string-is-2 {$RESULT eq \ | |
| 1326 | -{TH_ERROR: wrong # args: should be "string is class string"}} | |
| 1327 | - | |
| 1328 | -############################################################################### | |
| 1329 | - | |
| 1330 | -fossil test-th-eval {string is not something else} | |
| 1331 | -test th1-string-is-3 {$RESULT eq \ | |
| 1332 | -{TH_ERROR: wrong # args: should be "string is class string"}} | |
| 1333 | - | |
| 1334 | -############################################################################### | |
| 1335 | - | |
| 1336 | -fossil test-th-eval {string is other 123} | |
| 1337 | -test th1-string-is-4 {$RESULT eq \ | |
| 1338 | -"TH_ERROR: Expected alnum, double, integer, list, or tainted, got: other"} | |
| 1339 | - | |
| 1340 | -############################################################################### | |
| 1341 | - | |
| 1342 | -fossil test-th-eval {string is alnum 123} | |
| 1343 | -test th1-string-is-5 {$RESULT eq "1"} | |
| 1344 | - | |
| 1345 | -############################################################################### | |
| 1346 | - | |
| 1347 | -fossil test-th-eval {string is alnum abc} | |
| 1348 | -test th1-string-is-6 {$RESULT eq "1"} | |
| 1349 | - | |
| 1350 | -############################################################################### | |
| 1351 | - | |
| 1352 | -fossil test-th-eval {string is alnum 123abc} | |
| 1353 | -test th1-string-is-7 {$RESULT eq "1"} | |
| 1354 | - | |
| 1355 | -############################################################################### | |
| 1356 | - | |
| 1357 | -fossil test-th-eval {string is alnum abc123} | |
| 1358 | -test th1-string-is-8 {$RESULT eq "1"} | |
| 1359 | - | |
| 1360 | -############################################################################### | |
| 1361 | - | |
| 1362 | -fossil test-th-eval {string is alnum _abc123} | |
| 1363 | -test th1-string-is-9 {$RESULT eq "0"} | |
| 1364 | - | |
| 1365 | -############################################################################### | |
| 1366 | - | |
| 1367 | -fossil test-th-eval {string is alnum abc.123} | |
| 1368 | -test th1-string-is-10 {$RESULT eq "0"} | |
| 1369 | - | |
| 1370 | -############################################################################### | |
| 1371 | - | |
| 1372 | -fossil test-th-eval {string is alnum abc123_} | |
| 1373 | -test th1-string-is-11 {$RESULT eq "0"} | |
| 1374 | - | |
| 1375 | -############################################################################### | |
| 1376 | - | |
| 1377 | -fossil test-th-eval {string is list ""} | |
| 1378 | -test th1-string-is-12 {$RESULT eq "1"} | |
| 1379 | - | |
| 1380 | -############################################################################### | |
| 1381 | - | |
| 1382 | -fossil test-th-eval {string is list 1} | |
| 1383 | -test th1-string-is-13 {$RESULT eq "1"} | |
| 1384 | - | |
| 1385 | -############################################################################### | |
| 1386 | - | |
| 1387 | -fossil test-th-eval {string is list "1 2 3"} | |
| 1388 | -test th1-string-is-14 {$RESULT eq "1"} | |
| 1389 | - | |
| 1390 | -############################################################################### | |
| 1391 | - | |
| 1392 | -fossil test-th-eval {string is list "\{"} | |
| 1393 | -test th1-string-is-15 {$RESULT eq "0"} | |
| 1394 | - | |
| 1395 | -############################################################################### | |
| 1396 | - | |
| 1397 | -fossil test-th-eval {string is list "1 2 3 \{"} | |
| 1398 | -test th1-string-is-16 {$RESULT eq "0"} | |
| 1399 | - | |
| 1400 | -############################################################################### | |
| 1401 | - | |
| 1402 | -fossil test-th-eval {string is list "1 2 3 \{\}"} | |
| 1403 | -test th1-string-is-17 {$RESULT eq "1"} | |
| 1404 | - | |
| 1405 | -############################################################################### | |
| 1406 | - | |
| 1407 | -fossil test-th-eval {string is list "1 2 3 \{\{\}"} | |
| 1408 | -test th1-string-is-18 {$RESULT eq "0"} | |
| 1409 | - | |
| 1410 | -############################################################################### | |
| 1411 | - | |
| 1412 | -fossil test-th-eval {string is double 123} | |
| 1413 | -test th1-string-is-19 {$RESULT eq "1"} | |
| 1414 | - | |
| 1415 | -############################################################################### | |
| 1416 | - | |
| 1417 | -fossil test-th-eval {string is double 123.456} | |
| 1418 | -test th1-string-is-20 {$RESULT eq "1"} | |
| 1419 | - | |
| 1420 | -############################################################################### | |
| 1421 | - | |
| 1422 | -fossil test-th-eval {string is double 123abc} | |
| 1423 | -test th1-string-is-21 {$RESULT eq "0"} | |
| 1424 | - | |
| 1425 | -############################################################################### | |
| 1426 | - | |
| 1427 | -fossil test-th-eval {string is double 123_456} | |
| 1428 | -test th1-string-is-22 {$RESULT eq "0"} | |
| 1429 | - | |
| 1430 | -############################################################################### | |
| 1431 | - | |
| 1432 | -fossil test-th-eval {string is integer 123} | |
| 1433 | -test th1-string-is-23 {$RESULT eq "1"} | |
| 1434 | - | |
| 1435 | -############################################################################### | |
| 1436 | - | |
| 1437 | -fossil test-th-eval {string is integer 123.456} | |
| 1438 | -test th1-string-is-24 {$RESULT eq "0"} | |
| 1439 | - | |
| 1440 | -############################################################################### | |
| 1441 | - | |
| 1442 | -fossil test-th-eval {string is integer 123abc} | |
| 1443 | -test th1-string-is-25 {$RESULT eq "0"} | |
| 1444 | - | |
| 1445 | -############################################################################### | |
| 1446 | - | |
| 1447 | -fossil test-th-eval {string is integer 0b11001001} | |
| 1448 | -test th1-string-is-26 {$RESULT eq "1"} | |
| 1449 | - | |
| 1450 | -############################################################################### | |
| 1451 | - | |
| 1452 | -fossil test-th-eval {string is integer 0b11001002} | |
| 1453 | -test th1-string-is-27 {$RESULT eq "0"} | |
| 1454 | - | |
| 1455 | -############################################################################### | |
| 1456 | - | |
| 1457 | -fossil test-th-eval {string is integer 0o777} | |
| 1458 | -test th1-string-is-28 {$RESULT eq "1"} | |
| 1459 | - | |
| 1460 | -############################################################################### | |
| 1461 | - | |
| 1462 | -fossil test-th-eval {string is integer 0o778} | |
| 1463 | -test th1-string-is-29 {$RESULT eq "0"} | |
| 1464 | - | |
| 1465 | -############################################################################### | |
| 1466 | - | |
| 1467 | -fossil test-th-eval {string is integer 0xC0DEF00D} | |
| 1468 | -test th1-string-is-30 {$RESULT eq "1"} | |
| 1469 | - | |
| 1470 | -############################################################################### | |
| 1471 | - | |
| 1472 | -fossil test-th-eval {string is integer 0xC0DEF00Z} | |
| 1473 | -test th1-string-is-31 {$RESULT eq "0"} | |
| 1474 | - | |
| 1475 | -############################################################################### | |
| 1476 | - | |
| 1477 | -fossil test-th-eval {string index "" -1} | |
| 1478 | -test th1-string-index-1 {$RESULT eq ""} | |
| 1479 | - | |
| 1480 | -############################################################################### | |
| 1481 | - | |
| 1482 | -fossil test-th-eval {string index "" 0} | |
| 1483 | -test th1-string-index-2 {$RESULT eq ""} | |
| 1484 | - | |
| 1485 | -############################################################################### | |
| 1486 | - | |
| 1487 | -fossil test-th-eval {string index "" 1} | |
| 1488 | -test th1-string-index-3 {$RESULT eq ""} | |
| 1489 | - | |
| 1490 | -############################################################################### | |
| 1491 | - | |
| 1492 | -fossil test-th-eval {string index "" 2} | |
| 1493 | -test th1-string-index-4 {$RESULT eq ""} | |
| 1494 | - | |
| 1495 | -############################################################################### | |
| 1496 | - | |
| 1497 | -fossil test-th-eval {string index "" end} | |
| 1498 | -test th1-string-index-5 {$RESULT eq ""} | |
| 1499 | - | |
| 1500 | -############################################################################### | |
| 1501 | - | |
| 1502 | -fossil test-th-eval {string index A -1} | |
| 1503 | -test th1-string-index-6 {$RESULT eq ""} | |
| 1504 | - | |
| 1505 | -############################################################################### | |
| 1506 | - | |
| 1507 | -fossil test-th-eval {string index A 0} | |
| 1508 | -test th1-string-index-7 {$RESULT eq "A"} | |
| 1509 | - | |
| 1510 | -############################################################################### | |
| 1511 | - | |
| 1512 | -fossil test-th-eval {string index A 1} | |
| 1513 | -test th1-string-index-8 {$RESULT eq ""} | |
| 1514 | - | |
| 1515 | -############################################################################### | |
| 1516 | - | |
| 1517 | -fossil test-th-eval {string index A 2} | |
| 1518 | -test th1-string-index-9 {$RESULT eq ""} | |
| 1519 | - | |
| 1520 | -############################################################################### | |
| 1521 | - | |
| 1522 | -fossil test-th-eval {string index A end} | |
| 1523 | -test th1-string-index-10 {$RESULT eq "A"} | |
| 1524 | - | |
| 1525 | -############################################################################### | |
| 1526 | - | |
| 1527 | -fossil test-th-eval {string index ABC -1} | |
| 1528 | -test th1-string-index-11 {$RESULT eq ""} | |
| 1529 | - | |
| 1530 | -############################################################################### | |
| 1531 | - | |
| 1532 | -fossil test-th-eval {string index ABC 0} | |
| 1533 | -test th1-string-index-12 {$RESULT eq "A"} | |
| 1534 | - | |
| 1535 | -############################################################################### | |
| 1536 | - | |
| 1537 | -fossil test-th-eval {string index ABC 1} | |
| 1538 | -test th1-string-index-13 {$RESULT eq "B"} | |
| 1539 | - | |
| 1540 | -############################################################################### | |
| 1541 | - | |
| 1542 | -fossil test-th-eval {string index ABC 2} | |
| 1543 | -test th1-string-index-14 {$RESULT eq "C"} | |
| 1544 | - | |
| 1545 | -############################################################################### | |
| 1546 | - | |
| 1547 | -fossil test-th-eval {string index ABC end} | |
| 1548 | -test th1-string-index-15 {$RESULT eq "C"} | |
| 910 | +th1_cases { | |
| 911 | + th1-glob-match-1 {glob_match} \ | |
| 912 | + {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"} | |
| 913 | + th1-glob-match-2 {glob_match -one} \ | |
| 914 | + {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"} | |
| 915 | + th1-glob-match-3 {glob_match --} \ | |
| 916 | + {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"} | |
| 917 | + th1-glob-match-4 {glob_match -one --} \ | |
| 918 | + {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"} | |
| 919 | + th1-glob-match-5 {glob_match -one -- 1} \ | |
| 920 | + {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"} | |
| 921 | + th1-glob-match-6 {glob_match -one -- 1 2 3} \ | |
| 922 | + {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"} | |
| 923 | + th1-glob-match-7 {list [glob_match a A] [glob_match A a]} {0 0} | |
| 924 | + th1-glob-match-8 {list [glob_match a,b a] [glob_match a,b b]} {1 2} | |
| 925 | + th1-glob-match-9 {list [glob_match -one a,b a] [glob_match -one a,b b]} {0 0} | |
| 926 | + th1-glob-match-10 {list [glob_match -one a,b a,b] [glob_match -one a b,a]} {1 0} | |
| 927 | + th1-glob-match-11 {list [glob_match a*c abc] [glob_match abc a*c]} {1 0} | |
| 928 | + th1-glob-match-12 {list [glob_match a?c abc] [glob_match abc a?c]} {1 0} | |
| 929 | + th1-glob-match-13 {list [glob_match {a[bd]c} abc] [glob_match abc {a[bd]c}]} {1 0} | |
| 930 | +} | |
| 931 | + | |
| 932 | +############################################################################### | |
| 933 | + | |
| 934 | +th1_cases { | |
| 935 | + th1-string-is-1 {string is} \ | |
| 936 | + {TH_ERROR: wrong # args: should be "string is class string"} | |
| 937 | + th1-string-is-2 {string is something} \ | |
| 938 | + {TH_ERROR: wrong # args: should be "string is class string"} | |
| 939 | + th1-string-is-3 {string is not something else} \ | |
| 940 | + {TH_ERROR: wrong # args: should be "string is class string"} | |
| 941 | + th1-string-is-4 {string is other 123} \ | |
| 942 | + {TH_ERROR: Expected alnum, double, integer, list, or tainted, got: other} | |
| 943 | + th1-string-is-5 {string is alnum 123} 1 | |
| 944 | + th1-string-is-6 {string is alnum abc} 1 | |
| 945 | + th1-string-is-7 {string is alnum 123abc} 1 | |
| 946 | + th1-string-is-8 {string is alnum abc123} 1 | |
| 947 | + th1-string-is-9 {string is alnum _abc123} 0 | |
| 948 | + th1-string-is-10 {string is alnum abc.123} 0 | |
| 949 | + th1-string-is-11 {string is alnum abc123_} 0 | |
| 950 | + th1-string-is-12 {string is list ""} 1 | |
| 951 | + th1-string-is-13 {string is list 1} 1 | |
| 952 | + th1-string-is-14 {string is list "1 2 3"} 1 | |
| 953 | + th1-string-is-15 {string is list "\{"} 0 | |
| 954 | + th1-string-is-16 {string is list "1 2 3 \{"} 0 | |
| 955 | + th1-string-is-17 {string is list "1 2 3 \{\}"} 1 | |
| 956 | + th1-string-is-18 {string is list "1 2 3 \{\{\}"} 0 | |
| 957 | + th1-string-is-19 {string is double 123} 1 | |
| 958 | + th1-string-is-20 {string is double 123.456} 1 | |
| 959 | + th1-string-is-21 {string is double 123abc} 0 | |
| 960 | + th1-string-is-22 {string is double 123_456} 0 | |
| 961 | + th1-string-is-23 {string is integer 123} 1 | |
| 962 | + th1-string-is-24 {string is integer 123.456} 0 | |
| 963 | + th1-string-is-25 {string is integer 123abc} 0 | |
| 964 | + th1-string-is-26 {string is integer 0b11001001} 1 | |
| 965 | + th1-string-is-27 {string is integer 0b11001002} 0 | |
| 966 | + th1-string-is-28 {string is integer 0o777} 1 | |
| 967 | + th1-string-is-29 {string is integer 0o778} 0 | |
| 968 | + th1-string-is-30 {string is integer 0xC0DEF00D} 1 | |
| 969 | + th1-string-is-31 {string is integer 0xC0DEF00Z} 0 | |
| 970 | +} | |
| 971 | + | |
| 972 | +############################################################################### | |
| 973 | + | |
| 974 | +th1_cases { | |
| 975 | + th1-string-index-1 {string index "" -1} {} | |
| 976 | + th1-string-index-2 {string index "" 0} {} | |
| 977 | + th1-string-index-3 {string index "" 1} {} | |
| 978 | + th1-string-index-4 {string index "" 2} {} | |
| 979 | + th1-string-index-5 {string index "" end} {} | |
| 980 | + th1-string-index-6 {string index A -1} {} | |
| 981 | + th1-string-index-7 {string index A 0} A | |
| 982 | + th1-string-index-8 {string index A 1} {} | |
| 983 | + th1-string-index-9 {string index A 2} {} | |
| 984 | + th1-string-index-10 {string index A end} A | |
| 985 | + th1-string-index-11 {string index ABC -1} {} | |
| 986 | + th1-string-index-12 {string index ABC 0} A | |
| 987 | + th1-string-index-13 {string index ABC 1} B | |
| 988 | + th1-string-index-14 {string index ABC 2} C | |
| 989 | + th1-string-index-15 {string index ABC end} C | |
| 990 | +} | |
| 1549 | 991 | |
| 1550 | 992 | ############################################################################### |
| 1551 | 993 | |
| 1552 | 994 | fossil test-th-eval {markdown} |
| 1553 | 995 | test th1-markdown-1 {$RESULT eq \ |
| @@ -1628,17 +1070,14 @@ | ||
| 1628 | 1070 | </div> |
| 1629 | 1071 | }}} |
| 1630 | 1072 | |
| 1631 | 1073 | ############################################################################### |
| 1632 | 1074 | |
| 1633 | -fossil test-th-eval {encode64 test} | |
| 1634 | -test th1-encode64-1 {$RESULT eq "dGVzdA=="} | |
| 1635 | - | |
| 1636 | -############################################################################### | |
| 1637 | - | |
| 1638 | -fossil test-th-eval {encode64 test\x00} | |
| 1639 | -test th1-encode64-2 {$RESULT eq "dGVzdAA="} | |
| 1075 | +th1_cases { | |
| 1076 | + th1-encode64-1 {encode64 test} dGVzdA== | |
| 1077 | + th1-encode64-2 {encode64 test\x00} dGVzdAA= | |
| 1078 | +} | |
| 1640 | 1079 | |
| 1641 | 1080 | ############################################################################### |
| 1642 | 1081 | |
| 1643 | 1082 | fossil test-th-eval {array exists tcl_platform} |
| 1644 | 1083 | test th1-platform-1 {$RESULT eq "1"} |
| 1645 | 1084 |
| --- test/th1.test | |
| +++ test/th1.test | |
| @@ -23,29 +23,59 @@ | |
| 23 | ############################################################################### |
| 24 | |
| 25 | set th1Tcl [is_tcl_usable_by_fossil] |
| 26 | set th1Hooks [are_th1_hooks_usable_by_fossil] |
| 27 | |
| 28 | ############################################################################### |
| 29 | |
| 30 | fossil test-th-eval --open-config "setting abc" |
| 31 | test th1-setting-1 {$RESULT eq ""} |
| 32 | |
| 33 | ############################################################################### |
| 34 | |
| 35 | fossil test-th-eval --open-config "setting -- abc" |
| 36 | test th1-setting-2 {$RESULT eq ""} |
| 37 | |
| 38 | ############################################################################### |
| 39 | |
| 40 | fossil test-th-eval --open-config "setting -strict abc" |
| 41 | test th1-setting-3 {$RESULT eq {TH_ERROR: no value for setting "abc"}} |
| 42 | |
| 43 | ############################################################################### |
| 44 | |
| 45 | fossil test-th-eval --open-config "setting -strict -- abc" |
| 46 | test th1-setting-4 {$RESULT eq {TH_ERROR: no value for setting "abc"}} |
| 47 | |
| 48 | ############################################################################### |
| 49 | |
| 50 | fossil test-th-eval --open-config "setting autosync" |
| 51 | test th1-setting-5 {$RESULT eq 0 || $RESULT eq 1 || $RESULT eq "on"} |
| @@ -55,71 +85,31 @@ | |
| 55 | fossil test-th-eval --open-config "setting -strict autosync" |
| 56 | test th1-setting-6 {$RESULT eq 0 || $RESULT eq 1 || $RESULT eq "on"} |
| 57 | |
| 58 | ############################################################################### |
| 59 | |
| 60 | fossil test-th-eval --open-config "setting --" |
| 61 | test th1-setting-7 {$RESULT eq \ |
| 62 | {TH_ERROR: wrong # args: should be "setting ?-strict? ?--? name"}} |
| 63 | |
| 64 | ############################################################################### |
| 65 | |
| 66 | fossil test-th-eval --open-config "setting -strict --" |
| 67 | test th1-setting-8 {$RESULT eq \ |
| 68 | {TH_ERROR: wrong # args: should be "setting ?-strict? ?--? name"}} |
| 69 | |
| 70 | ############################################################################### |
| 71 | |
| 72 | fossil test-th-eval --open-config "setting -- --" |
| 73 | test th1-setting-9 {$RESULT eq {}} |
| 74 | |
| 75 | ############################################################################### |
| 76 | |
| 77 | fossil test-th-eval --open-config "setting -strict -- --" |
| 78 | test th1-setting-10 {$RESULT eq {TH_ERROR: no value for setting "--"}} |
| 79 | |
| 80 | ############################################################################### |
| 81 | |
| 82 | fossil test-th-eval "expr 42/0" |
| 83 | test th1-divide-by-zero-1 {$RESULT eq {TH_ERROR: Divide by 0: 42}} |
| 84 | |
| 85 | ############################################################################### |
| 86 | |
| 87 | fossil test-th-eval "expr 42/0.0" |
| 88 | test th1-divide-by-zero-2 {$RESULT eq {TH_ERROR: Divide by 0: 42}} |
| 89 | |
| 90 | ############################################################################### |
| 91 | |
| 92 | fossil test-th-eval "expr 42.0/0" |
| 93 | test th1-divide-by-zero-3 {$RESULT eq {TH_ERROR: Divide by 0: 42.0}} |
| 94 | |
| 95 | ############################################################################### |
| 96 | |
| 97 | fossil test-th-eval "expr 42.0/0.0" |
| 98 | test th1-divide-by-zero-4 {$RESULT eq {TH_ERROR: Divide by 0: 42.0}} |
| 99 | |
| 100 | ############################################################################### |
| 101 | |
| 102 | fossil test-th-eval "expr 42%0" |
| 103 | test th1-modulus-by-zero-1 {$RESULT eq {TH_ERROR: Modulo by 0: 42}} |
| 104 | |
| 105 | ############################################################################### |
| 106 | |
| 107 | fossil test-th-eval "expr 42%0.0" |
| 108 | test th1-modulus-by-zero-2 {$RESULT eq {TH_ERROR: expected integer, got: "0.0"}} |
| 109 | |
| 110 | ############################################################################### |
| 111 | |
| 112 | fossil test-th-eval "expr 42.0%0" |
| 113 | test th1-modulus-by-zero-3 {$RESULT eq \ |
| 114 | {TH_ERROR: expected integer, got: "42.0"}} |
| 115 | |
| 116 | ############################################################################### |
| 117 | |
| 118 | fossil test-th-eval "expr 42.0%0.0" |
| 119 | test th1-modulus-by-zero-4 {$RESULT eq \ |
| 120 | {TH_ERROR: expected integer, got: "42.0"}} |
| 121 | |
| 122 | ############################################################################### |
| 123 | |
| 124 | fossil test-th-eval "set var 1; info exists var" |
| 125 | test th1-info-exists-1 {$RESULT eq {1}} |
| @@ -219,471 +209,175 @@ | |
| 219 | fossil test-th-eval "set gv(1) 1; upvar 0 gv(1) gv2; unset gv(1); unset gv2" |
| 220 | test th1-unset-8 {$RESULT eq {TH_ERROR: no such variable: gv2}} |
| 221 | |
| 222 | ############################################################################### |
| 223 | |
| 224 | fossil test-th-eval "string first {} {}" |
| 225 | test th1-string-first-1 {$RESULT eq {-1}} |
| 226 | |
| 227 | ############################################################################### |
| 228 | |
| 229 | fossil test-th-eval "string first {} {a}" |
| 230 | test th1-string-first-2 {$RESULT eq {-1}} |
| 231 | |
| 232 | ############################################################################### |
| 233 | |
| 234 | fossil test-th-eval "string first {a} {}" |
| 235 | test th1-string-first-3 {$RESULT eq {-1}} |
| 236 | |
| 237 | ############################################################################### |
| 238 | |
| 239 | fossil test-th-eval "string first {a} {a}" |
| 240 | test th1-string-first-4 {$RESULT eq {0}} |
| 241 | |
| 242 | ############################################################################### |
| 243 | |
| 244 | fossil test-th-eval "string first {a} {aa}" |
| 245 | test th1-string-first-5 {$RESULT eq {0}} |
| 246 | |
| 247 | ############################################################################### |
| 248 | |
| 249 | fossil test-th-eval "string first {aa} {a}" |
| 250 | test th1-string-first-6 {$RESULT eq {-1}} |
| 251 | |
| 252 | ############################################################################### |
| 253 | |
| 254 | fossil test-th-eval "string first {ab} {abc}" |
| 255 | test th1-string-first-7 {$RESULT eq {0}} |
| 256 | |
| 257 | ############################################################################### |
| 258 | |
| 259 | fossil test-th-eval "string first {bc} {abc}" |
| 260 | test th1-string-first-8 {$RESULT eq {1}} |
| 261 | |
| 262 | ############################################################################### |
| 263 | |
| 264 | fossil test-th-eval "string first {AB} {abc}" |
| 265 | test th1-string-first-9 {$RESULT eq {-1}} |
| 266 | |
| 267 | ############################################################################### |
| 268 | |
| 269 | fossil test-th-eval "string last {} {}" |
| 270 | test th1-string-last-1 {$RESULT eq {-1}} |
| 271 | |
| 272 | ############################################################################### |
| 273 | |
| 274 | fossil test-th-eval "string last {} {a}" |
| 275 | test th1-string-last-2 {$RESULT eq {-1}} |
| 276 | |
| 277 | ############################################################################### |
| 278 | |
| 279 | fossil test-th-eval "string last {a} {}" |
| 280 | test th1-string-last-3 {$RESULT eq {-1}} |
| 281 | |
| 282 | ############################################################################### |
| 283 | |
| 284 | fossil test-th-eval "string last {a} {a}" |
| 285 | test th1-string-last-4 {$RESULT eq {0}} |
| 286 | |
| 287 | ############################################################################### |
| 288 | |
| 289 | fossil test-th-eval "string last {a} {aa}" |
| 290 | test th1-string-last-5 {$RESULT eq {1}} |
| 291 | |
| 292 | ############################################################################### |
| 293 | |
| 294 | fossil test-th-eval "string last {aa} {a}" |
| 295 | test th1-string-last-6 {$RESULT eq {-1}} |
| 296 | |
| 297 | ############################################################################### |
| 298 | |
| 299 | fossil test-th-eval "string last {ab} {abc}" |
| 300 | test th1-string-last-7 {$RESULT eq {0}} |
| 301 | |
| 302 | ############################################################################### |
| 303 | |
| 304 | fossil test-th-eval "string last {bc} {abc}" |
| 305 | test th1-string-last-8 {$RESULT eq {1}} |
| 306 | |
| 307 | ############################################################################### |
| 308 | |
| 309 | fossil test-th-eval "string last {AB} {abc}" |
| 310 | test th1-string-last-9 {$RESULT eq {-1}} |
| 311 | |
| 312 | ############################################################################### |
| 313 | |
| 314 | fossil test-th-eval "expr -2147483649.0" |
| 315 | test th1-expr-1 {$RESULT eq {-2147483649.0}} |
| 316 | |
| 317 | ############################################################################### |
| 318 | |
| 319 | fossil test-th-eval "expr -2147483649" |
| 320 | test th1-expr-2 {$RESULT eq {2147483647}} |
| 321 | |
| 322 | ############################################################################### |
| 323 | |
| 324 | fossil test-th-eval "expr -2147483648" |
| 325 | test th1-expr-3 {$RESULT eq {-2147483648}} |
| 326 | |
| 327 | ############################################################################### |
| 328 | |
| 329 | fossil test-th-eval "expr -2147483647" |
| 330 | test th1-expr-4 {$RESULT eq {-2147483647}} |
| 331 | |
| 332 | ############################################################################### |
| 333 | |
| 334 | fossil test-th-eval "expr -1" |
| 335 | test th1-expr-5 {$RESULT eq {-1}} |
| 336 | |
| 337 | ############################################################################### |
| 338 | |
| 339 | fossil test-th-eval "expr 0" |
| 340 | test th1-expr-6 {$RESULT eq {0}} |
| 341 | |
| 342 | ############################################################################### |
| 343 | |
| 344 | fossil test-th-eval "expr 0.0" |
| 345 | test th1-expr-7 {$RESULT eq {0.0}} |
| 346 | |
| 347 | ############################################################################### |
| 348 | |
| 349 | fossil test-th-eval "expr 1" |
| 350 | test th1-expr-8 {$RESULT eq {1}} |
| 351 | |
| 352 | ############################################################################### |
| 353 | |
| 354 | fossil test-th-eval "expr 2147483647" |
| 355 | test th1-expr-9 {$RESULT eq {2147483647}} |
| 356 | |
| 357 | ############################################################################### |
| 358 | |
| 359 | fossil test-th-eval "expr 2147483648" |
| 360 | test th1-expr-10 {$RESULT eq {2147483648}} |
| 361 | |
| 362 | ############################################################################### |
| 363 | |
| 364 | fossil test-th-eval "expr 2147483649" |
| 365 | test th1-expr-11 {$RESULT eq {2147483649}} |
| 366 | |
| 367 | ############################################################################### |
| 368 | |
| 369 | fossil test-th-eval "expr +2147483649" |
| 370 | test th1-expr-12 {$RESULT eq {-2147483647}} |
| 371 | |
| 372 | ############################################################################### |
| 373 | |
| 374 | fossil test-th-eval "expr +2147483649.0" |
| 375 | test th1-expr-13 {$RESULT eq {2147483649.0}} |
| 376 | |
| 377 | ############################################################################### |
| 378 | |
| 379 | fossil test-th-eval "expr ~(-1)" |
| 380 | test th1-expr-14 {$RESULT eq {0}} |
| 381 | |
| 382 | ############################################################################### |
| 383 | |
| 384 | fossil test-th-eval "expr ~-1" |
| 385 | test th1-expr-15 {$RESULT eq {0}} |
| 386 | |
| 387 | ############################################################################### |
| 388 | |
| 389 | fossil test-th-eval "expr ~0" |
| 390 | test th1-expr-16 {$RESULT eq {-1}} |
| 391 | |
| 392 | ############################################################################### |
| 393 | |
| 394 | fossil test-th-eval "expr ~+0" |
| 395 | test th1-expr-17 {$RESULT eq {-1}} |
| 396 | |
| 397 | ############################################################################### |
| 398 | |
| 399 | fossil test-th-eval "expr ~-0" |
| 400 | test th1-expr-18 {$RESULT eq {-1}} |
| 401 | |
| 402 | ############################################################################### |
| 403 | |
| 404 | fossil test-th-eval "expr ~(+0)" |
| 405 | test th1-expr-19 {$RESULT eq {-1}} |
| 406 | |
| 407 | ############################################################################### |
| 408 | |
| 409 | fossil test-th-eval "expr ~(-0)" |
| 410 | test th1-expr-20 {$RESULT eq {-1}} |
| 411 | |
| 412 | ############################################################################### |
| 413 | |
| 414 | fossil test-th-eval "expr ~1" |
| 415 | test th1-expr-21 {$RESULT eq {-2}} |
| 416 | |
| 417 | ############################################################################### |
| 418 | |
| 419 | fossil test-th-eval "expr ~+1" |
| 420 | test th1-expr-22 {$RESULT eq {-2}} |
| 421 | |
| 422 | ############################################################################### |
| 423 | |
| 424 | fossil test-th-eval "expr ~(+1)" |
| 425 | test th1-expr-23 {$RESULT eq {-2}} |
| 426 | |
| 427 | ############################################################################### |
| 428 | |
| 429 | fossil test-th-eval "expr 0+0b11" |
| 430 | test th1-expr-24 {$RESULT eq 3} |
| 431 | |
| 432 | ############################################################################### |
| 433 | |
| 434 | fossil test-th-eval "expr 0+0o15" |
| 435 | test th1-expr-25 {$RESULT eq 13} |
| 436 | |
| 437 | ############################################################################### |
| 438 | |
| 439 | fossil test-th-eval "expr 0+0x15" |
| 440 | test th1-expr-26 {$RESULT eq 21} |
| 441 | |
| 442 | ############################################################################### |
| 443 | |
| 444 | fossil test-th-eval "expr 0+0b2" |
| 445 | test th1-expr-27 {$RESULT eq {TH_ERROR: expected number, got: "0b2"}} |
| 446 | |
| 447 | ############################################################################### |
| 448 | |
| 449 | fossil test-th-eval "expr 0+0o8" |
| 450 | test th1-expr-28 {$RESULT eq {TH_ERROR: expected number, got: "0o8"}} |
| 451 | |
| 452 | ############################################################################### |
| 453 | |
| 454 | fossil test-th-eval "expr 0+0xg" |
| 455 | test th1-expr-29 {$RESULT eq {TH_ERROR: syntax error in expression: "0+0xg"}} |
| 456 | |
| 457 | ############################################################################### |
| 458 | |
| 459 | fossil test-th-eval "expr 0+0b1." |
| 460 | test th1-expr-30 {$RESULT eq {TH_ERROR: syntax error in expression: "0+0b1."}} |
| 461 | |
| 462 | ############################################################################### |
| 463 | |
| 464 | fossil test-th-eval "expr 0+0o1." |
| 465 | test th1-expr-31 {$RESULT eq {TH_ERROR: syntax error in expression: "0+0o1."}} |
| 466 | |
| 467 | ############################################################################### |
| 468 | |
| 469 | fossil test-th-eval "expr 0+0x1." |
| 470 | test th1-expr-32 {$RESULT eq {TH_ERROR: syntax error in expression: "0+0x1."}} |
| 471 | |
| 472 | ############################################################################### |
| 473 | |
| 474 | fossil test-th-eval "expr 0ne5" |
| 475 | test th1-expr-33 {$RESULT eq {1}} |
| 476 | |
| 477 | ############################################################################### |
| 478 | |
| 479 | fossil test-th-eval "expr 0b1+5" |
| 480 | test th1-expr-34 {$RESULT eq {6}} |
| 481 | |
| 482 | ############################################################################### |
| 483 | |
| 484 | fossil test-th-eval "expr 0+0b" |
| 485 | test th1-expr-35 {$RESULT eq {TH_ERROR: expected number, got: "0b"}} |
| 486 | |
| 487 | ############################################################################### |
| 488 | |
| 489 | fossil test-th-eval "expr (-1)+1" |
| 490 | test th1-expr-36 {$RESULT eq {0}} |
| 491 | |
| 492 | ############################################################################### |
| 493 | |
| 494 | fossil test-th-eval "expr (((-1)))" |
| 495 | test th1-expr-37 {$RESULT eq {-1}} |
| 496 | |
| 497 | ############################################################################### |
| 498 | |
| 499 | fossil test-th-eval "expr (((1)))" |
| 500 | test th1-expr-38 {$RESULT eq {1}} |
| 501 | |
| 502 | ############################################################################### |
| 503 | |
| 504 | fossil test-th-eval "expr (((1))" |
| 505 | test th1-expr-39 {$RESULT eq {TH_ERROR: syntax error in expression: "(((1))"}} |
| 506 | |
| 507 | ############################################################################### |
| 508 | |
| 509 | fossil test-th-eval "expr ((1)))" |
| 510 | test th1-expr-40 {$RESULT eq {TH_ERROR: syntax error in expression: "((1)))"}} |
| 511 | |
| 512 | ############################################################################### |
| 513 | |
| 514 | fossil test-th-eval "expr (((1)*2)*2)" |
| 515 | test th1-expr-41 {$RESULT eq {4}} |
| 516 | |
| 517 | ############################################################################### |
| 518 | |
| 519 | fossil test-th-eval "expr +" |
| 520 | test th1-expr-42 {$RESULT eq {TH_ERROR: syntax error in expression: "+"}} |
| 521 | |
| 522 | ############################################################################### |
| 523 | |
| 524 | fossil test-th-eval "expr -" |
| 525 | test th1-expr-43 {$RESULT eq {TH_ERROR: syntax error in expression: "-"}} |
| 526 | |
| 527 | ############################################################################### |
| 528 | |
| 529 | fossil test-th-eval "expr ++" |
| 530 | test th1-expr-44 {$RESULT eq {TH_ERROR: syntax error in expression: "++"}} |
| 531 | |
| 532 | ############################################################################### |
| 533 | |
| 534 | fossil test-th-eval "expr --" |
| 535 | test th1-expr-45 {$RESULT eq {TH_ERROR: syntax error in expression: "--"}} |
| 536 | |
| 537 | ############################################################################### |
| 538 | |
| 539 | fossil test-th-eval "lindex list +" |
| 540 | test th1-lindex-bad-1 {$RESULT eq {TH_ERROR: expected integer, got: "+"}} |
| 541 | |
| 542 | ############################################################################### |
| 543 | |
| 544 | fossil test-th-eval "lindex list -" |
| 545 | test th1-lindex-bad-2 {$RESULT eq {TH_ERROR: expected integer, got: "-"}} |
| 546 | |
| 547 | ############################################################################### |
| 548 | |
| 549 | fossil test-th-eval "lindex list +0x" |
| 550 | test th1-lindex-bad-3 {$RESULT eq {TH_ERROR: expected integer, got: "+0x"}} |
| 551 | |
| 552 | ############################################################################### |
| 553 | |
| 554 | fossil test-th-eval "lindex list -0x" |
| 555 | test th1-lindex-bad-4 {$RESULT eq {TH_ERROR: expected integer, got: "-0x"}} |
| 556 | |
| 557 | ############################################################################### |
| 558 | |
| 559 | set skip_anycap 1 |
| 560 | if {$::outside_fossil_repo} { |
| 561 | test_skip_part "th1-anycap-*-1 perm tests: not in Fossil repo checkout." |
| 562 | } elseif ($::dirty_ckout) { |
| 563 | test_skip_part "th1-anycap-*-1 perm tests: uncommitted changes in\ |
| 564 | Fossil checkout." |
| 565 | } else { |
| 566 | set skip_anycap 0 |
| 567 | } |
| 568 | |
| 569 | # NOTE: The 'd' permission is no longer used. |
| 570 | foreach perm [list \ |
| 571 | a b c e f g h i j k l m n o p q r s t u v w x y z \ |
| 572 | A D \ |
| 573 | 2 3 4 5 6 7 ] { |
| 574 | if {$perm eq "u"} continue; # NOTE: Skip "reader" meta-permission. |
| 575 | if {$perm eq "v"} continue; # NOTE: Skip "developer" meta-permission. |
| 576 | |
| 577 | set ::env(TH1_TEST_USER_CAPS) sxy |
| 578 | fossil test-th-eval "anycap $perm" |
| 579 | test th1-anycap-no-$perm-1 {$RESULT eq {0}} |
| 580 | |
| 581 | fossil test-th-eval "hascap $perm" |
| 582 | test th1-hascap-no-$perm-1 {$RESULT eq {0}} |
| 583 | |
| 584 | fossil test-th-eval "anoncap $perm" |
| 585 | test th1-anoncap-no-$perm-1 {$RESULT eq {0}} |
| 586 | |
| 587 | if {$skip_anycap} { continue } |
| 588 | |
| 589 | run_in_checkout { |
| 590 | set ::env(TH1_TEST_USER_CAPS) sxy |
| 591 | fossil test-th-eval --set-user-caps "anycap $perm" |
| 592 | test th1-anycap-yes-$perm-1 {$RESULT eq {1}} |
| 593 | |
| 594 | set ::env(TH1_TEST_USER_CAPS) 1; # NOTE: Bad permission. |
| 595 | fossil test-th-eval --set-user-caps "anycap $perm" |
| 596 | test th1-anycap-no-$perm-2 {$RESULT eq {0}} |
| 597 | |
| 598 | set ::env(TH1_TEST_USER_CAPS) sxy |
| 599 | fossil test-th-eval --set-user-caps "hascap $perm" |
| 600 | test th1-hascap-yes-$perm-1 {$RESULT eq {1}} |
| 601 | |
| 602 | set ::env(TH1_TEST_USER_CAPS) 1; # NOTE: Bad permission. |
| 603 | fossil test-th-eval --set-user-caps "hascap $perm" |
| 604 | test th1-hascap-no-$perm-2 {$RESULT eq {0}} |
| 605 | unset ::env(TH1_TEST_USER_CAPS) |
| 606 | |
| 607 | set ::env(TH1_TEST_ANON_CAPS) sxy |
| 608 | fossil test-th-eval --set-anon-caps "anoncap $perm" |
| 609 | test th1-anoncap-yes-$perm-1 {$RESULT eq {1}} |
| 610 | |
| 611 | set ::env(TH1_TEST_ANON_CAPS) 1; # NOTE: Bad permission. |
| 612 | fossil test-th-eval --set-anon-caps "anoncap $perm" |
| 613 | test th1-anoncap-no-$perm-2 {$RESULT eq {0}} |
| 614 | unset ::env(TH1_TEST_ANON_CAPS) |
| 615 | } |
| 616 | } |
| 617 | |
| 618 | ############################################################################### |
| 619 | |
| 620 | fossil test-th-eval "anycap oh" |
| 621 | test th1-anycap-no-multiple-1 {$RESULT eq {0}} |
| 622 | |
| 623 | ############################################################################### |
| 624 | |
| 625 | fossil test-th-eval "hascap oh" |
| 626 | test th1-hascap-no-multiple-1 {$RESULT eq {0}} |
| 627 | |
| 628 | ############################################################################### |
| 629 | |
| 630 | fossil test-th-eval "hascap o h" |
| 631 | test th1-hascap-no-multiple-2 {$RESULT eq {0}} |
| 632 | |
| 633 | ############################################################################### |
| 634 | |
| 635 | fossil test-th-eval "anoncap oh" |
| 636 | test th1-anoncap-no-multiple-1 {$RESULT eq {0}} |
| 637 | |
| 638 | ############################################################################### |
| 639 | |
| 640 | fossil test-th-eval "anoncap o h" |
| 641 | test th1-anoncap-no-multiple-2 {$RESULT eq {0}} |
| 642 | |
| 643 | ############################################################################### |
| 644 | |
| 645 | test_block_in_checkout "test-anoncap-*" { |
| 646 | fossil test-th-eval --set-user-caps "anycap oh" |
| 647 | test th1-anycap-yes-multiple-1 {$RESULT eq {1}} |
| 648 | |
| 649 | set ::env(TH1_TEST_USER_CAPS) o |
| 650 | fossil test-th-eval --set-user-caps "anycap oh" |
| 651 | test th1-anycap-yes-multiple-2 {$RESULT eq {1}} |
| 652 | unset ::env(TH1_TEST_USER_CAPS) |
| 653 | |
| 654 | fossil test-th-eval --set-user-caps "hascap oh" |
| 655 | test th1-hascap-yes-multiple-1 {$RESULT eq {1}} |
| 656 | |
| 657 | set ::env(TH1_TEST_USER_CAPS) o |
| 658 | fossil test-th-eval --set-user-caps "hascap oh" |
| 659 | test th1-hascap-no-multiple-3 {$RESULT eq {0}} |
| 660 | unset ::env(TH1_TEST_USER_CAPS) |
| 661 | |
| 662 | fossil test-th-eval --set-user-caps "hascap o h" |
| 663 | test th1-hascap-yes-multiple-2 {$RESULT eq {1}} |
| 664 | |
| 665 | set ::env(TH1_TEST_USER_CAPS) o |
| 666 | fossil test-th-eval --set-user-caps "hascap o h" |
| 667 | test th1-hascap-no-multiple-4 {$RESULT eq {0}} |
| 668 | unset ::env(TH1_TEST_USER_CAPS) |
| 669 | |
| 670 | fossil test-th-eval --set-anon-caps "anoncap oh" |
| 671 | test th1-anoncap-yes-multiple-1 {$RESULT eq {1}} |
| 672 | |
| 673 | set ::env(TH1_TEST_ANON_CAPS) o |
| 674 | fossil test-th-eval --set-anon-caps "anoncap oh" |
| 675 | test th1-anoncap-no-multiple-3 {$RESULT eq {0}} |
| 676 | unset ::env(TH1_TEST_ANON_CAPS) |
| 677 | |
| 678 | fossil test-th-eval --set-anon-caps "anoncap o h" |
| 679 | test th1-anoncap-yes-multiple-2 {$RESULT eq {1}} |
| 680 | |
| 681 | set ::env(TH1_TEST_ANON_CAPS) o |
| 682 | fossil test-th-eval --set-anon-caps "anoncap o h" |
| 683 | test th1-anoncap-no-multiple-4 {$RESULT eq {0}} |
| 684 | unset ::env(TH1_TEST_ANON_CAPS) |
| 685 | } |
| 686 | |
| 687 | ############################################################################### |
| 688 | |
| 689 | test_in_checkout th1-checkout-1 { |
| @@ -1189,365 +883,113 @@ | |
| 1189 | fossil test-th-eval "set foo(x) 2; unset foo(x); array names foo" |
| 1190 | test th1-array-names-6 {$RESULT eq ""} |
| 1191 | |
| 1192 | ############################################################################### |
| 1193 | |
| 1194 | fossil test-th-eval "lsearch" |
| 1195 | test th1-lsearch-1 {$RESULT eq \ |
| 1196 | {TH_ERROR: wrong # args: should be "lsearch list string"}} |
| 1197 | |
| 1198 | ############################################################################### |
| 1199 | |
| 1200 | fossil test-th-eval "lsearch a" |
| 1201 | test th1-lsearch-2 {$RESULT eq \ |
| 1202 | {TH_ERROR: wrong # args: should be "lsearch list string"}} |
| 1203 | |
| 1204 | ############################################################################### |
| 1205 | |
| 1206 | fossil test-th-eval "lsearch a a a" |
| 1207 | test th1-lsearch-3 {$RESULT eq \ |
| 1208 | {TH_ERROR: wrong # args: should be "lsearch list string"}} |
| 1209 | |
| 1210 | ############################################################################### |
| 1211 | |
| 1212 | fossil test-th-eval "lsearch {a b c} a" |
| 1213 | test th1-lsearch-4 {$RESULT eq "0"} |
| 1214 | |
| 1215 | ############################################################################### |
| 1216 | |
| 1217 | fossil test-th-eval "lsearch {a b c} b" |
| 1218 | test th1-lsearch-5 {$RESULT eq "1"} |
| 1219 | |
| 1220 | ############################################################################### |
| 1221 | |
| 1222 | fossil test-th-eval "lsearch {a b c} c" |
| 1223 | test th1-lsearch-6 {$RESULT eq "2"} |
| 1224 | |
| 1225 | ############################################################################### |
| 1226 | |
| 1227 | fossil test-th-eval "lsearch {a b c} d" |
| 1228 | test th1-lsearch-7 {$RESULT eq "-1"} |
| 1229 | |
| 1230 | ############################################################################### |
| 1231 | |
| 1232 | fossil test-th-eval "lsearch {a b c} aa" |
| 1233 | test th1-lsearch-8 {$RESULT eq "-1"} |
| 1234 | |
| 1235 | ############################################################################### |
| 1236 | |
| 1237 | fossil test-th-eval "lsearch {aa b c} a" |
| 1238 | test th1-lsearch-9 {$RESULT eq "-1"} |
| 1239 | |
| 1240 | ############################################################################### |
| 1241 | |
| 1242 | fossil test-th-eval "lsearch \"\{aa b c\" a" |
| 1243 | test th1-lsearch-10 {$RESULT eq "TH_ERROR: Expected list, got: \"\{aa b c\""} |
| 1244 | |
| 1245 | ############################################################################### |
| 1246 | |
| 1247 | fossil test-th-eval "glob_match" |
| 1248 | test th1-glob-match-1 {$RESULT eq \ |
| 1249 | {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} |
| 1250 | |
| 1251 | ############################################################################### |
| 1252 | |
| 1253 | fossil test-th-eval "glob_match -one" |
| 1254 | test th1-glob-match-2 {$RESULT eq \ |
| 1255 | {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} |
| 1256 | |
| 1257 | ############################################################################### |
| 1258 | |
| 1259 | fossil test-th-eval "glob_match --" |
| 1260 | test th1-glob-match-3 {$RESULT eq \ |
| 1261 | {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} |
| 1262 | |
| 1263 | ############################################################################### |
| 1264 | |
| 1265 | fossil test-th-eval "glob_match -one --" |
| 1266 | test th1-glob-match-4 {$RESULT eq \ |
| 1267 | {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} |
| 1268 | |
| 1269 | ############################################################################### |
| 1270 | |
| 1271 | fossil test-th-eval "glob_match -one -- 1" |
| 1272 | test th1-glob-match-5 {$RESULT eq \ |
| 1273 | {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} |
| 1274 | |
| 1275 | ############################################################################### |
| 1276 | |
| 1277 | fossil test-th-eval "glob_match -one -- 1 2 3" |
| 1278 | test th1-glob-match-6 {$RESULT eq \ |
| 1279 | {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} |
| 1280 | |
| 1281 | ############################################################################### |
| 1282 | |
| 1283 | fossil test-th-eval {list [glob_match a A] [glob_match A a]} |
| 1284 | test th1-glob-match-7 {$RESULT eq "0 0"} |
| 1285 | |
| 1286 | ############################################################################### |
| 1287 | |
| 1288 | fossil test-th-eval {list [glob_match a,b a] [glob_match a,b b]} |
| 1289 | test th1-glob-match-8 {$RESULT eq "1 2"} |
| 1290 | |
| 1291 | ############################################################################### |
| 1292 | |
| 1293 | fossil test-th-eval {list [glob_match -one a,b a] [glob_match -one a,b b]} |
| 1294 | test th1-glob-match-9 {$RESULT eq "0 0"} |
| 1295 | |
| 1296 | ############################################################################### |
| 1297 | |
| 1298 | fossil test-th-eval {list [glob_match -one a,b a,b] [glob_match -one a b,a]} |
| 1299 | test th1-glob-match-10 {$RESULT eq "1 0"} |
| 1300 | |
| 1301 | ############################################################################### |
| 1302 | |
| 1303 | fossil test-th-eval {list [glob_match a*c abc] [glob_match abc a*c]} |
| 1304 | test th1-glob-match-11 {$RESULT eq "1 0"} |
| 1305 | |
| 1306 | ############################################################################### |
| 1307 | |
| 1308 | fossil test-th-eval {list [glob_match a?c abc] [glob_match abc a?c]} |
| 1309 | test th1-glob-match-12 {$RESULT eq "1 0"} |
| 1310 | |
| 1311 | ############################################################################### |
| 1312 | |
| 1313 | fossil test-th-eval {list [glob_match {a[bd]c} abc] [glob_match abc {a[bd]c}]} |
| 1314 | test th1-glob-match-13 {$RESULT eq "1 0"} |
| 1315 | |
| 1316 | ############################################################################### |
| 1317 | |
| 1318 | fossil test-th-eval {string is} |
| 1319 | test th1-string-is-1 {$RESULT eq \ |
| 1320 | {TH_ERROR: wrong # args: should be "string is class string"}} |
| 1321 | |
| 1322 | ############################################################################### |
| 1323 | |
| 1324 | fossil test-th-eval {string is something} |
| 1325 | test th1-string-is-2 {$RESULT eq \ |
| 1326 | {TH_ERROR: wrong # args: should be "string is class string"}} |
| 1327 | |
| 1328 | ############################################################################### |
| 1329 | |
| 1330 | fossil test-th-eval {string is not something else} |
| 1331 | test th1-string-is-3 {$RESULT eq \ |
| 1332 | {TH_ERROR: wrong # args: should be "string is class string"}} |
| 1333 | |
| 1334 | ############################################################################### |
| 1335 | |
| 1336 | fossil test-th-eval {string is other 123} |
| 1337 | test th1-string-is-4 {$RESULT eq \ |
| 1338 | "TH_ERROR: Expected alnum, double, integer, list, or tainted, got: other"} |
| 1339 | |
| 1340 | ############################################################################### |
| 1341 | |
| 1342 | fossil test-th-eval {string is alnum 123} |
| 1343 | test th1-string-is-5 {$RESULT eq "1"} |
| 1344 | |
| 1345 | ############################################################################### |
| 1346 | |
| 1347 | fossil test-th-eval {string is alnum abc} |
| 1348 | test th1-string-is-6 {$RESULT eq "1"} |
| 1349 | |
| 1350 | ############################################################################### |
| 1351 | |
| 1352 | fossil test-th-eval {string is alnum 123abc} |
| 1353 | test th1-string-is-7 {$RESULT eq "1"} |
| 1354 | |
| 1355 | ############################################################################### |
| 1356 | |
| 1357 | fossil test-th-eval {string is alnum abc123} |
| 1358 | test th1-string-is-8 {$RESULT eq "1"} |
| 1359 | |
| 1360 | ############################################################################### |
| 1361 | |
| 1362 | fossil test-th-eval {string is alnum _abc123} |
| 1363 | test th1-string-is-9 {$RESULT eq "0"} |
| 1364 | |
| 1365 | ############################################################################### |
| 1366 | |
| 1367 | fossil test-th-eval {string is alnum abc.123} |
| 1368 | test th1-string-is-10 {$RESULT eq "0"} |
| 1369 | |
| 1370 | ############################################################################### |
| 1371 | |
| 1372 | fossil test-th-eval {string is alnum abc123_} |
| 1373 | test th1-string-is-11 {$RESULT eq "0"} |
| 1374 | |
| 1375 | ############################################################################### |
| 1376 | |
| 1377 | fossil test-th-eval {string is list ""} |
| 1378 | test th1-string-is-12 {$RESULT eq "1"} |
| 1379 | |
| 1380 | ############################################################################### |
| 1381 | |
| 1382 | fossil test-th-eval {string is list 1} |
| 1383 | test th1-string-is-13 {$RESULT eq "1"} |
| 1384 | |
| 1385 | ############################################################################### |
| 1386 | |
| 1387 | fossil test-th-eval {string is list "1 2 3"} |
| 1388 | test th1-string-is-14 {$RESULT eq "1"} |
| 1389 | |
| 1390 | ############################################################################### |
| 1391 | |
| 1392 | fossil test-th-eval {string is list "\{"} |
| 1393 | test th1-string-is-15 {$RESULT eq "0"} |
| 1394 | |
| 1395 | ############################################################################### |
| 1396 | |
| 1397 | fossil test-th-eval {string is list "1 2 3 \{"} |
| 1398 | test th1-string-is-16 {$RESULT eq "0"} |
| 1399 | |
| 1400 | ############################################################################### |
| 1401 | |
| 1402 | fossil test-th-eval {string is list "1 2 3 \{\}"} |
| 1403 | test th1-string-is-17 {$RESULT eq "1"} |
| 1404 | |
| 1405 | ############################################################################### |
| 1406 | |
| 1407 | fossil test-th-eval {string is list "1 2 3 \{\{\}"} |
| 1408 | test th1-string-is-18 {$RESULT eq "0"} |
| 1409 | |
| 1410 | ############################################################################### |
| 1411 | |
| 1412 | fossil test-th-eval {string is double 123} |
| 1413 | test th1-string-is-19 {$RESULT eq "1"} |
| 1414 | |
| 1415 | ############################################################################### |
| 1416 | |
| 1417 | fossil test-th-eval {string is double 123.456} |
| 1418 | test th1-string-is-20 {$RESULT eq "1"} |
| 1419 | |
| 1420 | ############################################################################### |
| 1421 | |
| 1422 | fossil test-th-eval {string is double 123abc} |
| 1423 | test th1-string-is-21 {$RESULT eq "0"} |
| 1424 | |
| 1425 | ############################################################################### |
| 1426 | |
| 1427 | fossil test-th-eval {string is double 123_456} |
| 1428 | test th1-string-is-22 {$RESULT eq "0"} |
| 1429 | |
| 1430 | ############################################################################### |
| 1431 | |
| 1432 | fossil test-th-eval {string is integer 123} |
| 1433 | test th1-string-is-23 {$RESULT eq "1"} |
| 1434 | |
| 1435 | ############################################################################### |
| 1436 | |
| 1437 | fossil test-th-eval {string is integer 123.456} |
| 1438 | test th1-string-is-24 {$RESULT eq "0"} |
| 1439 | |
| 1440 | ############################################################################### |
| 1441 | |
| 1442 | fossil test-th-eval {string is integer 123abc} |
| 1443 | test th1-string-is-25 {$RESULT eq "0"} |
| 1444 | |
| 1445 | ############################################################################### |
| 1446 | |
| 1447 | fossil test-th-eval {string is integer 0b11001001} |
| 1448 | test th1-string-is-26 {$RESULT eq "1"} |
| 1449 | |
| 1450 | ############################################################################### |
| 1451 | |
| 1452 | fossil test-th-eval {string is integer 0b11001002} |
| 1453 | test th1-string-is-27 {$RESULT eq "0"} |
| 1454 | |
| 1455 | ############################################################################### |
| 1456 | |
| 1457 | fossil test-th-eval {string is integer 0o777} |
| 1458 | test th1-string-is-28 {$RESULT eq "1"} |
| 1459 | |
| 1460 | ############################################################################### |
| 1461 | |
| 1462 | fossil test-th-eval {string is integer 0o778} |
| 1463 | test th1-string-is-29 {$RESULT eq "0"} |
| 1464 | |
| 1465 | ############################################################################### |
| 1466 | |
| 1467 | fossil test-th-eval {string is integer 0xC0DEF00D} |
| 1468 | test th1-string-is-30 {$RESULT eq "1"} |
| 1469 | |
| 1470 | ############################################################################### |
| 1471 | |
| 1472 | fossil test-th-eval {string is integer 0xC0DEF00Z} |
| 1473 | test th1-string-is-31 {$RESULT eq "0"} |
| 1474 | |
| 1475 | ############################################################################### |
| 1476 | |
| 1477 | fossil test-th-eval {string index "" -1} |
| 1478 | test th1-string-index-1 {$RESULT eq ""} |
| 1479 | |
| 1480 | ############################################################################### |
| 1481 | |
| 1482 | fossil test-th-eval {string index "" 0} |
| 1483 | test th1-string-index-2 {$RESULT eq ""} |
| 1484 | |
| 1485 | ############################################################################### |
| 1486 | |
| 1487 | fossil test-th-eval {string index "" 1} |
| 1488 | test th1-string-index-3 {$RESULT eq ""} |
| 1489 | |
| 1490 | ############################################################################### |
| 1491 | |
| 1492 | fossil test-th-eval {string index "" 2} |
| 1493 | test th1-string-index-4 {$RESULT eq ""} |
| 1494 | |
| 1495 | ############################################################################### |
| 1496 | |
| 1497 | fossil test-th-eval {string index "" end} |
| 1498 | test th1-string-index-5 {$RESULT eq ""} |
| 1499 | |
| 1500 | ############################################################################### |
| 1501 | |
| 1502 | fossil test-th-eval {string index A -1} |
| 1503 | test th1-string-index-6 {$RESULT eq ""} |
| 1504 | |
| 1505 | ############################################################################### |
| 1506 | |
| 1507 | fossil test-th-eval {string index A 0} |
| 1508 | test th1-string-index-7 {$RESULT eq "A"} |
| 1509 | |
| 1510 | ############################################################################### |
| 1511 | |
| 1512 | fossil test-th-eval {string index A 1} |
| 1513 | test th1-string-index-8 {$RESULT eq ""} |
| 1514 | |
| 1515 | ############################################################################### |
| 1516 | |
| 1517 | fossil test-th-eval {string index A 2} |
| 1518 | test th1-string-index-9 {$RESULT eq ""} |
| 1519 | |
| 1520 | ############################################################################### |
| 1521 | |
| 1522 | fossil test-th-eval {string index A end} |
| 1523 | test th1-string-index-10 {$RESULT eq "A"} |
| 1524 | |
| 1525 | ############################################################################### |
| 1526 | |
| 1527 | fossil test-th-eval {string index ABC -1} |
| 1528 | test th1-string-index-11 {$RESULT eq ""} |
| 1529 | |
| 1530 | ############################################################################### |
| 1531 | |
| 1532 | fossil test-th-eval {string index ABC 0} |
| 1533 | test th1-string-index-12 {$RESULT eq "A"} |
| 1534 | |
| 1535 | ############################################################################### |
| 1536 | |
| 1537 | fossil test-th-eval {string index ABC 1} |
| 1538 | test th1-string-index-13 {$RESULT eq "B"} |
| 1539 | |
| 1540 | ############################################################################### |
| 1541 | |
| 1542 | fossil test-th-eval {string index ABC 2} |
| 1543 | test th1-string-index-14 {$RESULT eq "C"} |
| 1544 | |
| 1545 | ############################################################################### |
| 1546 | |
| 1547 | fossil test-th-eval {string index ABC end} |
| 1548 | test th1-string-index-15 {$RESULT eq "C"} |
| 1549 | |
| 1550 | ############################################################################### |
| 1551 | |
| 1552 | fossil test-th-eval {markdown} |
| 1553 | test th1-markdown-1 {$RESULT eq \ |
| @@ -1628,17 +1070,14 @@ | |
| 1628 | </div> |
| 1629 | }}} |
| 1630 | |
| 1631 | ############################################################################### |
| 1632 | |
| 1633 | fossil test-th-eval {encode64 test} |
| 1634 | test th1-encode64-1 {$RESULT eq "dGVzdA=="} |
| 1635 | |
| 1636 | ############################################################################### |
| 1637 | |
| 1638 | fossil test-th-eval {encode64 test\x00} |
| 1639 | test th1-encode64-2 {$RESULT eq "dGVzdAA="} |
| 1640 | |
| 1641 | ############################################################################### |
| 1642 | |
| 1643 | fossil test-th-eval {array exists tcl_platform} |
| 1644 | test th1-platform-1 {$RESULT eq "1"} |
| 1645 |
| --- test/th1.test | |
| +++ test/th1.test | |
| @@ -23,29 +23,59 @@ | |
| 23 | ############################################################################### |
| 24 | |
| 25 | set th1Tcl [is_tcl_usable_by_fossil] |
| 26 | set th1Hooks [are_th1_hooks_usable_by_fossil] |
| 27 | |
| 28 | # Evaluate TH1 case triples {name body expected ...}. catch restores the |
| 29 | # TH_ERROR: prefix that test-th-eval prints for a top-level error. |
| 30 | # |
| 31 | proc th1_cases {args} { |
| 32 | set opts {} |
| 33 | while {[llength $args] > 0 && [string match -* [lindex $args 0]]} { |
| 34 | lappend opts [lindex $args 0] |
| 35 | set args [lrange $args 1 end] |
| 36 | } |
| 37 | if {[llength $args] != 1} { |
| 38 | error "th1_cases ?options? {name body expected ...}" |
| 39 | } |
| 40 | set cases [lindex $args 0] |
| 41 | if {[llength $cases] % 3} { |
| 42 | error "th1_cases: cases must be name body expected triples" |
| 43 | } |
| 44 | set script "set out {}\n" |
| 45 | set names {} |
| 46 | set expecteds {} |
| 47 | foreach {name body expected} $cases { |
| 48 | lappend names $name |
| 49 | lappend expecteds $expected |
| 50 | append script "set rc \[catch [list $body] msg\]\n" |
| 51 | append script "if {\$rc} {\n" |
| 52 | append script " lappend out \"TH_ERROR: \$msg\"\n" |
| 53 | append script "} else {\n" |
| 54 | append script " lappend out \$msg\n" |
| 55 | append script "}\n" |
| 56 | } |
| 57 | append script "set out" |
| 58 | fossil test-th-eval {*}$opts $script |
| 59 | set results [normalize_result] |
| 60 | if {[llength $results] != [llength $names]} { |
| 61 | test [lindex $names 0] {0} |
| 62 | return |
| 63 | } |
| 64 | foreach name $names expected $expecteds actual $results { |
| 65 | test_eq $name $actual $expected |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | ############################################################################### |
| 70 | |
| 71 | th1_cases --open-config { |
| 72 | th1-setting-1 {setting abc} {} |
| 73 | th1-setting-2 {setting -- abc} {} |
| 74 | th1-setting-3 {setting -strict abc} {TH_ERROR: no value for setting "abc"} |
| 75 | th1-setting-4 {setting -strict -- abc} {TH_ERROR: no value for setting "abc"} |
| 76 | } |
| 77 | |
| 78 | ############################################################################### |
| 79 | |
| 80 | fossil test-th-eval --open-config "setting autosync" |
| 81 | test th1-setting-5 {$RESULT eq 0 || $RESULT eq 1 || $RESULT eq "on"} |
| @@ -55,71 +85,31 @@ | |
| 85 | fossil test-th-eval --open-config "setting -strict autosync" |
| 86 | test th1-setting-6 {$RESULT eq 0 || $RESULT eq 1 || $RESULT eq "on"} |
| 87 | |
| 88 | ############################################################################### |
| 89 | |
| 90 | th1_cases --open-config { |
| 91 | th1-setting-7 {setting --} \ |
| 92 | {TH_ERROR: wrong # args: should be "setting ?-strict? ?--? name"} |
| 93 | th1-setting-8 {setting -strict --} \ |
| 94 | {TH_ERROR: wrong # args: should be "setting ?-strict? ?--? name"} |
| 95 | th1-setting-9 {setting -- --} {} |
| 96 | th1-setting-10 {setting -strict -- --} {TH_ERROR: no value for setting "--"} |
| 97 | } |
| 98 | |
| 99 | ############################################################################### |
| 100 | |
| 101 | th1_cases { |
| 102 | th1-divide-by-zero-1 {expr 42/0} {TH_ERROR: Divide by 0: 42} |
| 103 | th1-divide-by-zero-2 {expr 42/0.0} {TH_ERROR: Divide by 0: 42} |
| 104 | th1-divide-by-zero-3 {expr 42.0/0} {TH_ERROR: Divide by 0: 42.0} |
| 105 | th1-divide-by-zero-4 {expr 42.0/0.0} {TH_ERROR: Divide by 0: 42.0} |
| 106 | th1-modulus-by-zero-1 {expr 42%0} {TH_ERROR: Modulo by 0: 42} |
| 107 | th1-modulus-by-zero-2 {expr 42%0.0} {TH_ERROR: expected integer, got: "0.0"} |
| 108 | th1-modulus-by-zero-3 {expr 42.0%0} {TH_ERROR: expected integer, got: "42.0"} |
| 109 | th1-modulus-by-zero-4 {expr 42.0%0.0} {TH_ERROR: expected integer, got: "42.0"} |
| 110 | } |
| 111 | |
| 112 | ############################################################################### |
| 113 | |
| 114 | fossil test-th-eval "set var 1; info exists var" |
| 115 | test th1-info-exists-1 {$RESULT eq {1}} |
| @@ -219,471 +209,175 @@ | |
| 209 | fossil test-th-eval "set gv(1) 1; upvar 0 gv(1) gv2; unset gv(1); unset gv2" |
| 210 | test th1-unset-8 {$RESULT eq {TH_ERROR: no such variable: gv2}} |
| 211 | |
| 212 | ############################################################################### |
| 213 | |
| 214 | th1_cases { |
| 215 | th1-string-first-1 {string first {} {}} -1 |
| 216 | th1-string-first-2 {string first {} {a}} -1 |
| 217 | th1-string-first-3 {string first {a} {}} -1 |
| 218 | th1-string-first-4 {string first {a} {a}} 0 |
| 219 | th1-string-first-5 {string first {a} {aa}} 0 |
| 220 | th1-string-first-6 {string first {aa} {a}} -1 |
| 221 | th1-string-first-7 {string first {ab} {abc}} 0 |
| 222 | th1-string-first-8 {string first {bc} {abc}} 1 |
| 223 | th1-string-first-9 {string first {AB} {abc}} -1 |
| 224 | th1-string-last-1 {string last {} {}} -1 |
| 225 | th1-string-last-2 {string last {} {a}} -1 |
| 226 | th1-string-last-3 {string last {a} {}} -1 |
| 227 | th1-string-last-4 {string last {a} {a}} 0 |
| 228 | th1-string-last-5 {string last {a} {aa}} 1 |
| 229 | th1-string-last-6 {string last {aa} {a}} -1 |
| 230 | th1-string-last-7 {string last {ab} {abc}} 0 |
| 231 | th1-string-last-8 {string last {bc} {abc}} 1 |
| 232 | th1-string-last-9 {string last {AB} {abc}} -1 |
| 233 | } |
| 234 | |
| 235 | ############################################################################### |
| 236 | |
| 237 | th1_cases { |
| 238 | th1-expr-1 {expr -2147483649.0} -2147483649.0 |
| 239 | th1-expr-2 {expr -2147483649} 2147483647 |
| 240 | th1-expr-3 {expr -2147483648} -2147483648 |
| 241 | th1-expr-4 {expr -2147483647} -2147483647 |
| 242 | th1-expr-5 {expr -1} -1 |
| 243 | th1-expr-6 {expr 0} 0 |
| 244 | th1-expr-7 {expr 0.0} 0.0 |
| 245 | th1-expr-8 {expr 1} 1 |
| 246 | th1-expr-9 {expr 2147483647} 2147483647 |
| 247 | th1-expr-10 {expr 2147483648} 2147483648 |
| 248 | th1-expr-11 {expr 2147483649} 2147483649 |
| 249 | th1-expr-12 {expr +2147483649} -2147483647 |
| 250 | th1-expr-13 {expr +2147483649.0} 2147483649.0 |
| 251 | th1-expr-14 {expr ~(-1)} 0 |
| 252 | th1-expr-15 {expr ~-1} 0 |
| 253 | th1-expr-16 {expr ~0} -1 |
| 254 | th1-expr-17 {expr ~+0} -1 |
| 255 | th1-expr-18 {expr ~-0} -1 |
| 256 | th1-expr-19 {expr ~(+0)} -1 |
| 257 | th1-expr-20 {expr ~(-0)} -1 |
| 258 | th1-expr-21 {expr ~1} -2 |
| 259 | th1-expr-22 {expr ~+1} -2 |
| 260 | th1-expr-23 {expr ~(+1)} -2 |
| 261 | th1-expr-24 {expr 0+0b11} 3 |
| 262 | th1-expr-25 {expr 0+0o15} 13 |
| 263 | th1-expr-26 {expr 0+0x15} 21 |
| 264 | th1-expr-27 {expr 0+0b2} {TH_ERROR: expected number, got: "0b2"} |
| 265 | th1-expr-28 {expr 0+0o8} {TH_ERROR: expected number, got: "0o8"} |
| 266 | th1-expr-29 {expr 0+0xg} {TH_ERROR: syntax error in expression: "0+0xg"} |
| 267 | th1-expr-30 {expr 0+0b1.} {TH_ERROR: syntax error in expression: "0+0b1."} |
| 268 | th1-expr-31 {expr 0+0o1.} {TH_ERROR: syntax error in expression: "0+0o1."} |
| 269 | th1-expr-32 {expr 0+0x1.} {TH_ERROR: syntax error in expression: "0+0x1."} |
| 270 | th1-expr-33 {expr 0ne5} 1 |
| 271 | th1-expr-34 {expr 0b1+5} 6 |
| 272 | th1-expr-35 {expr 0+0b} {TH_ERROR: expected number, got: "0b"} |
| 273 | th1-expr-36 {expr (-1)+1} 0 |
| 274 | th1-expr-37 {expr (((-1)))} -1 |
| 275 | th1-expr-38 {expr (((1)))} 1 |
| 276 | th1-expr-39 {expr (((1))} {TH_ERROR: syntax error in expression: "(((1))"} |
| 277 | th1-expr-40 {expr ((1)))} {TH_ERROR: syntax error in expression: "((1)))"} |
| 278 | th1-expr-41 {expr (((1)*2)*2)} 4 |
| 279 | th1-expr-42 {expr +} {TH_ERROR: syntax error in expression: "+"} |
| 280 | th1-expr-43 {expr -} {TH_ERROR: syntax error in expression: "-"} |
| 281 | th1-expr-44 {expr ++} {TH_ERROR: syntax error in expression: "++"} |
| 282 | th1-expr-45 {expr --} {TH_ERROR: syntax error in expression: "--"} |
| 283 | th1-lindex-bad-1 {lindex list +} {TH_ERROR: expected integer, got: "+"} |
| 284 | th1-lindex-bad-2 {lindex list -} {TH_ERROR: expected integer, got: "-"} |
| 285 | th1-lindex-bad-3 {lindex list +0x} {TH_ERROR: expected integer, got: "+0x"} |
| 286 | th1-lindex-bad-4 {lindex list -0x} {TH_ERROR: expected integer, got: "-0x"} |
| 287 | } |
| 288 | |
| 289 | ############################################################################### |
| 290 | |
| 291 | # NOTE: The 'd' permission is no longer used. Skip "reader" (u) and |
| 292 | # "developer" (v) meta-permissions. |
| 293 | set th1_cap_perms { |
| 294 | a b c e f g h i j k l m n o p q r s t w x y z |
| 295 | A D |
| 296 | 2 3 4 5 6 7 |
| 297 | } |
| 298 | |
| 299 | set cases {} |
| 300 | foreach perm $th1_cap_perms { |
| 301 | lappend cases th1-anycap-no-$perm-1 "anycap $perm" 0 |
| 302 | lappend cases th1-hascap-no-$perm-1 "hascap $perm" 0 |
| 303 | lappend cases th1-anoncap-no-$perm-1 "anoncap $perm" 0 |
| 304 | } |
| 305 | lappend cases \ |
| 306 | th1-anycap-no-multiple-1 {anycap oh} 0 \ |
| 307 | th1-hascap-no-multiple-1 {hascap oh} 0 \ |
| 308 | th1-hascap-no-multiple-2 {hascap o h} 0 \ |
| 309 | th1-anoncap-no-multiple-1 {anoncap oh} 0 \ |
| 310 | th1-anoncap-no-multiple-2 {anoncap o h} 0 |
| 311 | th1_cases $cases |
| 312 | |
| 313 | ############################################################################### |
| 314 | |
| 315 | set skip_anycap 1 |
| 316 | if {$::outside_fossil_repo} { |
| 317 | test_skip_part "th1-anycap-*-1 perm tests: not in Fossil repo checkout." |
| 318 | } elseif {$::dirty_ckout} { |
| 319 | test_skip_part "th1-anycap-*-1 perm tests: uncommitted changes in\ |
| 320 | Fossil checkout." |
| 321 | } else { |
| 322 | set skip_anycap 0 |
| 323 | } |
| 324 | |
| 325 | if {!$skip_anycap} { |
| 326 | run_in_checkout { |
| 327 | set cases {} |
| 328 | foreach perm $th1_cap_perms { |
| 329 | lappend cases th1-anycap-yes-$perm-1 "anycap $perm" 1 |
| 330 | lappend cases th1-hascap-yes-$perm-1 "hascap $perm" 1 |
| 331 | } |
| 332 | lappend cases \ |
| 333 | th1-anycap-yes-multiple-1 {anycap oh} 1 \ |
| 334 | th1-hascap-yes-multiple-1 {hascap oh} 1 \ |
| 335 | th1-hascap-yes-multiple-2 {hascap o h} 1 |
| 336 | set ::env(TH1_TEST_USER_CAPS) sxy |
| 337 | th1_cases --set-user-caps $cases |
| 338 | |
| 339 | set cases {} |
| 340 | foreach perm $th1_cap_perms { |
| 341 | lappend cases th1-anycap-no-$perm-2 "anycap $perm" 0 |
| 342 | lappend cases th1-hascap-no-$perm-2 "hascap $perm" 0 |
| 343 | } |
| 344 | set ::env(TH1_TEST_USER_CAPS) 1; # NOTE: Bad permission. |
| 345 | th1_cases --set-user-caps $cases |
| 346 | |
| 347 | set ::env(TH1_TEST_USER_CAPS) o |
| 348 | th1_cases --set-user-caps { |
| 349 | th1-anycap-yes-multiple-2 {anycap oh} 1 |
| 350 | th1-hascap-no-multiple-3 {hascap oh} 0 |
| 351 | th1-hascap-no-multiple-4 {hascap o h} 0 |
| 352 | } |
| 353 | unset ::env(TH1_TEST_USER_CAPS) |
| 354 | |
| 355 | set cases {} |
| 356 | foreach perm $th1_cap_perms { |
| 357 | lappend cases th1-anoncap-yes-$perm-1 "anoncap $perm" 1 |
| 358 | } |
| 359 | lappend cases \ |
| 360 | th1-anoncap-yes-multiple-1 {anoncap oh} 1 \ |
| 361 | th1-anoncap-yes-multiple-2 {anoncap o h} 1 |
| 362 | set ::env(TH1_TEST_ANON_CAPS) sxy |
| 363 | th1_cases --set-anon-caps $cases |
| 364 | |
| 365 | set cases {} |
| 366 | foreach perm $th1_cap_perms { |
| 367 | lappend cases th1-anoncap-no-$perm-2 "anoncap $perm" 0 |
| 368 | } |
| 369 | set ::env(TH1_TEST_ANON_CAPS) 1; # NOTE: Bad permission. |
| 370 | th1_cases --set-anon-caps $cases |
| 371 | |
| 372 | set ::env(TH1_TEST_ANON_CAPS) o |
| 373 | th1_cases --set-anon-caps { |
| 374 | th1-anoncap-no-multiple-3 {anoncap oh} 0 |
| 375 | th1-anoncap-no-multiple-4 {anoncap o h} 0 |
| 376 | } |
| 377 | unset ::env(TH1_TEST_ANON_CAPS) |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | ############################################################################### |
| 382 | |
| 383 | test_in_checkout th1-checkout-1 { |
| @@ -1189,365 +883,113 @@ | |
| 883 | fossil test-th-eval "set foo(x) 2; unset foo(x); array names foo" |
| 884 | test th1-array-names-6 {$RESULT eq ""} |
| 885 | |
| 886 | ############################################################################### |
| 887 | |
| 888 | th1_cases { |
| 889 | th1-lsearch-1 {lsearch} \ |
| 890 | {TH_ERROR: wrong # args: should be "lsearch list string"} |
| 891 | th1-lsearch-2 {lsearch a} \ |
| 892 | {TH_ERROR: wrong # args: should be "lsearch list string"} |
| 893 | th1-lsearch-3 {lsearch a a a} \ |
| 894 | {TH_ERROR: wrong # args: should be "lsearch list string"} |
| 895 | th1-lsearch-4 {lsearch {a b c} a} 0 |
| 896 | th1-lsearch-5 {lsearch {a b c} b} 1 |
| 897 | th1-lsearch-6 {lsearch {a b c} c} 2 |
| 898 | th1-lsearch-7 {lsearch {a b c} d} -1 |
| 899 | th1-lsearch-8 {lsearch {a b c} aa} -1 |
| 900 | th1-lsearch-9 {lsearch {aa b c} a} -1 |
| 901 | } |
| 902 | |
| 903 | ############################################################################### |
| 904 | |
| 905 | fossil test-th-eval "lsearch \"\{aa b c\" a" |
| 906 | test th1-lsearch-10 {$RESULT eq "TH_ERROR: Expected list, got: \"\{aa b c\""} |
| 907 | |
| 908 | ############################################################################### |
| 909 | |
| 910 | th1_cases { |
| 911 | th1-glob-match-1 {glob_match} \ |
| 912 | {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"} |
| 913 | th1-glob-match-2 {glob_match -one} \ |
| 914 | {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"} |
| 915 | th1-glob-match-3 {glob_match --} \ |
| 916 | {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"} |
| 917 | th1-glob-match-4 {glob_match -one --} \ |
| 918 | {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"} |
| 919 | th1-glob-match-5 {glob_match -one -- 1} \ |
| 920 | {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"} |
| 921 | th1-glob-match-6 {glob_match -one -- 1 2 3} \ |
| 922 | {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"} |
| 923 | th1-glob-match-7 {list [glob_match a A] [glob_match A a]} {0 0} |
| 924 | th1-glob-match-8 {list [glob_match a,b a] [glob_match a,b b]} {1 2} |
| 925 | th1-glob-match-9 {list [glob_match -one a,b a] [glob_match -one a,b b]} {0 0} |
| 926 | th1-glob-match-10 {list [glob_match -one a,b a,b] [glob_match -one a b,a]} {1 0} |
| 927 | th1-glob-match-11 {list [glob_match a*c abc] [glob_match abc a*c]} {1 0} |
| 928 | th1-glob-match-12 {list [glob_match a?c abc] [glob_match abc a?c]} {1 0} |
| 929 | th1-glob-match-13 {list [glob_match {a[bd]c} abc] [glob_match abc {a[bd]c}]} {1 0} |
| 930 | } |
| 931 | |
| 932 | ############################################################################### |
| 933 | |
| 934 | th1_cases { |
| 935 | th1-string-is-1 {string is} \ |
| 936 | {TH_ERROR: wrong # args: should be "string is class string"} |
| 937 | th1-string-is-2 {string is something} \ |
| 938 | {TH_ERROR: wrong # args: should be "string is class string"} |
| 939 | th1-string-is-3 {string is not something else} \ |
| 940 | {TH_ERROR: wrong # args: should be "string is class string"} |
| 941 | th1-string-is-4 {string is other 123} \ |
| 942 | {TH_ERROR: Expected alnum, double, integer, list, or tainted, got: other} |
| 943 | th1-string-is-5 {string is alnum 123} 1 |
| 944 | th1-string-is-6 {string is alnum abc} 1 |
| 945 | th1-string-is-7 {string is alnum 123abc} 1 |
| 946 | th1-string-is-8 {string is alnum abc123} 1 |
| 947 | th1-string-is-9 {string is alnum _abc123} 0 |
| 948 | th1-string-is-10 {string is alnum abc.123} 0 |
| 949 | th1-string-is-11 {string is alnum abc123_} 0 |
| 950 | th1-string-is-12 {string is list ""} 1 |
| 951 | th1-string-is-13 {string is list 1} 1 |
| 952 | th1-string-is-14 {string is list "1 2 3"} 1 |
| 953 | th1-string-is-15 {string is list "\{"} 0 |
| 954 | th1-string-is-16 {string is list "1 2 3 \{"} 0 |
| 955 | th1-string-is-17 {string is list "1 2 3 \{\}"} 1 |
| 956 | th1-string-is-18 {string is list "1 2 3 \{\{\}"} 0 |
| 957 | th1-string-is-19 {string is double 123} 1 |
| 958 | th1-string-is-20 {string is double 123.456} 1 |
| 959 | th1-string-is-21 {string is double 123abc} 0 |
| 960 | th1-string-is-22 {string is double 123_456} 0 |
| 961 | th1-string-is-23 {string is integer 123} 1 |
| 962 | th1-string-is-24 {string is integer 123.456} 0 |
| 963 | th1-string-is-25 {string is integer 123abc} 0 |
| 964 | th1-string-is-26 {string is integer 0b11001001} 1 |
| 965 | th1-string-is-27 {string is integer 0b11001002} 0 |
| 966 | th1-string-is-28 {string is integer 0o777} 1 |
| 967 | th1-string-is-29 {string is integer 0o778} 0 |
| 968 | th1-string-is-30 {string is integer 0xC0DEF00D} 1 |
| 969 | th1-string-is-31 {string is integer 0xC0DEF00Z} 0 |
| 970 | } |
| 971 | |
| 972 | ############################################################################### |
| 973 | |
| 974 | th1_cases { |
| 975 | th1-string-index-1 {string index "" -1} {} |
| 976 | th1-string-index-2 {string index "" 0} {} |
| 977 | th1-string-index-3 {string index "" 1} {} |
| 978 | th1-string-index-4 {string index "" 2} {} |
| 979 | th1-string-index-5 {string index "" end} {} |
| 980 | th1-string-index-6 {string index A -1} {} |
| 981 | th1-string-index-7 {string index A 0} A |
| 982 | th1-string-index-8 {string index A 1} {} |
| 983 | th1-string-index-9 {string index A 2} {} |
| 984 | th1-string-index-10 {string index A end} A |
| 985 | th1-string-index-11 {string index ABC -1} {} |
| 986 | th1-string-index-12 {string index ABC 0} A |
| 987 | th1-string-index-13 {string index ABC 1} B |
| 988 | th1-string-index-14 {string index ABC 2} C |
| 989 | th1-string-index-15 {string index ABC end} C |
| 990 | } |
| 991 | |
| 992 | ############################################################################### |
| 993 | |
| 994 | fossil test-th-eval {markdown} |
| 995 | test th1-markdown-1 {$RESULT eq \ |
| @@ -1628,17 +1070,14 @@ | |
| 1070 | </div> |
| 1071 | }}} |
| 1072 | |
| 1073 | ############################################################################### |
| 1074 | |
| 1075 | th1_cases { |
| 1076 | th1-encode64-1 {encode64 test} dGVzdA== |
| 1077 | th1-encode64-2 {encode64 test\x00} dGVzdAA= |
| 1078 | } |
| 1079 | |
| 1080 | ############################################################################### |
| 1081 | |
| 1082 | fossil test-th-eval {array exists tcl_platform} |
| 1083 | test th1-platform-1 {$RESULT eq "1"} |
| 1084 |