::xox::test
Class TestPackage

Heritage:
::xotcl::Object
  |
  +--::xox::Node
        |
        +--::xounit::Test
              |
              +--::xounit::Assert
                    |
                    +--::xounit::TestCase
Tested Class:
::xox::Package

Class TestPackage
superclass ::xounit::TestCase,

Variables
NameDefault ValueClassComment
currentTestMethod    ::xounit::TestCase
 name of the currently running test method.
nodeName    ::xox::Node
 
result    ::xounit::TestCase
 the result for the current run.
 
Methods
NameComment
assertPackageLoaded {package}  
assertPackageUnknown {package}  
notestExport {}  
notestImport {}  
notestMakeClass {}  
notestMakePackage {}  
notestMakeTest {}  
setUp {}   setUp is called before each test method in your specific test case
tearDown {}   tearDown is called after each test method in your specific test case
testForgetAll {}  
testIsPackage {}  
testPackageName {}  
testReloadABC {}  
testReloadServer {}  
   
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

assertPackageLoaded

Description:
 
Arguments:
Code:
  ::xox::test::TestPackage instproc assertPackageLoaded {package}  {
   

        my assertNoError { package present $package } "Package $package is not loaded"
    
}

assertPackageUnknown

Description:
 
Arguments:
Code:
  ::xox::test::TestPackage instproc assertPackageUnknown {package}  {
   

        set subs [ ::xox::removeIfNot { 
            string match "${package}" $name 
            } name [ package names ] ]

        my assertEquals $subs "" "Package $package is not unknown"
    
}

notestExport

Description:
 
Code:
  ::xox::test::TestPackage instproc notestExport {}  {
   

         ::xox::Package ::testexportpackage

         ::testexportpackage proc return5 { } { return 5 }

         my assertError { return5 }
         
         my assertNotEquals [info procs return5] return5

         ::testexportpackage export [namespace current]

         my assertEquals [info procs return5] return5

         my assertEquals [ return5 ] 5
    
}

notestImport

Description:
 
Code:
  ::xox::test::TestPackage instproc notestImport {}  {
   

         ::xox::Package ::testimportpackage

         ::testimportpackage proc return6 { } { return 6 }

         my assertError { return6 }
         
         my assertNotEquals [info procs return6] return6

         ::testimportpackage import

         my assertEquals [info procs return6] return6

         my assertEquals [ return6 ] 6
    
}

notestMakeClass

Description:
 
Code:
  ::xox::test::TestPackage instproc notestMakeClass {}  {
   

        ::xox::Package makeClass xyz XYZ
        my assert [ file exists XYZ.tcl ]
        source XYZ.tcl
        my assert [ Object isclass ::xyz::XYZ ]
        my assert [ ::xyz::XYZ exists #(XYZ) ]
    
}

notestMakePackage

Description:
 
Code:
  ::xox::test::TestPackage instproc notestMakePackage {}  {
   

        ::xox::Package makePackage xyz
        my assert [ file exists xyz ]
        my assert [ file exists xyz/xyz.tcl ]
        my assert [ file exists xyz/test ]
        my assert [ file exists xyz/test/xyz.tcl ]
        my assert [ file exists xyz/pkgIndex.tcl ]

        source xyz/xyz.tcl
        source xyz/test/xyz.tcl

        package require xyz
    
}

notestMakeTest

Description:
 
Code:
  ::xox::test::TestPackage instproc notestMakeTest {}  {
   

        ::xox::Package makeTest xyz XYZ
        my assert [ file exists TestXYZ.tcl ]
        source TestXYZ.tcl
        my assert [ Object isclass ::xyz::test::TestXYZ ]
    
}

setUp

Description:
 setUp is called before each test method in
 your specific test case.  This provides a clean
 test fixture for each test method.  Over-ride 
 setUp in your specific TestCase to configure
 your TestCase before each test.  Example:

 SimpleTest instproc setUp {} {

     my set testValue 10
 }

 SimpleTest instproc testValue {} {

     my assertEquals [ my set testValue ] 10
 }
Overrides:
setUp in ::xounit::TestCase
Code:
  ::xox::test::TestPackage instproc setUp {}  {
   

        #add set up code here
    
}

tearDown

Description:
 tearDown is called after each test method
 in your specific test case.  This allows
 you to clean up any resources that were used
 in your test methods. Override this method
 in your TestCase and it will automatically
 called after each test method.
Overrides:
tearDown in ::xounit::TestCase
Code:
  ::xox::test::TestPackage instproc tearDown {}  {
   

        catch { file delete XYZ.tcl }
        catch { file delete TestXYZ.tcl }
        catch { file delete -force xyz }
    
}

testForgetAll

Description:
 
Code:
  ::xox::test::TestPackage instproc testForgetAll {}  {
   

        my assertPackageLoaded xox

        package require abc

        my assertPackageLoaded abc

        package forget abc

        my assertPackageUnknown abc

        my assertFailure {

            my assertPackageLoaded abc
        }

        my assertError { package require notapackage }

        my assertFailure {

            my assertPackageUnknown abc
        }

        package require abc

        my assertPackageLoaded abc

        ::abc forgetAll

        my assertFailure {

            my assertPackageLoaded abc
        }

        my assertPackageUnknown abc
    
}

testIsPackage

Description:
 
Code:
  ::xox::test::TestPackage instproc testIsPackage {}  {
   

        my assert [ ::xox::Package isPackage xox ]
        my assert [ ::xox::Package isPackage xox::test::TestPackage ]
    
}

testPackageName

Description:
 
Code:
  ::xox::test::TestPackage instproc testPackageName {}  {
   

        my assertEquals [ ::xox packageName ] xox
    
}

testReloadABC

Description:
 
Code:
  ::xox::test::TestPackage instproc testReloadABC {}  {
   

        package require abc

        my assertPackageLoaded abc

        ::abc reload

        my assertPackageLoaded abc
    
}

testReloadServer

Description:
 
Code:
  ::xox::test::TestPackage instproc testReloadServer {}  {
   

        package require server

        ::server forgetAll

        my assertPackageUnknown server

        ::server findPackages

        my assertFailure { my assertPackageUnknown server }
        my assertFailure { my assertPackageLoaded server }

        ::server loadAll

        ::server reload

        my assertPackageLoaded server::UserInterface
        my assertObject ::server::UserInterface
    
}