|
||||||
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 |
test {}
| |
testCatch {}
| |
testCatchAssert {}
| |
testCatchException {}
| |
testCatchMultiException {}
| |
testFinally {}
| |
testNamespace {}
| |
testNestedTry {}
| |
testNestedTry2 {}
| |
testRethrowException {}
|
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 |
::xoexception::test::TestProcTry instproc test {} { try { error error } catch {error someError} { return $someError } }
::xoexception::test::TestProcTry instproc testCatch {} { set value [ try { error foobar } catch { error someError } { my assertEquals $someError foobar }] my assertEquals $someError foobar unset someError try { set value 1 } catch { error someError } { set value 2 } my assertFalse [ info exists someError ] my assertEquals $value 1 }
::xoexception::test::TestProcTry instproc testCatchAssert {} { try { my fail "assert failure" } catch { ::xounit::AssertionError assert } { my assertTrue [ info exists assert ] my assertTrue [ Object isobject $assert ] my assertEquals [ $assert message ] "assert failure" set ran 1 } my assertTrue [ info exists assert ] my assertTrue [ Object isobject $assert ] my assertEquals [ $assert message ] "assert failure" my assertEquals $ran 1 }
::xoexception::test::TestProcTry instproc testCatchException {} { catch { try { error foobar } catch { ::xoexception::Exception anError } { my fail "should not run" } puts "testCatchException failed did not throw uncaught error" exit 1 } set value [ try { error [ ::xoexception::Exception new ] } catch { error anError } { my assertTrue [ Object isobject $anError ] }] my assertTrue [ Object isobject $anError ] set value [ try { error [ ::xoexception::Error new ] } catch { error anError } { my assertTrue [ Object isobject $anError ] }] my assertTrue [ info exists anError ] my assertTrue [ Object isobject $anError ] unset anError catch { set value [ try { error [ ::xoexception::Exception new ] } catch { ::xoexception::Error anError } { }] } my assertFalse [ info exists anError ] set value [ try { error [ ::xoexception::Error new ] } catch { ::xoexception::Throwable anError } { }] my assertTrue [ info exists anError ] my assertTrue [ Object isobject $anError ] }
::xoexception::test::TestProcTry instproc testCatchMultiException {} { set value [ try { error [ ::xoexception::Error new ] } catch { ::xoexception::Error anError } { } catch { ::xoexception::Exception anExeception } { } catch { error tclError } { }] my assertTrue [ info exists anError ] my assertFalse [ info exists anException ] my assertFalse [ info exists tclError ] unset anError set value [ try { error [ ::xoexception::Exception new ] } catch { ::xoexception::Error anError } { } catch { ::xoexception::Exception anException } { } catch { error tclError } { }] my assertFalse [ info exists anError ] my assertTrue [ info exists anException ] my assertFalse [ info exists tclError ] unset anException set value [ try { error foobar } catch { ::xoexception::Error anError } { } catch { ::xoexception::Exception anExeception } { } catch { error tclError } { }] my assertFalse [ info exists anError ] my assertFalse [ info exists anException ] my assertTrue [ info exists tclError ] }
::xoexception::test::TestProcTry instproc testFinally {} { try { set value 1 } finally { set a 5 } my assertEquals $value 1 my assertEquals $a 5 unset value unset a catch { try { set value 1 error foobar set value 2 } finally { set a 5 } } my assertEquals $value 1 my assertEquals $a 5 }
::xoexception::test::TestProcTry instproc testNamespace {} { set a 5 puts [ self ] try { puts [ namespace current ] my assertEquals ::xoexception::test [ namespace current ] puts [ self ] my assertEquals $a 5 } finally { puts [ namespace current ] my assertEquals ::xoexception::test [ namespace current ] puts [ self ] my assertEquals $a 5 } my assertEquals $a 5 }
::xoexception::test::TestProcTry instproc testNestedTry {} { try { try { error [ ::xoexception::Exception new ] } catch { ::xoexception::Exception e } { my assertEquals [ $e info class ] ::xoexception::Exception } my assert [ info exists e ] } catch { ::xoexception::Exception e } { my assertEquals [ $e info class ] ::xoexception::Exception } my assert [ info exists e ] }
::xoexception::test::TestProcTry instproc testNestedTry2 {} { try { try { error [ ::xoexception::Error new ] my fail "Should have thrown error" } catch { ::xoexception::Exception e } { my fail "Should not catch exception" } } catch { ::xoexception::Error e } { my assertEquals [ $e info class ] ::xoexception::Error } my assert [ info exists e ] }
::xoexception::test::TestProcTry instproc testRethrowException {} { catch { try { error [ ::xoexception::Error new ] my fail "Should throw error" } catch { ::xoexception::Exception e } { my fail "Should not be caught" } } e my assert [ info exists e ] 1 my assert [ Object isobject $e ] 2 my assertEquals [ $e info class ] ::xoexception::Error 3 }