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
|
# -*- tcl -*-
# paths.test: Testsuite for package fileutil::paths
#
# Copyright (c) 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.0
support {
use snit/snit.tcl snit
}
testing {
useLocal paths.tcl fileutil::paths
}
# ---------------------------------------------------------------------
# [] constructor
# [] destructor
# [] paths
# [] add
# [] remove
# [] clear
#----------------------------------------------------------------------
## Constructor, destructor
test fileutil-paths-1.0 {constructor, wrong args, too many} -body {
fileutil::paths P X
} -returnCodes error -result {Error in constructor: wrong # args: should be "::fileutil::paths::Snit_constructor type selfns win self"}
test fileutil-paths-1.1 {instance, bogus method} -setup {
fileutil::paths P
} -cleanup {
P destroy
} -body {
P bogus
} -returnCodes error -result {"::P bogus" is not defined}
#----------------------------------------------------------------------
## paths
test fileutil-paths-2.0 {paths, wrong args, too many} -setup {
fileutil::paths P
} -cleanup {
P destroy
} -body {
P paths X
} -returnCodes error -result {wrong # args: should be "::fileutil::paths::Snit_methodpaths type selfns win self"}
test fileutil-paths-2.1 {paths, base state, none} -setup {
fileutil::paths P
} -cleanup {
P destroy
} -body {
P paths
} -result {}
#----------------------------------------------------------------------
## add
test fileutil-paths-3.0 {add, wrong args, not enough} -setup {
fileutil::paths P
} -cleanup {
P destroy
} -body {
P add
} -returnCodes error -result {wrong # args: should be "::fileutil::paths::Snit_methodadd type selfns win self path"}
test fileutil-paths-3.1 {add, wrong args, too many} -setup {
fileutil::paths P
} -cleanup {
P destroy
} -body {
P add F X
} -returnCodes error -result {wrong # args: should be "::fileutil::paths::Snit_methodadd type selfns win self path"}
test fileutil-paths-3.2 {add, state change, result} -setup {
fileutil::paths P
} -cleanup {
P destroy
} -body {
list [P add F] [P paths]
} -result {{} F}
#----------------------------------------------------------------------
## remove
test fileutil-paths-4.0 {remove, wrong args, not enough} -setup {
fileutil::paths P
} -cleanup {
P destroy
} -body {
P remove
} -returnCodes error -result {wrong # args: should be "::fileutil::paths::Snit_methodremove type selfns win self path"}
test fileutil-paths-4.1 {remove, wrong args, too many} -setup {
fileutil::paths P
} -cleanup {
P destroy
} -body {
P remove F X
} -returnCodes error -result {wrong # args: should be "::fileutil::paths::Snit_methodremove type selfns win self path"}
test fileutil-paths-4.2 {remove, known path, state change, result} -setup {
fileutil::paths P
P add F
} -cleanup {
P destroy
} -body {
list [P remove F] [P paths]
} -result {{} {}}
test fileutil-paths-4.3 {remove, missing path, no state change, result} -setup {
fileutil::paths P
P add Z
} -cleanup {
P destroy
} -body {
list [P remove F] [P paths]
} -result {{} Z}
#----------------------------------------------------------------------
## clear
test fileutil-paths-5.0 {clear, wrong args, too many} -setup {
fileutil::paths P
} -cleanup {
P destroy
} -body {
P clear X
} -returnCodes error -result {wrong # args: should be "::fileutil::paths::Snit_methodclear type selfns win self"}
test fileutil-paths-5.1 {clear, return to base state} -setup {
fileutil::paths P
P add F
} -cleanup {
P destroy
} -body {
list [P clear] [P paths]
} -result {{} {}}
#----------------------------------------------------------------------
testsuiteCleanup
return
|