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
|
# -*- tcl -*-
# interp.test: tests for the interp alias and creation utilities
#
# Sourcing this file into Tcl runs the tests and
# generates output for errors. No output means no errors were found.
# -------------------------------------------------------------------------
source [file join \
[file dirname [file dirname [file join [pwd] [info script]]]] \
devtools testutilities.tcl]
testsNeedTcl 8.3
testsNeedTcltest 1.0
support {
use snit/snit.tcl snit
testsNeed snit 1.3.1 ; # method introspection arguments/body
}
testing {
useLocal deleg_method.tcl interp::delegate::method
}
# -------------------------------------------------------------------------
test dmethod-1.0 {wrong#args} {
catch {snit::type foo {interp::delegate::method}} msg
set msg
} {wrong # args}
test dmethod-1.1 {wrong#args} {
catch {snit::type foo {interp::delegate::method a}} msg
set msg
} {wrong # args}
test dmethod-1.2 {wrong#args} {
catch {snit::type foo {interp::delegate::method a b}} msg
set msg
} {wrong # args}
test dmethod-1.3 {wrong#args} {
catch {snit::type foo {interp::delegate::method a b c}} msg
set msg
} {wrong # args}
test dmethod-1.4 {wrong#args} {
catch {snit::type foo {interp::delegate::method a b c d e}} msg
set msg
} {wrong # args}
# -------------------------------------------------------------------------
test dmethod-2.0 {bad switch} {
catch {snit::type foo {interp::delegate::method -bogus}} msg
set msg
} {unknown option "-bogus", expected -async}
# -------------------------------------------------------------------------
test dmethod-3.0 {delegation result} {
snit::type foo {
interp::delegate::method request {} COMM ID
}
res!
foo bar
res+ [info commands foo::Snit_methodrequest]
res+ [lsort [bar info methods]]
bar destroy
foo destroy
res?
} {::foo::Snit_methodrequest {{destroy info request}}}
# -------------------------------------------------------------------------
test dmethod-4.0 {signature} {
snit::type foo {
interp::delegate::method request {} COMM ID
}
foo X
res!
res+ \
[X info args request] \
[string trimleft [X info body request]]
X destroy
foo destroy
res?
} {{{} {COMM send ID request}}}
test dmethod-4.1 {signature} {
snit::type foo {
interp::delegate::method request {a b} COMM ID
}
foo X
res!
res+ \
[X info args request] \
[string trimleft [X info body request]]
X destroy
foo destroy
res?
} {{{a b} {COMM send ID [list request $a $b]}}}
test dmethod-4.2 {signature} {
snit::type foo {
interp::delegate::method request {a b args} COMM ID
}
foo X
res!
res+ \
[X info args request] \
[string trimleft [X info body request]]
X destroy
foo destroy
res?
} {{{a b args} {COMM send ID [linsert $args 0 request $a $b]}}}
test dmethod-4.3 {signature} {
snit::type foo {
interp::delegate::method request {args} COMM ID
}
foo X
res!
res+ \
[X info args request] \
[string trimleft [X info body request]]
X destroy
foo destroy
res?
} {{args {COMM send ID [linsert $args 0 request]}}}
# -------------------------------------------------------------------------
test dmethod-5.0 {signature} {
snit::type foo {
interp::delegate::method -async request {} COMM ID
}
foo X
res!
res+ \
[X info args request] \
[string trimleft [X info body request]]
X destroy
foo destroy
res?
} {{{} {COMM send -async ID request}}}
test dmethod-5.1 {signature} {
snit::type foo {
interp::delegate::method -async request {a b} COMM ID
}
foo X
res!
res+ \
[X info args request] \
[string trimleft [X info body request]]
X destroy
foo destroy
res?
} {{{a b} {COMM send -async ID [list request $a $b]}}}
test dmethod-5.2 {signature} {
snit::type foo {
interp::delegate::method -async request {a b args} COMM ID
}
foo X
res!
res+ \
[X info args request] \
[string trimleft [X info body request]]
X destroy
foo destroy
res?
} {{{a b args} {COMM send -async ID [linsert $args 0 request $a $b]}}}
test dmethod-5.3 {signature} {
snit::type foo {
interp::delegate::method -async request {args} COMM ID
}
foo X
res!
res+ \
[X info args request] \
[string trimleft [X info body request]]
X destroy
foo destroy
res?
} {{args {COMM send -async ID [linsert $args 0 request]}}}
# -------------------------------------------------------------------------
testsuiteCleanup
return
|