summaryrefslogtreecommitdiffstats
path: root/src/tests/keywords/foreach-break
blob: 67812fe3fb6b0a3f23897252e675db5d09b00d96 (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
66
67
68
69
70
71
72
73
# PRE: foreach
#

#
#  We DON'T want to see this one.
#
update request {
       Filter-Id += "broken"
}

foreach Filter-Id {
	#
	#  If we see this one, "break" out of the
	#  foreach loop.
	#
	if ("%{Foreach-Variable-0}" == "broken") {
		break
	}

	update reply {
	       Called-Station-Id += "%{Foreach-Variable-0}"
	}
}


#
# Adding attribute during request and immediately breaking
#
update {
	request:Filter-Id += "1"
	request:Filter-Id += "2"
}

foreach &request:Reply-Message {
	if("%{Foreach-Variable-0}" == "1") {
		update {
			request:Filter-Id += "3"
		}
		break

		update reply {
			Filter-Id := "fail-break-1"
		}
	}
}

update {
	request:Filter-Id !* ANY
}

#
# Adding attribute during request and continuing
#
update {
	request:Filter-Id += "1"
	request:Filter-Id += "2"
}

foreach &request:Reply-Message {
	if("%{Foreach-Variable-0}" == "1") {
		update {
			request:Filter-Id += "3"
		}
	}

	if ("%{Foreach-Variable-0}" == "3") {
		break

		update reply {
			Filter-Id := "fail-break-2"
		}
	}
}