aboutsummaryrefslogtreecommitdiff
path: root/tests/ref.test
blob: acc2793e574b51b2ac0ba2938c437ff99556d6a5 (plain)
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
source [file dirname [info script]]/testing.tcl

needs constraint jim
needs cmd ref
needs cmd collect

test collect-1.1 {ensure globally scoped references are deleted} {
	collect
	set result {}

	# Create a globally scoped reference as a function name
	set a ::[ref testfunction -]
	proc $a {} { return 3 }
	lappend result [$a]
	# It shouldn't be collected
	lappend result [collect]
	lappend result [$a]
	unset a
	# Now it should be collected
	lappend result [collect]
	set result
} {3 0 3 1}

test getref-1.1 {getref basic functionality} {
	set r [ref string tag]
	getref $r
} string

test getref-1.2 {getref fully qualified} {
	getref ::$r
} string

test setref-1.1 {setref basic functionality} {
	setref $r string2
	getref $r
} string2

test setref-1.2 {setref fully qualified} {
	setref ::$r string3
	getref ::$r
} string3

testreport