From d10bd68ba6f91409f7b256b7f9b6609b940977a3 Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Tue, 21 Nov 2023 18:28:44 -0800 Subject: [PATCH] need to detect custom func cycle, WIP --- tests/unit/script/types/test_function.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/unit/script/types/test_function.py b/tests/unit/script/types/test_function.py index 4ebb206b..bca1a196 100644 --- a/tests/unit/script/types/test_function.py +++ b/tests/unit/script/types/test_function.py @@ -126,6 +126,18 @@ class TestFunction: {"%cycle_func": "{%mul(%cycle_func(1), $0)}", "output": "{%cycle_func(1)}"} ).resolve() + def test_custom_function_chained_cycle(self): + with pytest.raises( + CycleDetected, match=re.escape("The custom function %cycle_func cannot call itself.") + ): + Script( + { + "%cycle_func1": "{%mul(%cycle_func0(1), $0)}", + "%cycle_func0": "{%mul(%cycle_func1(1), $0)}", + "output": "{%cycle_func0(1)}", + } + ).resolve() + def test_lambda_with_custom_function(self): assert Script( {"%times_two": "{%mul($0, 2)}", "wip": "{%array_apply([1, 2, 3], %times_two)}"}