test_guard_ts_parser.py

tests/guard/test_guard_ts_parser.py

Tests for clew.guard.ts_parser (absorbed from doxygen-guard) — tree-sitter based function extraction.

test_basic_c_function

test_guard_ts_parser.TestCFunctionDetection.test_basic_c_function(self)

tests/guard/test_guard_ts_parser.py:11

Checks

  • assert len(funcs) == 1
  • assert funcs[0].name == "my_func"
  • assert funcs[0].doxygen is not None
  • assert "brief" in funcs[0].doxygen.tags

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-019measuredtest_basic_c_function → parse_functions_ts → _collect_functions → _find_preceding_doxygen → parse_doxygen_tags
REQ-DDB-GUARD-020measuredtest_basic_c_function → parse_functions_ts
REQ-DDB-GUARD-021inferredtest_basic_c_function → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block
REQ-DDB-GUARD-024inferredtest_basic_c_function → parse_functions_ts → _collect_functions → _is_rust_test_item
REQ-DDB-GUARD-025measuredtest_basic_c_function → parse_functions_ts → _collect_functions → _js_returns_void
Source · 16 lines
    def test_basic_c_function(self):
        code = """\
/**
 * @brief Do something.
 * @version 1.0
 */
void my_func(void) {
    return;
}
"""
        funcs = parse_functions_ts(code, "c")
        assert len(funcs) == 1
        assert funcs[0].name == "my_func"
        assert funcs[0].doxygen is not None
        assert "brief" in funcs[0].doxygen.tags

test_basic_python_function

test_guard_ts_parser.TestPythonFunctionDetection.test_basic_python_function(self)

tests/guard/test_guard_ts_parser.py:138

Checks

  • assert len(funcs) == 1
  • assert funcs[0].name == "load_config"
  • assert funcs[0].doxygen is not None
  • assert funcs[0].doxygen.tags.get("req") == ["REQ-CONFIG-001"]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-019measuredtest_basic_python_function → parse_functions_ts → _collect_functions → _find_preceding_doxygen → parse_doxygen_tags
REQ-DDB-GUARD-020measuredtest_basic_python_function → parse_functions_ts
REQ-DDB-GUARD-021inferredtest_basic_python_function → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block
REQ-DDB-GUARD-024inferredtest_basic_python_function → parse_functions_ts → _collect_functions → _is_rust_test_item
REQ-DDB-GUARD-025measuredtest_basic_python_function → parse_functions_ts → _collect_functions → _js_returns_void
Source · 15 lines
    def test_basic_python_function(self):
        code = """\
## @brief Load config.
#  @version 1.0
#  @req REQ-CONFIG-001
def load_config(path=None):
    data = read_yaml(path)
    return deep_merge(DEFAULTS, data)
"""
        funcs = parse_functions_ts(code, "python", comment_start_pattern=r"^\s*##(?!#)")
        assert len(funcs) == 1
        assert funcs[0].name == "load_config"
        assert funcs[0].doxygen is not None
        assert funcs[0].doxygen.tags.get("req") == ["REQ-CONFIG-001"]

test_body_end_line

test_guard_ts_parser.TestCFunctionDetection.test_body_end_line(self)

tests/guard/test_guard_ts_parser.py:108

Checks

  • assert len(funcs) == 1
  • assert funcs[0].def_line == 0
  • assert funcs[0].body_end == 3

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-019measuredtest_body_end_line → parse_functions_ts → _collect_functions → _find_preceding_doxygen → parse_doxygen_tags
REQ-DDB-GUARD-020measuredtest_body_end_line → parse_functions_ts
REQ-DDB-GUARD-021inferredtest_body_end_line → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block
REQ-DDB-GUARD-024inferredtest_body_end_line → parse_functions_ts → _collect_functions → _is_rust_test_item
REQ-DDB-GUARD-025measuredtest_body_end_line → parse_functions_ts → _collect_functions → _js_returns_void
Source · 12 lines
    def test_body_end_line(self):
        code = """\
void func(void) {
    int x = 1;
    int y = 2;
}
"""
        funcs = parse_functions_ts(code, "c")
        assert len(funcs) == 1
        assert funcs[0].def_line == 0
        assert funcs[0].body_end == 3

test_cloud_fixture

test_guard_ts_parser.TestParityWithFixtures.test_cloud_fixture(self)

tests/guard/test_guard_ts_parser.py:215

Checks

  • assert "startMqttConnection" in names

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-019measuredtest_cloud_fixture → parse_functions_ts → _collect_functions → _find_preceding_doxygen → parse_doxygen_tags
REQ-DDB-GUARD-020measuredtest_cloud_fixture → parse_functions_ts
REQ-DDB-GUARD-021inferredtest_cloud_fixture → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block
REQ-DDB-GUARD-024inferredtest_cloud_fixture → parse_functions_ts → _collect_functions → _is_rust_test_item
REQ-DDB-GUARD-025measuredtest_cloud_fixture → parse_functions_ts → _collect_functions → _js_returns_void
Source · 9 lines
    def test_cloud_fixture(self):
        from guard_helpers import FIXTURES_DIR

        content = (FIXTURES_DIR / "sources" / "cloud_mgr" / "cloud.c").read_text()
        funcs = parse_functions_ts(content, "c")
        names = [f.name for f in funcs]
        assert "startMqttConnection" in names

Activity · 5 steps
lines 216–216from guard_helpers import FIXTURES_DIRlines 218–218content = (FIXTURES_DIR / "sources" / "cloud_mgr" / "cloud.c").read_text()lines 219–219funcs = parse_functions_ts(content, "c")lines 220–220names = [f.name for f in funcs]lines 221–221assert "startMqttConnection" in names

test_decorated_function

test_guard_ts_parser.TestPythonFunctionDetection.test_decorated_function(self)

tests/guard/test_guard_ts_parser.py:174

Checks

  • assert len(funcs) == 1
  • assert funcs[0].name == "decorated"
  • assert funcs[0].doxygen is not None
  • assert "internal" in funcs[0].doxygen.tags

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-019measuredtest_decorated_function → parse_functions_ts → _collect_functions → _find_preceding_doxygen → parse_doxygen_tags
REQ-DDB-GUARD-020measuredtest_decorated_function → parse_functions_ts
REQ-DDB-GUARD-021inferredtest_decorated_function → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block
REQ-DDB-GUARD-024inferredtest_decorated_function → parse_functions_ts → _collect_functions → _is_rust_test_item
REQ-DDB-GUARD-025measuredtest_decorated_function → parse_functions_ts → _collect_functions → _js_returns_void
Source · 16 lines
    def test_decorated_function(self):
        code = """\
## @brief A decorated func.
#  @version 1.0
#  @internal
@dataclass
def decorated():
    pass
"""
        funcs = parse_functions_ts(code, "python", comment_start_pattern=r"^\s*##(?!#)")
        assert len(funcs) == 1
        assert funcs[0].name == "decorated"
        assert funcs[0].doxygen is not None
        assert "internal" in funcs[0].doxygen.tags

test_doxygen_tags_extracted

test_guard_ts_parser.TestCFunctionDetection.test_doxygen_tags_extracted(self)

tests/guard/test_guard_ts_parser.py:86

Checks

  • assert len(funcs) == 1
  • assert tags.get("req") == ["REQ-0252"]
  • assert tags.get("sends") == ["EVENT_PAIRING_STARTED"]
  • assert tags.get("calls") == ["wifi_mgr::WiFi_ConnectAfterDelay"]
  • assert tags.get("note") == ["CLOUD_DISABLE"]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-019measuredtest_doxygen_tags_extracted → parse_functions_ts → _collect_functions → _find_preceding_doxygen → parse_doxygen_tags
REQ-DDB-GUARD-020measuredtest_doxygen_tags_extracted → parse_functions_ts
REQ-DDB-GUARD-021inferredtest_doxygen_tags_extracted → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block
REQ-DDB-GUARD-024inferredtest_doxygen_tags_extracted → parse_functions_ts → _collect_functions → _is_rust_test_item
REQ-DDB-GUARD-025measuredtest_doxygen_tags_extracted → parse_functions_ts → _collect_functions → _js_returns_void
Source · 22 lines
    def test_doxygen_tags_extracted(self):
        code = """\
/**
 * @brief Start pairing.
 * @version 1.0
 * @req REQ-0252
 * @sends EVENT_PAIRING_STARTED
 * @calls wifi_mgr::WiFi_ConnectAfterDelay
 * @note CLOUD_DISABLE
 */
void Pairing_Start(void) {
    disable_cloud();
}
"""
        funcs = parse_functions_ts(code, "c")
        assert len(funcs) == 1
        tags = funcs[0].doxygen.tags
        assert tags.get("req") == ["REQ-0252"]
        assert tags.get("sends") == ["EVENT_PAIRING_STARTED"]
        assert tags.get("calls") == ["wifi_mgr::WiFi_ConnectAfterDelay"]
        assert tags.get("note") == ["CLOUD_DISABLE"]

test_exclude_names

test_guard_ts_parser.TestCFunctionDetection.test_exclude_names(self)

tests/guard/test_guard_ts_parser.py:77

Checks

  • assert "if" not in names

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-018measured
REQ-DDB-GUARD-019measuredtest_exclude_names → parse_functions_ts → _collect_functions → _find_preceding_doxygen → parse_doxygen_tags
REQ-DDB-GUARD-020measuredtest_exclude_names → parse_functions_ts
REQ-DDB-GUARD-021inferredtest_exclude_names → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block
REQ-DDB-GUARD-024inferredtest_exclude_names → parse_functions_ts → _collect_functions → _is_rust_test_item
REQ-DDB-GUARD-025measuredtest_exclude_names → parse_functions_ts → _collect_functions → _js_returns_void
Source · 9 lines
    def test_exclude_names(self):
        code = """\
void if(void) { }
void real(void) { }
"""
        funcs = parse_functions_ts(code, "c", exclude_names=["if"])
        names = [f.name for f in funcs]
        assert "if" not in names

test_forward_declaration_excluded

test_guard_ts_parser.TestCFunctionDetection.test_forward_declaration_excluded(self)

Forward declarations (no body) should be excluded.

tests/guard/test_guard_ts_parser.py:60

Checks

  • assert len(funcs) == 1
  • assert funcs[0].name == "real_func"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-019measuredtest_forward_declaration_excluded → parse_functions_ts → _collect_functions → _find_preceding_doxygen → parse_doxygen_tags
REQ-DDB-GUARD-020measuredtest_forward_declaration_excluded → parse_functions_ts
REQ-DDB-GUARD-021inferredtest_forward_declaration_excluded → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block
REQ-DDB-GUARD-024inferredtest_forward_declaration_excluded → parse_functions_ts → _collect_functions → _is_rust_test_item
REQ-DDB-GUARD-025measuredtest_forward_declaration_excluded → parse_functions_ts → _collect_functions → _js_returns_void
Source · 17 lines
    def test_forward_declaration_excluded(self):
        """Forward declarations (no body) should be excluded."""
        code = """\
void forward_decl(void);

/**
 * @brief Real function.
 * @version 1.0
 */
void real_func(void) {
    return;
}
"""
        funcs = parse_functions_ts(code, "c")
        assert len(funcs) == 1
        assert funcs[0].name == "real_func"

test_function_without_doxygen

test_guard_ts_parser.TestCFunctionDetection.test_function_without_doxygen(self)

tests/guard/test_guard_ts_parser.py:50

Checks

  • assert len(funcs) == 1
  • assert funcs[0].doxygen is None

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-019measuredtest_function_without_doxygen → parse_functions_ts → _collect_functions → _find_preceding_doxygen → parse_doxygen_tags
REQ-DDB-GUARD-020measuredtest_function_without_doxygen → parse_functions_ts
REQ-DDB-GUARD-021inferredtest_function_without_doxygen → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block
REQ-DDB-GUARD-024inferredtest_function_without_doxygen → parse_functions_ts → _collect_functions → _is_rust_test_item
REQ-DDB-GUARD-025measuredtest_function_without_doxygen → parse_functions_ts → _collect_functions → _js_returns_void
Source · 10 lines
    def test_function_without_doxygen(self):
        code = """\
void no_doc(void) {
    return;
}
"""
        funcs = parse_functions_ts(code, "c")
        assert len(funcs) == 1
        assert funcs[0].doxygen is None

test_inline_constructor

test_guard_ts_parser.TestConstructorDestructorDetection.test_inline_constructor(self)

tests/guard/test_guard_ts_parser.py:227

Checks

  • assert ctor is not None
  • assert ctor.enclosing_class == "Foo"
  • assert ctor.is_constructor()
  • assert not ctor.is_destructor()

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-019measuredtest_inline_constructor → parse_functions_ts → _collect_functions → _find_preceding_doxygen → parse_doxygen_tags
REQ-DDB-GUARD-020measuredtest_inline_constructor → parse_functions_ts
REQ-DDB-GUARD-021inferredtest_inline_constructor → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block
REQ-DDB-GUARD-024inferredtest_inline_constructor → parse_functions_ts → _collect_functions → _is_rust_test_item
REQ-DDB-GUARD-025measuredtest_inline_constructor → parse_functions_ts → _collect_functions → _js_returns_void
Source · 14 lines
    def test_inline_constructor(self):
        code = """\
class Foo {
public:
    Foo() {}
};
"""
        funcs = parse_functions_ts(code, "cpp")
        ctor = next((f for f in funcs if f.name == "Foo"), None)
        assert ctor is not None
        assert ctor.enclosing_class == "Foo"
        assert ctor.is_constructor()
        assert not ctor.is_destructor()

test_inline_destructor

test_guard_ts_parser.TestConstructorDestructorDetection.test_inline_destructor(self)

tests/guard/test_guard_ts_parser.py:241

Checks

  • assert dtor is not None
  • assert dtor.enclosing_class == "Foo"
  • assert dtor.is_destructor()
  • assert not dtor.is_constructor()

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-019measuredtest_inline_destructor → parse_functions_ts → _collect_functions → _find_preceding_doxygen → parse_doxygen_tags
REQ-DDB-GUARD-020measuredtest_inline_destructor → parse_functions_ts
REQ-DDB-GUARD-021inferredtest_inline_destructor → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block
REQ-DDB-GUARD-024inferredtest_inline_destructor → parse_functions_ts → _collect_functions → _is_rust_test_item
REQ-DDB-GUARD-025measuredtest_inline_destructor → parse_functions_ts → _collect_functions → _js_returns_void
Source · 14 lines
    def test_inline_destructor(self):
        code = """\
class Foo {
public:
    ~Foo() {}
};
"""
        funcs = parse_functions_ts(code, "cpp")
        dtor = next((f for f in funcs if f.name == "~Foo"), None)
        assert dtor is not None
        assert dtor.enclosing_class == "Foo"
        assert dtor.is_destructor()
        assert not dtor.is_constructor()

test_method_not_constructor

test_guard_ts_parser.TestConstructorDestructorDetection.test_method_not_constructor(self)

tests/guard/test_guard_ts_parser.py:280

Checks

  • assert method is not None
  • assert method.enclosing_class == "Foo"
  • assert not method.is_constructor()
  • assert not method.is_destructor()

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-019measuredtest_method_not_constructor → parse_functions_ts → _collect_functions → _find_preceding_doxygen → parse_doxygen_tags
REQ-DDB-GUARD-020measuredtest_method_not_constructor → parse_functions_ts
REQ-DDB-GUARD-021inferredtest_method_not_constructor → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block
REQ-DDB-GUARD-024inferredtest_method_not_constructor → parse_functions_ts → _collect_functions → _is_rust_test_item
REQ-DDB-GUARD-025measuredtest_method_not_constructor → parse_functions_ts → _collect_functions → _js_returns_void
Source · 14 lines
    def test_method_not_constructor(self):
        code = """\
class Foo {
public:
    void bar() {}
};
"""
        funcs = parse_functions_ts(code, "cpp")
        method = next((f for f in funcs if f.name == "bar"), None)
        assert method is not None
        assert method.enclosing_class == "Foo"
        assert not method.is_constructor()
        assert not method.is_destructor()

test_multiple_functions

test_guard_ts_parser.TestCFunctionDetection.test_multiple_functions(self)

tests/guard/test_guard_ts_parser.py:27

Checks

  • assert len(funcs) == 2
  • assert funcs[0].name == "alpha"
  • assert funcs[1].name == "beta"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-001measured
REQ-DDB-GUARD-005inferred
REQ-DDB-GUARD-019measuredtest_multiple_functions → parse_functions_ts → _collect_functions → _find_preceding_doxygen → parse_doxygen_tags
REQ-DDB-GUARD-020measuredtest_multiple_functions → parse_functions_ts
REQ-DDB-GUARD-021inferredtest_multiple_functions → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block
REQ-DDB-GUARD-024inferredtest_multiple_functions → parse_functions_ts → _collect_functions → _is_rust_test_item
REQ-DDB-GUARD-025measuredtest_multiple_functions → parse_functions_ts → _collect_functions → _js_returns_void
Source · 23 lines
    def test_multiple_functions(self):
        code = """\
/**
 * @brief First.
 * @version 1.0
 */
int alpha(void) {
    return 0;
}

/**
 * @brief Second.
 * @version 1.0
 */
void beta(int x) {
    do_something(x);
}
"""
        funcs = parse_functions_ts(code, "c")
        assert len(funcs) == 2
        assert funcs[0].name == "alpha"
        assert funcs[1].name == "beta"

test_out_of_line_constructor

test_guard_ts_parser.TestConstructorDestructorDetection.test_out_of_line_constructor(self)

tests/guard/test_guard_ts_parser.py:255

Checks

  • assert len(out_of_line) >= 1
  • assert all(f.is_constructor() for f in out_of_line)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-019measuredtest_out_of_line_constructor → parse_functions_ts → _collect_functions → _find_preceding_doxygen → parse_doxygen_tags
REQ-DDB-GUARD-020measuredtest_out_of_line_constructor → parse_functions_ts
REQ-DDB-GUARD-021inferredtest_out_of_line_constructor → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block
REQ-DDB-GUARD-024inferredtest_out_of_line_constructor → parse_functions_ts → _collect_functions → _is_rust_test_item
REQ-DDB-GUARD-025measuredtest_out_of_line_constructor → parse_functions_ts → _collect_functions → _js_returns_void
REQ-DDB-WIKI-054inferredtest_out_of_line_constructor → all
Source · 14 lines
    def test_out_of_line_constructor(self):
        code = """\
class Foo {
public:
    Foo();
};

Foo::Foo() {}
"""
        funcs = parse_functions_ts(code, "cpp")
        out_of_line = [f for f in funcs if f.name == "Foo"]
        assert len(out_of_line) >= 1
        assert all(f.is_constructor() for f in out_of_line)

test_pairing_fixture

test_guard_ts_parser.TestParityWithFixtures.test_pairing_fixture(self)

tests/guard/test_guard_ts_parser.py:193

Checks

  • assert "Pairing_Start" in names
  • assert "ContinuePairing" in names
  • assert pairing.doxygen is not None
  • assert pairing.doxygen.tags.get("req") == ["REQ-0252"]
  • assert pairing.doxygen.tags.get("sends") == ["EVENT_PAIRING_STARTED"]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-019measuredtest_pairing_fixture → parse_functions_ts → _collect_functions → _find_preceding_doxygen → parse_doxygen_tags
REQ-DDB-GUARD-020measuredtest_pairing_fixture → parse_functions_ts
REQ-DDB-GUARD-021inferredtest_pairing_fixture → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block
REQ-DDB-GUARD-024inferredtest_pairing_fixture → parse_functions_ts → _collect_functions → _is_rust_test_item
REQ-DDB-GUARD-025measuredtest_pairing_fixture → parse_functions_ts → _collect_functions → _js_returns_void
Source · 14 lines
    def test_pairing_fixture(self):
        from guard_helpers import FIXTURES_DIR

        content = (FIXTURES_DIR / "sources" / "pairing_mgr" / "pairing.c").read_text()
        funcs = parse_functions_ts(content, "c")
        names = [f.name for f in funcs]
        assert "Pairing_Start" in names
        assert "ContinuePairing" in names

        pairing = next(f for f in funcs if f.name == "Pairing_Start")
        assert pairing.doxygen is not None
        assert pairing.doxygen.tags.get("req") == ["REQ-0252"]
        assert pairing.doxygen.tags.get("sends") == ["EVENT_PAIRING_STARTED"]
Activity · 10 steps
lines 194–194from guard_helpers import FIXTURES_DIRlines 196–196content = (FIXTURES_DIR / "sources" / "pairing_mgr" / "pairing.c").read_text()lines 197–197funcs = parse_functions_ts(content, "c")lines 198–198names = [f.name for f in funcs]lines 199–199assert "Pairing_Start" in nameslines 200–200assert "ContinuePairing" in nameslines 202–202pairing = next(f for f in funcs if f.name == "Pairing_Start")lines 203–203assert pairing.doxygen is not Nonelines 204–204assert pairing.doxygen.tags.get("req") == ["REQ-0252"]lines 205–205assert pairing.doxygen.tags.get("sends") == ["EVENT_PAIRING_STARTED"]

test_python_body_end

test_guard_ts_parser.TestPythonFunctionDetection.test_python_body_end(self)

tests/guard/test_guard_ts_parser.py:153

Checks

  • assert len(funcs) == 1
  • assert funcs[0].def_line == 0
  • assert funcs[0].body_end == 3

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-019measuredtest_python_body_end → parse_functions_ts → _collect_functions → _find_preceding_doxygen → parse_doxygen_tags
REQ-DDB-GUARD-020measuredtest_python_body_end → parse_functions_ts
REQ-DDB-GUARD-021measuredtest_python_body_end → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block
REQ-DDB-GUARD-024inferredtest_python_body_end → parse_functions_ts → _collect_functions → _is_rust_test_item
REQ-DDB-GUARD-025measuredtest_python_body_end → parse_functions_ts → _collect_functions → _js_returns_void
Source · 12 lines
    def test_python_body_end(self):
        code = """\
def func():
    x = 1
    y = 2
    return x + y
"""
        funcs = parse_functions_ts(code, "python", comment_start_pattern=r"^\s*##(?!#)")
        assert len(funcs) == 1
        assert funcs[0].def_line == 0
        assert funcs[0].body_end == 3

test_python_no_doxygen

test_guard_ts_parser.TestPythonFunctionDetection.test_python_no_doxygen(self)

tests/guard/test_guard_ts_parser.py:165

Checks

  • assert len(funcs) == 1
  • assert funcs[0].doxygen is None

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-019measuredtest_python_no_doxygen → parse_functions_ts → _collect_functions → _find_preceding_doxygen → parse_doxygen_tags
REQ-DDB-GUARD-020measuredtest_python_no_doxygen → parse_functions_ts
REQ-DDB-GUARD-021measuredtest_python_no_doxygen → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block
REQ-DDB-GUARD-024inferredtest_python_no_doxygen → parse_functions_ts → _collect_functions → _is_rust_test_item
REQ-DDB-GUARD-025measuredtest_python_no_doxygen → parse_functions_ts → _collect_functions → _js_returns_void
Source · 9 lines
    def test_python_no_doxygen(self):
        code = """\
def bare_func():
    pass
"""
        funcs = parse_functions_ts(code, "python", comment_start_pattern=r"^\s*##(?!#)")
        assert len(funcs) == 1
        assert funcs[0].doxygen is None

test_standalone_function_no_enclosing

test_guard_ts_parser.TestConstructorDestructorDetection.test_standalone_function_no_enclosing(self)

tests/guard/test_guard_ts_parser.py:294

Checks

  • assert funcs[0].enclosing_class is None
  • assert not funcs[0].is_constructor()

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-019measuredtest_standalone_function_no_enclosing → parse_functions_ts → _collect_functions → _find_preceding_doxygen → parse_doxygen_tags
REQ-DDB-GUARD-020measuredtest_standalone_function_no_enclosing → parse_functions_ts
REQ-DDB-GUARD-021inferredtest_standalone_function_no_enclosing → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block
REQ-DDB-GUARD-024inferredtest_standalone_function_no_enclosing → parse_functions_ts → _collect_functions → _is_rust_test_item
REQ-DDB-GUARD-025measuredtest_standalone_function_no_enclosing → parse_functions_ts → _collect_functions → _js_returns_void
Source · 5 lines
    def test_standalone_function_no_enclosing(self):
        code = "void standalone() {}"
        funcs = parse_functions_ts(code, "cpp")
        assert funcs[0].enclosing_class is None
        assert not funcs[0].is_constructor()

1 more lines, not shown

Activity · 4 steps
lines 295–295code = "void standalone() {}"lines 296–296funcs = parse_functions_ts(code, "cpp")lines 297–297assert funcs[0].enclosing_class is Nonelines 298–298assert not funcs[0].is_constructor()

test_static_function

test_guard_ts_parser.TestCFunctionDetection.test_static_function(self)

tests/guard/test_guard_ts_parser.py:120

Checks

  • assert len(funcs) == 1
  • assert funcs[0].name == "helper"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-019measuredtest_static_function → parse_functions_ts → _collect_functions → _find_preceding_doxygen → parse_doxygen_tags
REQ-DDB-GUARD-020measuredtest_static_function → parse_functions_ts
REQ-DDB-GUARD-021inferredtest_static_function → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block
REQ-DDB-GUARD-024inferredtest_static_function → parse_functions_ts → _collect_functions → _is_rust_test_item
REQ-DDB-GUARD-025measuredtest_static_function → parse_functions_ts → _collect_functions → _js_returns_void
Source · 15 lines
    def test_static_function(self):
        code = """\
/**
 * @brief Static helper.
 * @version 1.0
 */
static void helper(void) {
    return;
}
"""
        funcs = parse_functions_ts(code, "c")
        assert len(funcs) == 1
        assert funcs[0].name == "helper"

test_struct_constructor

test_guard_ts_parser.TestConstructorDestructorDetection.test_struct_constructor(self)

tests/guard/test_guard_ts_parser.py:269

Checks

  • assert ctor is not None
  • assert ctor.is_constructor()

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-019measuredtest_struct_constructor → parse_functions_ts → _collect_functions → _find_preceding_doxygen → parse_doxygen_tags
REQ-DDB-GUARD-020measuredtest_struct_constructor → parse_functions_ts
REQ-DDB-GUARD-021inferredtest_struct_constructor → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block
REQ-DDB-GUARD-024inferredtest_struct_constructor → parse_functions_ts → _collect_functions → _is_rust_test_item
REQ-DDB-GUARD-025measuredtest_struct_constructor → parse_functions_ts → _collect_functions → _js_returns_void
Source · 11 lines
    def test_struct_constructor(self):
        code = """\
struct Bar {
    Bar() {}
};
"""
        funcs = parse_functions_ts(code, "cpp")
        ctor = next((f for f in funcs if f.name == "Bar"), None)
        assert ctor is not None
        assert ctor.is_constructor()

test_wifi_fixture

test_guard_ts_parser.TestParityWithFixtures.test_wifi_fixture(self)

tests/guard/test_guard_ts_parser.py:207

Checks

  • assert "WiFi_ConnectAfterDelay" in names

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-019measuredtest_wifi_fixture → parse_functions_ts → _collect_functions → _find_preceding_doxygen → parse_doxygen_tags
REQ-DDB-GUARD-020measuredtest_wifi_fixture → parse_functions_ts
REQ-DDB-GUARD-021inferredtest_wifi_fixture → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block
REQ-DDB-GUARD-024inferredtest_wifi_fixture → parse_functions_ts → _collect_functions → _is_rust_test_item
REQ-DDB-GUARD-025measuredtest_wifi_fixture → parse_functions_ts → _collect_functions → _js_returns_void
Source · 8 lines
    def test_wifi_fixture(self):
        from guard_helpers import FIXTURES_DIR

        content = (FIXTURES_DIR / "sources" / "wifi_mgr" / "wifi.c").read_text()
        funcs = parse_functions_ts(content, "c")
        names = [f.name for f in funcs]
        assert "WiFi_ConnectAfterDelay" in names
Activity · 5 steps
lines 208–208from guard_helpers import FIXTURES_DIRlines 210–210content = (FIXTURES_DIR / "sources" / "wifi_mgr" / "wifi.c").read_text()lines 211–211funcs = parse_functions_ts(content, "c")lines 212–212names = [f.name for f in funcs]lines 213–213assert "WiFi_ConnectAfterDelay" in names