Merge pull request #1976 from codeflash-ai/fix/nested-functions-parity-test

fix: update nested functions parity test
This commit is contained in:
Sarthak Agarwal 2026-04-03 01:11:35 +05:30 committed by GitHub
commit b0c4e1f10e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -440,25 +440,19 @@ class TestDiscoverFunctionsParity:
assert js_sync.is_async is False, "JavaScript sync function should have is_async=False"
def test_nested_functions_discovery(self, python_support, js_support):
"""Python skips nested functions; JavaScript discovers them with parent info."""
"""Both Python and JavaScript skip nested functions — only outer is discovered."""
py_file = write_temp_file(NESTED_FUNCTIONS.python, ".py")
js_file = write_temp_file(NESTED_FUNCTIONS.javascript, ".js")
py_funcs = python_support.discover_functions(py_file.read_text(encoding="utf-8"), py_file)
js_funcs = js_support.discover_functions(js_file.read_text(encoding="utf-8"), js_file)
# Python skips nested functions — only outer is discovered
# Both skip nested functions — only outer is discovered
assert len(py_funcs) == 1, f"Python found {len(py_funcs)}, expected 1"
assert py_funcs[0].function_name == "outer"
# JavaScript discovers both
assert len(js_funcs) == 2, f"JavaScript found {len(js_funcs)}, expected 2"
js_names = {f.function_name for f in js_funcs}
assert js_names == {"outer", "inner"}, f"JavaScript found {js_names}"
js_inner = next(f for f in js_funcs if f.function_name == "inner")
assert len(js_inner.parents) >= 1, "JavaScript inner should have parent info"
assert js_inner.parents[0].name == "outer", "JavaScript inner's parent should be outer"
assert len(js_funcs) == 1, f"JavaScript found {len(js_funcs)}, expected 1"
assert js_funcs[0].function_name == "outer"
def test_static_methods_discovery(self, python_support, js_support):
"""Both should discover static methods."""