File: interp.test

package info (click to toggle)
itcl4 4.3.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,512 kB
  • sloc: ansic: 25,739; tcl: 1,705; sh: 452; makefile: 68
file content (88 lines) | stat: -rw-r--r-- 2,440 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#
# 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