empty.test

#

Copyright 2019, Erik N. Johnson

This software is distributed under the MIT 3-clause license (../License.ENJ).

#

#

Preamble for all tests

package require tcltest
namespace import ::tcltest::*

lappend auto_path ".."
package require autoObject
#

Empty Object Tests

Series of tests creating and testing the functions of an object with no fields defined or handler classes mixed in. Tests all base-class functions (e.g., configure & cget) that do not need the mixin classes, and tests the null-case handlers for the mixin mechanisms.

puts ""
puts ""
puts "\tEmpty Object Tests"
puts ""

test empty_objectCreate {
    Empty Object Tests:  Create object with empty definition list.
} -body {
    set emptyObj [autoObject new {}]
} -match glob -result "::oo::Obj*"

test empty_objectType { Empty object:  Verify object is the correct class } -body {
    return [info object isa typeof $emptyObj ::autoObject]
} -result 1

test empty_objectValidate { Empty object:  validate } -body {
    $emptyObj validate
} -constraints {
    $::AutoObject::AUTOOBJECT_VERSION >= 1.0
} -result true

test empty_cgetInitialized { Empty object:  cget initialized } -body {
    $emptyObj cget -initialized
} -constraints {
    $::AutoObject::AUTOOBJECT_VERSION > 0.10
} -result false

test empty_isInitializedNot { Empty object: isInitialized s/b false} -body {
    $emptyObj isInitialized
} -constraints {
    $::AutoObject::AUTOOBJECT_VERSION < 1.0
} -result false

test empty_cgetLevel {Empty object cget -level} -body {
    $emptyObj cget -level
} -constraints {
    $::AutoObject::AUTOOBJECT_VERSION > 0.10
} -result "warn"

test empty_configureLevel {Empty object:  configure -level} -body {
    $emptyObj configure -level error
    $emptyObj cget -level
} -constraints {
    $::AutoObject::AUTOOBJECT_VERSION > 0.10
} -result error

test empty_configureAll {
    Empty object:  configure {} should return all options
} -body {
    $emptyObj configure
} -constraints {
    $::AutoObject::AUTOOBJECT_VERSION > 0.10
} -result {-initialized false -level error}
#

Set level back to warn before next test if possible

if {$::AutoObject::AUTOOBJECT_VERSION > 0.10} {
    $emptyObj configure -level warn
}

test empty_getUninitialized { Empty object:  get when uninitialized } -body {
    $emptyObj get
} -match glob -output  "* \\\[\:\:autoObject\] \\\[warn\] 'Reading from uninitialized object * of type ::autoObject'\n"

test empty_configureInit {Empty object:  configure -initialized} -body {
    $emptyObj configure -initialized true
    $emptyObj cget -initialized
} -constraints {
    $::AutoObject::AUTOOBJECT_VERSION > 0.10
} -result true

test empty_initializedGet  {} -body {
    $emptyObj get
} -result {}

test empty_isInitialized { Empty object: isInitialized s/b true} -body {
    $emptyObj isInitialized
} -constraints {
    $::AutoObject::AUTOOBJECT_VERSION < 1.0
} -result true

test empty_toString {Empty object toString} -body {
    $emptyObj toString
} -result ""

test empty_toList {Empty object toList} -body {
    $emptyObj toList
} -result {}

test empty_setNothing {Empty object set} -body {
    $emptyObj set
} -result {}

test empty_fromList {Empty object fromList} -body {
    $emptyObj fromList {}
} -result {}

test empty_toString2 {Empty object toString post fromList} -body {
    $emptyObj toString
} -result ""




cleanupTests