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
|
# -*- 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
}
testing {
useLocal interp.tcl interp
}
# -------------------------------------------------------------------------
test interp-1.0 {wrong#args} {
catch {interp::createEmpty a b} msg
set msg
} {wrong#args: Expected ?path?}
# -------------------------------------------------------------------------
test interp-2.0 {auto naming, empty} {
set i [interp::createEmpty]
catch {$i eval {set x}} msg
interp delete $i
set msg
} {invalid command name "set"}
test interp-2.1 {explicit naming, empty} {
set i [interp::createEmpty A]
catch {$i eval {set x}} msg
interp delete $i
list $i $msg
} {A {invalid command name "set"}}
# -------------------------------------------------------------------------
test interp-3.0 {wrong#args} {
catch {interp::snitLink} msg
set msg
} [tcltest::wrongNumArgs interp::snitLink {path methods} 0]
test interp-3.1 {wrong#args} {
catch {interp::snitLink a} msg
set msg
} [tcltest::wrongNumArgs interp::snitLink {path methods} 1]
test interp-3.2 {wrong#args} {
catch {interp::snitLink a b c} msg
set msg
} [tcltest::tooManyArgs interp::snitLink {path methods}]
test interp-3.3 {create, test redirection} {
res!
snit::type foo {
variable i
constructor {} {
set i [interp::createEmpty]
interp::snitLink $i Duck
}
method Duck {} {
res+ Ducking
}
method ho {} {$i eval Duck}
}
set i [foo %AUTO%]
$i ho
$i destroy
foo destroy
res?
} Ducking
# -------------------------------------------------------------------------
test interp-4.0 {wrong#args} {
catch {interp::snitDictLink} msg
set msg
} [tcltest::wrongNumArgs interp::snitDictLink {path methoddict} 0]
test interp-4.1 {wrong#args} {
catch {interp::snitDictLink a} msg
set msg
} [tcltest::wrongNumArgs interp::snitDictLink {path methoddict} 1]
test interp-4.2 {wrong#args} {
catch {interp::snitDictLink a b c} msg
set msg
} [tcltest::tooManyArgs interp::snitDictLink {path methoddict}]
test interp-4.3 {create, test redirection} {
res!
snit::type foo {
variable i
constructor {} {
set i [interp::createEmpty]
interp::snitDictLink $i {
Wail {The wailer}
Quack {The duck}
}
}
method The {what} {
res+ $what
}
method ho {sound} {$i eval $sound}
}
set i [foo %AUTO%]
$i ho Quack
$i ho Wail
$i destroy
foo destroy
res?
} {duck wailer}
# -------------------------------------------------------------------------
testsuiteCleanup
return
|