89 lines
2.6 KiB
Plaintext
89 lines
2.6 KiB
Plaintext
|
#
|
||
|
# Tests for using [incr Tcl] in child interpreters
|
||
|
# ----------------------------------------------------------------------
|
||
|
# AUTHOR: Michael J. McLennan
|
||
|
# Bell Labs Innovations for Lucent Technologies
|
||
|
# mmclennan@lucent.com
|
||
|
# http://www.tcltk.com/itcl
|
||
|
# ----------------------------------------------------------------------
|
||
|
# Copyright (c) 1993-1998 Lucent Technologies, Inc.
|
||
|
# ======================================================================
|
||
|
# See the file "license.terms" for information on usage and
|
||
|
# redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||
|
|
||
|
package require tcltest 2.1
|
||
|
namespace import ::tcltest::test
|
||
|
::tcltest::loadTestedCommands
|
||
|
package require itcl
|
||
|
|
||
|
# ----------------------------------------------------------------------
|
||
|
# Make sure that child interpreters can be created and loaded
|
||
|
# with [incr Tcl]...
|
||
|
# ----------------------------------------------------------------------
|
||
|
test interp-1.1 {create a child interp with [incr Tcl]} {
|
||
|
interp create child
|
||
|
load "" Itcl child
|
||
|
list [child eval "namespace children :: itcl"] [interp delete child]
|
||
|
} {::itcl {}}
|
||
|
|
||
|
test interp-1.2 {create a safe child interp with [incr Tcl]} {
|
||
|
interp create -safe child
|
||
|
load "" Itcl child
|
||
|
list [child eval "namespace children :: itcl"] [interp delete child]
|
||
|
} {::itcl {}}
|
||
|
|
||
|
test interp-1.3 {errors are okay when child interp is deleted} {
|
||
|
catch {interp delete child}
|
||
|
interp create child
|
||
|
load "" Itcl child
|
||
|
child eval {
|
||
|
itcl::class Troublemaker {
|
||
|
destructor { error "cannot delete this object" }
|
||
|
}
|
||
|
itcl::class Foo {
|
||
|
variable obj ""
|
||
|
constructor {} {
|
||
|
set obj [Troublemaker #auto]
|
||
|
}
|
||
|
destructor {
|
||
|
delete object $obj
|
||
|
}
|
||
|
}
|
||
|
Foo f
|
||
|
}
|
||
|
interp delete child
|
||
|
} {}
|
||
|
|
||
|
test interp-1.4 {one namespace can cause another to be destroyed} {
|
||
|
interp create child
|
||
|
load "" Itcl child
|
||
|
child eval {
|
||
|
namespace eval group {
|
||
|
itcl::class base1 {}
|
||
|
itcl::class base2 {}
|
||
|
}
|
||
|
itcl::class TroubleMaker {
|
||
|
inherit group::base1 group::base2
|
||
|
}
|
||
|
}
|
||
|
interp delete child
|
||
|
} {}
|
||
|
|
||
|
test interp-1.5 {cleanup interp object list, this should not
|
||
|
include an object that deletes itself in ctor} {
|
||
|
interp create child
|
||
|
load "" Itcl child
|
||
|
child eval {
|
||
|
itcl::class DeleteSelf {
|
||
|
constructor {} {
|
||
|
itcl::delete object $this
|
||
|
}
|
||
|
}
|
||
|
DeleteSelf ds
|
||
|
}
|
||
|
interp delete child
|
||
|
} {}
|
||
|
|
||
|
::tcltest::cleanupTests
|
||
|
return
|