test_guard_jsdoc_file_level.py¶
tests/guard/test_guard_jsdoc_file_level.py
The gate and the index must agree on what documents a JavaScript file.
test_a_js_file_with_no_file_tag_at_all_still_fails
None test_guard_jsdoc_file_level.test_a_js_file_with_no_file_tag_at_all_still_fails()
A block with no file tag is still a violation.
tests/guard/test_guard_jsdoc_file_level.py:92
Checks
assert violations, "a JS block naming no file tag must still be reported"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-006 | measured | test_a_js_file_with_no_file_tag_at_all_still_fails → check_file_presence |
| REQ-DDB-GUARD-019 | measured | test_a_js_file_with_no_file_tag_at_all_still_fails → check_file_presence → _check_file_block_tags → parse_doxygen_tags |
| REQ-DDB-GUARD-024 | inferred | test_a_js_file_with_no_file_tag_at_all_still_fails → check_file_presence → _check_file_block_tags → apply_autobrief |
Source · 10 lines
def test_a_js_file_with_no_file_tag_at_all_still_fails() -> None:
"""THE CONTROL. Widening which tags count must not make the check vacuous.
@brief A block with no file tag is still a violation. @version 1
"""
content = "/**\n * @brief Does a thing.\n * @version 1.0\n */\nexport const x = 1;\n"
violations = check_file_presence("thing.js", content, _REQUIRE_FILE)
assert violations, "a JS block naming no file tag must still be reported"1 more lines, not shown
Activity · 3 steps
test_a_shebang_does_not_hide_the_file_block
None test_guard_jsdoc_file_level.test_a_shebang_does_not_hide_the_file_block()
A shebang is skipped when locating the file block.
tests/guard/test_guard_jsdoc_file_level.py:53
Checks
assert check_file_presence("tool.js", content, _REQUIRE_FILE) == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-006 | measured | test_a_shebang_does_not_hide_the_file_block → check_file_presence |
| REQ-DDB-GUARD-019 | measured | test_a_shebang_does_not_hide_the_file_block → check_file_presence → _check_file_block_tags → parse_doxygen_tags |
| REQ-DDB-GUARD-024 | inferred | test_a_shebang_does_not_hide_the_file_block → check_file_presence → _check_file_block_tags → apply_autobrief |
Source · 15 lines
def test_a_shebang_does_not_hide_the_file_block() -> None:
"""A Node executable starts `#!/usr/bin/env node`, which is not a doc comment, so the
search gave up on line one and reported a file with a perfectly good block as having none.
@brief A shebang is skipped when locating the file block. @version 1
"""
content = (
"#!/usr/bin/env node\n"
"/**\n * @fileoverview A tool.\n * @brief Does a thing.\n * @version 1.0\n */\n"
"run();\n"
)
assert check_file_presence("tool.js", content, _REQUIRE_FILE) == []
Activity · 2 steps
test_a_use_strict_prologue_does_not_hide_the_file_block
None test_guard_jsdoc_file_level.test_a_use_strict_prologue_does_not_hide_the_file_block()
A `'use strict'` directive is skipped when locating the file block.
tests/guard/test_guard_jsdoc_file_level.py:68
Checks
assert check_file_presence("thing.js", content, _REQUIRE_FILE) == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-006 | measured | test_a_use_strict_prologue_does_not_hide_the_file_block → check_file_presence |
| REQ-DDB-GUARD-019 | measured | test_a_use_strict_prologue_does_not_hide_the_file_block → check_file_presence → _check_file_block_tags → parse_doxygen_tags |
| REQ-DDB-GUARD-024 | inferred | test_a_use_strict_prologue_does_not_hide_the_file_block → check_file_presence → _check_file_block_tags → apply_autobrief |
Source · 11 lines
def test_a_use_strict_prologue_does_not_hide_the_file_block() -> None:
"""@brief A `'use strict'` directive is skipped when locating the file block. @version 1"""
content = (
"'use strict';\n"
"/**\n * @module thing\n * @brief Does a thing.\n * @version 1.0\n */\n"
"run();\n"
)
assert check_file_presence("thing.js", content, _REQUIRE_FILE) == []
Activity · 2 steps
test_an_undocumented_js_file_is_told_the_jsdoc_spelling
None test_guard_jsdoc_file_level.test_an_undocumented_js_file_is_told_the_jsdoc_spelling()
The skeleton suggestion names a JSDoc tag.
tests/guard/test_guard_jsdoc_file_level.py:79
Checks
assert len(violations) == 1assert "@fileoverview" in message, f"the remedy does not name a JSDoc tag: {message}"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-006 | measured | test_an_undocumented_js_file_is_told_the_jsdoc_spelling → check_file_presence |
| REQ-DDB-GUARD-019 | inferred | test_an_undocumented_js_file_is_told_the_jsdoc_spelling → check_file_presence → _check_file_block_tags → parse_doxygen_tags |
| REQ-DDB-GUARD-024 | inferred | test_an_undocumented_js_file_is_told_the_jsdoc_spelling → check_file_presence → _check_file_block_tags → apply_autobrief |
Source · 13 lines
def test_an_undocumented_js_file_is_told_the_jsdoc_spelling() -> None:
"""THE REMEDY HAS TO BE RUNNABLE. Telling a JavaScript author to write the C file block is
how an owner concludes the gate does not understand their language.
@brief The skeleton suggestion names a JSDoc tag. @version 1
"""
violations = check_file_presence("thing.js", "export const x = 1;\n", _REQUIRE_FILE)
assert len(violations) == 1
message = violations[0].message
assert "@fileoverview" in message, f"the remedy does not name a JSDoc tag: {message}"
Activity · 4 steps
test_every_jsdoc_file_tag_the_index_accepts_is_accepted
None test_guard_jsdoc_file_level.test_every_jsdoc_file_tag_the_index_accepts_is_accepted(str tag)
All four JSDoc file tags satisfy the gate.
tests/guard/test_guard_jsdoc_file_level.py:41
Checks
assert violations == [], (f"`{tag}` documents the file for the index but not for the gate, so a correctly " f"documented JSDoc file fails the gate: {[v.message for v in violations]}" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-006 | measured | test_every_jsdoc_file_tag_the_index_accepts_is_accepted → check_file_presence |
| REQ-DDB-GUARD-019 | measured | test_every_jsdoc_file_tag_the_index_accepts_is_accepted → check_file_presence → _check_file_block_tags → parse_doxygen_tags |
| REQ-DDB-GUARD-024 | inferred | test_every_jsdoc_file_tag_the_index_accepts_is_accepted → check_file_presence → _check_file_block_tags → apply_autobrief |
Source · 12 lines
def test_every_jsdoc_file_tag_the_index_accepts_is_accepted(tag: str) -> None:
"""@brief All four JSDoc file tags satisfy the gate. @version 1"""
content = f"/**\n * {tag}\n * @brief Does a thing.\n * @version 1.0\n */\nexport const x = 1;\n"
violations = check_file_presence("thing.js", content, _REQUIRE_FILE)
assert violations == [], (
f"`{tag}` documents the file for the index but not for the gate, so a correctly "
f"documented JSDoc file fails the gate: {[v.message for v in violations]}"
)