1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-31 15:12:06 +00:00

Merge branch 'stateless_lambdas' into integration

This commit is contained in:
J. Nick Koston
2025-10-26 01:31:14 -07:00
5 changed files with 28 additions and 17 deletions

View File

@@ -213,6 +213,23 @@ class TestLambdaExpression:
"+[](int32_t foo, float bar) -> float {\n return foo + bar;\n}"
)
def test_str__with_capture_no_prefix(self):
"""Test lambda with capture (not stateless) does NOT get + prefix"""
target = cg.LambdaExpression(
("return captured_var + x;",),
((int, "x"),),
"captured_var", # Has capture (not stateless)
int,
)
actual = str(target)
# Should NOT have + prefix
assert actual == (
"[captured_var](int32_t x) -> int32_t {\n return captured_var + x;\n}"
)
assert not actual.startswith("+")
class TestLiterals:
@pytest.mark.parametrize(