]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Regression tests for try/catch
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 30 Apr 2025 18:13:58 +0000 (14:13 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 30 Apr 2025 20:22:51 +0000 (16:22 -0400)
src/tests/keywords/try-no-sibiling [new file with mode: 0644]
src/tests/keywords/try-norcode-catch-no-sibling [new file with mode: 0644]

diff --git a/src/tests/keywords/try-no-sibiling b/src/tests/keywords/try-no-sibiling
new file mode 100644 (file)
index 0000000..2cb6da5
--- /dev/null
@@ -0,0 +1,29 @@
+#
+#  PRE: if
+#
+string foo
+string bar
+
+group {
+       try {
+               foo := "hello"
+
+               fail
+
+               bar := "nope"
+       }
+       catch disallow {
+               test_fail
+       }
+       catch ok reject fail {
+               if foo != "hello" {
+                       test_fail
+               }
+
+               if bar {
+                       test_fail
+               }
+       }
+}
+
+success
diff --git a/src/tests/keywords/try-norcode-catch-no-sibling b/src/tests/keywords/try-norcode-catch-no-sibling
new file mode 100644 (file)
index 0000000..f4815b4
--- /dev/null
@@ -0,0 +1,23 @@
+#
+#  PRE: if
+#
+string foo
+
+#
+#  Try returns noop - which is not caught
+#
+#  Regression test where there are no more sibilings for catch.
+#
+group {
+       try {
+               foo := "hello"
+       }
+       catch disallow {
+               test_fail
+       }
+       catch ok reject fail {
+               test_fail
+       }
+}
+
+success