test_definitions_functions_and_classes

Tests › tests/test_jsts.py

passed Passed in the packaged run.

What this test is for

Why it exists

The test says nothing about why.

Given

  1. out = harvest_definitions(_tree("typescript", TS), TS)
  2. functions = {(f["cls"], f["name"]): f for f in out["functions"] if not f.get("decl")}
  3. classes = {c["name"]: c for c in out["classes"]}
→

When

  1. —
→

Then

  1. ✓ {(f["cls"], f["name"]) for f in out["functions"] if f.get("decl")} equals {("Shape", "area")}
  2. ✓ set(functions) equals { ("Formatter", "trim"), ("Formatter", "clean"), ("Formatter", "make"), ("", "normalize"), ("", "run"), }
  3. ✓ functions[("Formatter", "make")]["static"] equals 1
  4. ✓ functions[("", "normalize")]["ret"] equals "string"
  5. ✓ functions[("", "run")]["line"] equals 23
  6. ✓ functions[("", "run")]["end"] equals 26
  7. ✓ classes["Formatter"]["bases"] equals ["Base", "Shape"]
  8. ✓ classes["Shape"]["kind"] equals "interface"
  9. ✓ classes["Formatter"]["doc"] contains "Formats strings."

What it exercises

The parts of the system's flows this test ran, measured by per-test coverage: lit steps ran in this test, dimmed ones did not, and ▶ marks where the test called in. Each title opens the whole flow with these steps lit.

`main` (clew/guard/main.py) · 19 of 357 steps

… 127 earlier steps

program launcherprogram launcherprogram launcherprogram launcherprogram launcherclew/guard/ts_parser.pyclew/guard/ts_parser.pyclew/guard/ts_parser.pyclew/guard/ts_parser.pyclew/guard/ts_parser.pyother filesother filesother filesother filesother filesloop (line 647)loopopt (line 658)optopt (line 377)optalt (line 380)altopt (line 383)optopt (line 384)optopt (line 400)optopt (line 681)optopt (line 683)optmain128. _append_declaration → _extract_signature128_extract_signature129. _collect_functions → _resolve_function_node129_resolve_function_node130. _resolve_function_node → _unwrap_decorated130_unwrap_decorated▶ test enters131. _resolve_function_node → _bound_function131_bound_function132–134. _collect_functions → _extract_function_name132_extract_function_name +2 more135. _function_carrier → _bound_function135_bound_function136. _collect_functions → _find_preceding_doxygen136_find_preceding_doxygen137. _find_preceding_doxygen → _preceding_node137_preceding_node▶ test enters138–140. _find_preceding_doxygen → _collect_rust_doc138_collect_rust_doc +2 more141. _find_preceding_doxygen → _collect_c_comment141_collect_c_comment142. _find_preceding_doxygen → _find_python_docstring_block142_find_python_docstring_block143. _find_preceding_doxygen → parse_doxygen_tags143parse_doxygen_tags144. _find_preceding_doxygen → apply_autobrief144apply_autobrief145. _find_preceding_doxygen → _last_row145_last_row146–147. _collect_functions → _qualified_enclosing146_qualified_enclosing +1 more148. _extract_signature → _function_carrier148_function_carrier▶ test enters149–151. _collect_functions → _js_returns_void149_js_returns_void +2 more152. _produced_class → _function_carrier152_function_carrier▶ test enters153–154. _collect_functions → _collect_functions153_collect_functions +1 more

… 8 steps between

program launcherprogram launcherprogram launcherprogram launcherclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/main.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/config.pyclew/guard/checks.pyclew/guard/checks.pyclew/guard/checks.pyclew/guard/checks.pyother filesother filesother filesother filesopt (line 1198)optloop (line 143)loopopt (line 1171)optloop (line 181)loopmain163. _extract_file_block_text → _docstring_block163_docstring_block164. _check_file_block_tags → parse_doxygen_tags164parse_doxygen_tags165–170. parse_doxygen_tags → _mask_escaped_at165_mask_escaped_at +5 more171. _check_file_block_tags → apply_autobrief171apply_autobrief172–174. apply_autobrief → _mask_escaped_at172_mask_escaped_at +2 more175. validate_file → check_presence175check_presence176. check_presence → get_validate176get_validate

… 181 later steps

tests/test_jsts.py:67 · its file's page

What it checks (8)

  1. assert {(f["cls"], f["name"]) for f in out["functions"] if f.get("decl")} == {("Shape", "area")} observes _tree via out
  2. assert set(functions) == { ("Formatter", "trim"), ("Formatter", "clean"), ("Formatter", "make"), ("", "normalize"), ("", "run"), }, "anonymous callbacks are not definitions" not attributed
  3. assert functions[("Formatter", "make")]["static"] == 1 not attributed
  4. assert functions[("", "normalize")]["ret"] == "string" not attributed
  5. assert functions[("", "run")]["line"] == 23 and functions[("", "run")]["end"] == 26 not attributed
  6. assert classes["Formatter"]["bases"] == ["Base", "Shape"] not attributed
  7. assert classes["Shape"]["kind"] == "interface" not attributed
  8. assert "Formats strings." in classes["Formatter"]["doc"] not attributed

Where the product reaches it

No product flow reaches this code: no product entry point's flow calls any of the functions this test calls.

Call flow

test_definitions_functions_and_classes→_tree

What it reaches

Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.

Also reaches 5 requirements

Its run touches their code; that is reach, not proof.