1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-31 07:03:55 +00:00
This commit is contained in:
J. Nick Koston
2025-10-26 01:30:39 -07:00
parent c30e130a48
commit 97346e5644
5 changed files with 22 additions and 5 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(