1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678
|
# -*- tcl -*-
# idx.test: Tests for the doctools::idx package. Index management.
#
# Copyright (c) 2009-2019 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
# All rights reserved.
# -------------------------------------------------------------------------
source [file join [
file dirname [file dirname [file join [pwd] [info script]]]
] devtools testutilities.tcl]
testsNeedTcl 8.4
testsNeedTcltest 2
support {
use struct/list.tcl struct::list
use snit/snit.tcl snit
use fileutil/fileutil.tcl fileutil
use fileutil/paths.tcl fileutil::paths
use log/logger.tcl logger
use pluginmgr/pluginmgr.tcl pluginmgr
use struct/map.tcl struct::map
useLocal export.tcl doctools::idx::export
useLocal import.tcl doctools::idx::import
use doctools2base/nroff_manmacros.tcl doctools::nroff::man_macros
source [tcllibPath doctools2base/tests/common]
}
testing {
useLocalKeep container.tcl doctools::idx
}
# -------------------------------------------------------------------------
setup_plugins
# -------------------------------------------------------------------------
test doctools-idx-1.0 {deserialize =, wrong#args} -setup {
doctools::idx I
} -body {
I deserialize =
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_hmethoddeserialize_= type selfns win self data ?format?"}
test doctools-idx-1.1 {deserialize =, wrong#args} -setup {
doctools::idx I
} -body {
I deserialize = T F XXX
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_hmethoddeserialize_= type selfns win self data ?format?"}
test doctools-idx-2.0 {deserialize +=, wrong#args} -setup {
doctools::idx I
} -body {
I deserialize +=
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_hmethoddeserialize_+= type selfns win self data ?format?"}
test doctools-idx-2.1 {deserialize +=, wrong#args} -setup {
doctools::idx I
} -body {
I deserialize += T F XXX
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_hmethoddeserialize_+= type selfns win self data ?format?"}
test doctools-idx-3.0 {serialize, wrong#args} -setup {
doctools::idx I
} -body {
I serialize F XXX
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_methodserialize type selfns win self ?format?"}
test doctools-idx-4.0 {key add, wrong#args} -setup {
doctools::idx I
} -body {
I key add
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_hmethodkey_add type selfns win self key"}
test doctools-idx-4.1 {key add, wrong#args} -setup {
doctools::idx I
} -body {
I key add N XXX
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_hmethodkey_add type selfns win self key"}
test doctools-idx-5.0 {key remove, wrong#args} -setup {
doctools::idx I
} -body {
I key remove
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_hmethodkey_remove type selfns win self key"}
test doctools-idx-5.1 {key remove, wrong#args} -setup {
doctools::idx I
} -body {
I key remove N XXX
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_hmethodkey_remove type selfns win self key"}
test doctools-idx-6.0 {key references, wrong#args} -setup {
doctools::idx I
} -body {
I key references
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_hmethodkey_references type selfns win self key"}
test doctools-idx-6.1 {key references, wrong#args} -setup {
doctools::idx I
} -body {
I key references N XXX
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_hmethodkey_references type selfns win self key"}
test doctools-idx-7.0 {keys, wrong#args} -setup {
doctools::idx I
} -body {
I keys XXX
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_methodkeys type selfns win self"}
test doctools-idx-8.0 {reference add, wrong#args} -setup {
doctools::idx I
} -body {
I reference add
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_hmethodreference_add type selfns win self reftype key name label"}
test doctools-idx-8.1 {reference add, wrong#args} -setup {
doctools::idx I
} -body {
I reference add T
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_hmethodreference_add type selfns win self reftype key name label"}
test doctools-idx-8.2 {reference add, wrong#args} -setup {
doctools::idx I
} -body {
I reference add T K
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_hmethodreference_add type selfns win self reftype key name label"}
test doctools-idx-8.3 {reference add, wrong#args} -setup {
doctools::idx I
} -body {
I reference add T K N
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_hmethodreference_add type selfns win self reftype key name label"}
test doctools-idx-8.4 {reference add, wrong#args} -setup {
doctools::idx I
} -body {
I reference add T K N L XXX
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_hmethodreference_add type selfns win self reftype key name label"}
test doctools-idx-9.0 {reference remove, wrong#args} -setup {
doctools::idx I
} -body {
I reference remove
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_hmethodreference_remove type selfns win self name"}
test doctools-idx-9.1 {reference remove, wrong#args} -setup {
doctools::idx I
} -body {
I reference remove N XXX
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_hmethodreference_remove type selfns win self name"}
test doctools-idx-10.0 {reference label, wrong#args} -setup {
doctools::idx I
} -body {
I reference label
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_hmethodreference_label type selfns win self name"}
test doctools-idx-10.1 {reference label, wrong#args} -setup {
doctools::idx I
} -body {
I reference label N XXX
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_hmethodreference_label type selfns win self name"}
test doctools-idx-11.0 {reference keys, wrong#args} -setup {
doctools::idx I
} -body {
I reference keys
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_hmethodreference_keys type selfns win self name"}
test doctools-idx-11.1 {reference keys, wrong#args} -setup {
doctools::idx I
} -body {
I reference keys N XXX
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_hmethodreference_keys type selfns win self name"}
test doctools-idx-12.0 {reference type, wrong#args} -setup {
doctools::idx I
} -body {
I reference type
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_hmethodreference_type type selfns win self name"}
test doctools-idx-12.1 {reference type, wrong#args} -setup {
doctools::idx I
} -body {
I reference type N XXX
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_hmethodreference_type type selfns win self name"}
test doctools-idx-13.0 {references, wrong#args} -setup {
doctools::idx I
} -body {
I references XXX
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_methodreferences type selfns win self"}
test doctools-idx-14.0 {title, wrong#args} -setup {
doctools::idx I
} -body {
I title T XXX
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_methodtitle type selfns win self ?text?"}
test doctools-idx-15.0 {label, wrong#args} -setup {
doctools::idx I
} -body {
I label L XXX
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_methodlabel type selfns win self ?text?"}
test doctools-idx-16.0 {exporter, wrong#args} -setup {
doctools::idx I
} -body {
I exporter E XXX
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_methodexporter type selfns win self ?object?"}
test doctools-idx-17.0 {importer, wrong#args} -setup {
doctools::idx I
} -body {
I importer I XXX
} -cleanup {
I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::idx::Snit_methodimporter type selfns win self ?object?"}
# -------------------------------------------------------------------------
test doctools-idx-18.0 {key add, new key} -setup {
doctools::idx I
} -body {
I key add K
I keys
} -cleanup {
I destroy
} -result K
test doctools-idx-18.1 {key add, known key} -setup {
doctools::idx I
I key add K
} -body {
I key add K
I keys
} -cleanup {
I destroy
} -result K
test doctools-idx-19.0 {key remove, known key} -setup {
doctools::idx I
I key add K
} -body {
I key remove K
I keys
} -cleanup {
I destroy
} -result {}
test doctools-idx-19.1 {key remove, unknown key} -setup {
doctools::idx I
I key add K
} -body {
I key remove K'
I keys
} -cleanup {
I destroy
} -result K
test doctools-idx-19.2 {key remove, reference still has keys} -setup {
doctools::idx I
I key add K
I key add K'
I reference add manpage K R r
I reference add manpage K' R r
} -body {
I key remove K
list [I keys] [I references]
} -cleanup {
I destroy
} -result {K' R}
test doctools-idx-19.3 {key remove, last user of reference} -setup {
doctools::idx I
I key add K
I reference add manpage K R r
} -body {
I key remove K
list [I keys] [I references]
} -cleanup {
I destroy
} -result {{} {}}
test doctools-idx-20.0 {keys, empty} -setup {
doctools::idx I
} -body {
I keys
} -cleanup {
I destroy
} -result {}
test doctools-idx-20.1 {keys, not empty} -setup {
doctools::idx I
I key add K
} -body {
I keys
} -cleanup {
I destroy
} -result K
test doctools-idx-20.2 {keys, not empty. multiple} -setup {
doctools::idx I
I key add K
I key add K'
} -body {
lsort [I keys]
} -cleanup {
I destroy
} -result {K K'}
test doctools-idx-21.0 {key, without references} -setup {
doctools::idx I
I key add K
} -body {
I key references K
} -cleanup {
I destroy
} -result {}
test doctools-idx-21.1 {key, with reference, one} -setup {
doctools::idx I
I key add K
I reference add manpage K R r
} -body {
I key references K
} -cleanup {
I destroy
} -result R
test doctools-idx-21.2 {key, with reference, many} -setup {
doctools::idx I
I key add K
I reference add manpage K R r
I reference add manpage K R' r
} -body {
I key references K
} -cleanup {
I destroy
} -result {R R'}
test doctools-idx-22.0 {reference add, unknown key} -setup {
doctools::idx I
} -body {
I reference add manpage K R r
} -cleanup {
I destroy
} -returnCodes error -result {Unknown key 'K'}
test doctools-idx-22.1 {reference add, bad type} -setup {
doctools::idx I
I key add K
} -body {
I reference add bogus K R r
} -cleanup {
I destroy
} -returnCodes error -result {Bad reference type 'bogus'}
test doctools-idx-22.2 {reference add, known ref, type mismatch} -setup {
doctools::idx I
I key add K
I reference add manpage K R r
} -body {
I reference add url K R r
} -cleanup {
I destroy
} -returnCodes error -result {Cannot add url reference 'R', is a manpage reference already}
test doctools-idx-22.3 {reference add, unknown ref} -setup {
doctools::idx I
I key add K
} -body {
I reference add manpage K R r
list [I references] [I key references K]
} -cleanup {
I destroy
} -result {R R}
test doctools-idx-22.4 {reference add, known ref, type match} -setup {
doctools::idx I
I key add K
I reference add manpage K R r
} -body {
I reference add manpage K R r'
list [I references] [I key references K]
} -cleanup {
I destroy
} -result {R R}
test doctools-idx-23.0 {reference remove, known reference} -setup {
doctools::idx I
I key add K
I reference add manpage K R r
} -body {
I reference remove R
list [I references] [I key references K]
} -cleanup {
I destroy
} -result {{} {}}
test doctools-idx-23.1 {reference remove, unknown reference} -setup {
doctools::idx I
I key add K
I reference add manpage K R r
} -body {
I reference remove R'
list [I references] [I key references K]
} -cleanup {
I destroy
} -result {R R}
test doctools-idx-24.0 {reference type} -setup {
doctools::idx I
I key add K
I reference add manpage K R r
} -body {
I reference type R
} -cleanup {
I destroy
} -result manpage
test doctools-idx-25.0 {reference label} -setup {
doctools::idx I
I key add K
I reference add manpage K R r
} -body {
I reference label R
} -cleanup {
I destroy
} -result r
test doctools-idx-25.1 {reference label, multiple keys, overwrites} -setup {
doctools::idx I
I key add K
I key add K'
I reference add manpage K R r
} -body {
lappend res [I reference label R]
I reference add manpage K' R r'
lappend res [I reference label R]
} -cleanup {
I destroy
unset res
} -result {r r'}
test doctools-idx-25.2 {reference label, same key, overwrites} -setup {
doctools::idx I
I key add K
I reference add manpage K R r
I reference add manpage K R r'
} -body {
I reference label R
} -cleanup {
I destroy
} -result r'
test doctools-idx-26.0 {reference, always one key} -setup {
doctools::idx I
I key add K
I reference add manpage K R r
} -body {
I reference keys R
} -cleanup {
I destroy
} -result K
test doctools-idx-26.1 {reference, multiple keys} -setup {
doctools::idx I
I key add K
I key add K'
I reference add url K R r
I reference add url K' R r
} -body {
lsort [I reference keys R]
} -cleanup {
I destroy
} -result {K K'}
test doctools-idx-27.0 {references, empty} -setup {
doctools::idx I
} -body {
I references
} -cleanup {
I destroy
} -result {}
test doctools-idx-27.1 {references, not empty} -setup {
doctools::idx I
I key add K
I reference add url K R r
} -body {
I references
} -cleanup {
I destroy
} -result R
test doctools-idx-27.2 {references, not empty. multiple} -setup {
doctools::idx I
I key add K
I reference add url K R r
I reference add url K R' r
} -body {
lsort [I references]
} -cleanup {
I destroy
} -result {R R'}
test doctools-idx-28.0 {title, default} -setup {
doctools::idx I
} -body {
I title
} -cleanup {
I destroy
} -result {}
test doctools-idx-28.1 {title, set} -setup {
doctools::idx I
} -body {
I title T
} -cleanup {
I destroy
} -result T
test doctools-idx-28.2 {title, get} -setup {
doctools::idx I
I title T
} -body {
I title
} -cleanup {
I destroy
} -result T
test doctools-idx-29.0 {label, default} -setup {
doctools::idx I
} -body {
I label
} -cleanup {
I destroy
} -result {}
test doctools-idx-29.1 {label, set} -setup {
doctools::idx I
} -body {
I label T
} -cleanup {
I destroy
} -result T
test doctools-idx-29.2 {label, get} -setup {
doctools::idx I
I label T
} -body {
I label
} -cleanup {
I destroy
} -result T
test doctools-idx-30.0 {exporter, default} -setup {
doctools::idx I
} -body {
I exporter
} -cleanup {
I destroy
} -result {}
test doctools-idx-30.1 {exporter, set} -setup {
doctools::idx I
} -body {
I exporter T
} -cleanup {
I destroy
} -result T
test doctools-idx-30.2 {exporter, get} -setup {
doctools::idx I
I exporter T
} -body {
I exporter
} -cleanup {
I destroy
} -result T
test doctools-idx-31.0 {importer, default} -setup {
doctools::idx I
} -body {
I importer
} -cleanup {
I destroy
} -result {}
test doctools-idx-31.1 {importer, set} -setup {
doctools::idx I
} -body {
I importer T
} -cleanup {
I destroy
} -result T
test doctools-idx-31.2 {importer, get} -setup {
doctools::idx I
I importer T
} -body {
I importer
} -cleanup {
I destroy
} -result T
# TODO :: check index merging (+=).
# idx tests, numbering starts at 40
# -------------------------------------------------------------------------
source [localPath tests/container]
#----------------------------------------------------------------------
testsuiteCleanup
return
|