|
||||||
| SUMMARY: CHILDREN | PARAMETER | INSTPROC | INSTFILTER | INSTFORWARD | DETAIL: | INSTPROC | |||||
::xotcl::Object
|
+--::xox::Node
|
+--::xounit::Test
|
+--::xounit::Assert
|
+--::xounit::TestCase
| Variables | |||
| Name | Default Value | Class | Comment |
currentTestMethod |
::xounit::TestCase | name of the currently running test method. |
|
nodeName |
::xox::Node | ||
result |
::xounit::TestCase | the result for the current run. |
|
| Methods | |
| Name | Comment |
testEvenp {}
| |
testIdentity {}
| |
testMapcar {}
| |
testOddp {}
| |
testReadFile {}
| |
testRemoveIfNot {}
| |
testWithOpenFile {}
| |
testWithOpenFileError {}
| |
testWithOpenScriptError {}
| |
| Methods from ::xotcl::Object |
#, ., ?, ?code, ?methods, ?object, abstract, copy, coverageFilter, defaultmethod, extractConfigureArg, filterappend, garbageCollect, get#, getClean#, hasclass, init, methodTag, mixinappend, move, profileFilter, self, setParameterDefaults, shell, tclcmd, traceFilter,
|
| Instproc Detail |
::xox::test::TestHigherOrderTcl instproc testEvenp {} {
my assertFalse [ ::xox::evenp 1 ]
my assert [ ::xox::evenp 2 ]
my assertFalse [ ::xox::evenp 51 ]
my assert [ ::xox::evenp 98 ]
}
::xox::test::TestHigherOrderTcl instproc testIdentity {} {
my assertEquals [ ::xox::identity a ] a
my assertEquals [ ::xox::mapcar {
::xox::identity $x
} x {1 2 3 4 5} ] {1 2 3 4 5}
}
::xox::test::TestHigherOrderTcl instproc testMapcar {} {
my assertEquals [ ::xox::mapcar { expr {1 + $item} } item {1 2 3 4 5} ] {2 3 4 5 6}
set list {1 2 3 4 5}
my assertEquals [ ::xox::mapcar { expr {2 + $item} } item $list ] {3 4 5 6 7}
proc getListXYZ { } {
return {1 2 3 4 5}
}
my assertEquals [ ::xox::mapcar { expr {3 + $item} } item [ getListXYZ ] ] {4 5 6 7 8}
}
::xox::test::TestHigherOrderTcl instproc testOddp {} {
my assert [ ::xox::oddp 1 ]
my assertFalse [ ::xox::oddp 2 ]
my assert [ ::xox::oddp 51 ]
my assertFalse [ ::xox::oddp 98 ]
}
::xox::test::TestHigherOrderTcl instproc testReadFile {} {
my assertFalse [ info exists data]
my assertEquals hello [ string trim [ ::xox::readFile test/withOpenFile ]]
my assertFalse [ info exists data]
}
::xox::test::TestHigherOrderTcl instproc testRemoveIfNot {} {
my assertEquals [ ::xox::removeIfNot { ::xox::oddp $x } x { 1 2 3 4 5 } ] {1 3 5}
my assertEquals [ ::xox::removeIf { ::xox::oddp $x } x { 1 2 3 4 5 } ] {2 4}
my assertEquals [ ::xox::removeIf { expr { "2" == "$x" } } x { 1 2 3 4 5 } ] {1 3 4 5}
}
::xox::test::TestHigherOrderTcl instproc testWithOpenFile {} {
set data nothing
my assertEquals $data nothing
my assertFalse [ info exists error ]
::xox::withOpenFile test/withOpenFile r file {
set data [string trim [ read $file ] ]
my assertEquals $data hello
}
my assertEquals $data hello
my assertFalse [ info exists error ]
}
::xox::test::TestHigherOrderTcl instproc testWithOpenFileError {} {
my assertError {
::xox::withOpenFile test/noSuchFile r file {
}
}
my assertError { close $file }
}
::xox::test::TestHigherOrderTcl instproc testWithOpenScriptError {} {
my assertError {
::xox::withOpenFile test/withOpenFile r file {
error "script error"
}
}
my assertError { close $file }
}