Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make "break" jump out of the "foreach" loop
and add a test to that effect!
- Loading branch information
Showing
3 changed files
with
73 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# 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}" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# | ||
# Input packet | ||
# | ||
User-Name = "bob" | ||
User-Password = "hello" | ||
Filter-Id = "1" | ||
Filter-Id += "2" | ||
Filter-Id += "3" | ||
Filter-Id += "4" | ||
|
||
# | ||
# Expected answer | ||
# | ||
Called-Station-Id == "1" | ||
Called-Station-Id == "2" | ||
Called-Station-Id == "3" | ||
Called-Station-Id == "4" |