aboutsummaryrefslogtreecommitdiff
path: root/tests/try.test
blob: 3cc86fb119e03c7edce73e7f7c6fb942efa2c049 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
source testing.tcl

test try-1.1 "Simple case" {
	try {
		set x 0
	} finally {
		incr x
	}
} 0

test try-1.2 "Error in body" {
	list [catch {
		try {
			set x 0
			error message
		} finally {
			incr x
		}
	} msg] $msg $x
} {1 message 1}

test try-1.3 "Error in finally" {
	list [catch {
		try {
			set x 0
		} finally {
			incr x
			error finally
		}
	} msg] $msg $x
} {1 finally 1}

test try-1.4 "Error in both" {
	list [catch {
		try {
			set x 0
			error message
		} finally {
			incr x
			error finally
		}
	} msg] $msg $x
} {1 message 1}

test try-1.5 "break in body" {
	list [catch {
		try {
			set x 0
			break
		} finally {
			incr x
		}
	} msg] $msg $x
} {3 {} 1}

test try-1.6 "break in finally" {
	list [catch {
		try {
			set x 0
		} finally {
			incr x
			break
		}
	} msg] $msg $x
} {3 {} 1}