#
|
#
|
# Tests for using [incr Tcl] in slave interpreters
|
# Tests for using [incr Tcl] in slave interpreters
|
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
# AUTHOR: Michael J. McLennan
|
# AUTHOR: Michael J. McLennan
|
# Bell Labs Innovations for Lucent Technologies
|
# Bell Labs Innovations for Lucent Technologies
|
# mmclennan@lucent.com
|
# mmclennan@lucent.com
|
# http://www.tcltk.com/itcl
|
# http://www.tcltk.com/itcl
|
#
|
#
|
# RCS: $Id: interp.test,v 1.1.1.1 2002-01-16 10:24:47 markom Exp $
|
# RCS: $Id: interp.test,v 1.1.1.1 2002-01-16 10:24:47 markom Exp $
|
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
# Copyright (c) 1993-1998 Lucent Technologies, Inc.
|
# Copyright (c) 1993-1998 Lucent Technologies, Inc.
|
# ======================================================================
|
# ======================================================================
|
# See the file "license.terms" for information on usage and
|
# See the file "license.terms" for information on usage and
|
# redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
# redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
if {[string compare test [info procs test]] == 1} then {source defs}
|
if {[string compare test [info procs test]] == 1} then {source defs}
|
|
|
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
# Make sure that slave interpreters can be created and loaded
|
# Make sure that slave interpreters can be created and loaded
|
# with [incr Tcl]...
|
# with [incr Tcl]...
|
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
test interp-1.1 {create a slave interp with [incr Tcl]} {
|
test interp-1.1 {create a slave interp with [incr Tcl]} {
|
interp create slave
|
interp create slave
|
load "" Itcl slave
|
load "" Itcl slave
|
list [slave eval "namespace children :: itcl"] [interp delete slave]
|
list [slave eval "namespace children :: itcl"] [interp delete slave]
|
} {::itcl {}}
|
} {::itcl {}}
|
|
|
test interp-1.2 {create a safe slave interp with [incr Tcl]} {
|
test interp-1.2 {create a safe slave interp with [incr Tcl]} {
|
interp create -safe slave
|
interp create -safe slave
|
load "" Itcl slave
|
load "" Itcl slave
|
list [slave eval "namespace children :: itcl"] [interp delete slave]
|
list [slave eval "namespace children :: itcl"] [interp delete slave]
|
} {::itcl {}}
|
} {::itcl {}}
|
|
|
test interp-1.3 {errors are okay when slave interp is deleted} {
|
test interp-1.3 {errors are okay when slave interp is deleted} {
|
interp create slave
|
interp create slave
|
load "" Itcl slave
|
load "" Itcl slave
|
slave eval {
|
slave eval {
|
itcl::class Troublemaker {
|
itcl::class Troublemaker {
|
destructor { error "cannot delete this object" }
|
destructor { error "cannot delete this object" }
|
}
|
}
|
itcl::class Foo {
|
itcl::class Foo {
|
variable obj ""
|
variable obj ""
|
constructor {} {
|
constructor {} {
|
set obj [Troublemaker #auto]
|
set obj [Troublemaker #auto]
|
}
|
}
|
destructor {
|
destructor {
|
delete object $obj
|
delete object $obj
|
}
|
}
|
}
|
}
|
Foo f
|
Foo f
|
}
|
}
|
interp delete slave
|
interp delete slave
|
} {}
|
} {}
|
|
|
test interp-1.4 {one namespace can cause another to be destroyed} {
|
test interp-1.4 {one namespace can cause another to be destroyed} {
|
interp create slave
|
interp create slave
|
load "" Itcl slave
|
load "" Itcl slave
|
slave eval {
|
slave eval {
|
namespace eval group {
|
namespace eval group {
|
itcl::class base1 {}
|
itcl::class base1 {}
|
itcl::class base2 {}
|
itcl::class base2 {}
|
}
|
}
|
itcl::class TroubleMaker {
|
itcl::class TroubleMaker {
|
inherit group::base1 group::base2
|
inherit group::base1 group::base2
|
}
|
}
|
}
|
}
|
interp delete slave
|
interp delete slave
|
} {}
|
} {}
|
|
|