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

requirementlinkedpath to the implementer
REQ-DDB-GUARD-006measuredtest_a_js_file_with_no_file_tag_at_all_still_fails → check_file_presence
REQ-DDB-GUARD-019measuredtest_a_js_file_with_no_file_tag_at_all_still_fails → check_file_presence → _check_file_block_tags → parse_doxygen_tags
REQ-DDB-GUARD-024inferredtest_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
lines 97–97content = "/**\n * @brief Does a thing.\n * @version 1.0\n */\nexport const x = 1;\n"lines 99–99violations = check_file_presence("thing.js", content, _REQUIRE_FILE)lines 101–101assert violations, "a JS block naming no file tag must still be reported"

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

requirementlinkedpath to the implementer
REQ-DDB-GUARD-006measuredtest_a_shebang_does_not_hide_the_file_block → check_file_presence
REQ-DDB-GUARD-019measuredtest_a_shebang_does_not_hide_the_file_block → check_file_presence → _check_file_block_tags → parse_doxygen_tags
REQ-DDB-GUARD-024inferredtest_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
lines 59–63content = ( "#!/usr/bin/env node\n" "/**\n * @fileoverview A tool.\n * @brief Does a thing.\n * @version 1.0\n */\n" "run();\n" )lines 65–65assert check_file_presence("tool.js", content, _REQUIRE_FILE) == []

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

requirementlinkedpath to the implementer
REQ-DDB-GUARD-006measuredtest_a_use_strict_prologue_does_not_hide_the_file_block → check_file_presence
REQ-DDB-GUARD-019measuredtest_a_use_strict_prologue_does_not_hide_the_file_block → check_file_presence → _check_file_block_tags → parse_doxygen_tags
REQ-DDB-GUARD-024inferredtest_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
lines 70–74content = ( "'use strict';\n" "/**\n * @module thing\n * @brief Does a thing.\n * @version 1.0\n */\n" "run();\n" )lines 76–76assert check_file_presence("thing.js", content, _REQUIRE_FILE) == []

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) == 1
  • assert "@fileoverview" in message, f"the remedy does not name a JSDoc tag: {message}"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-006measuredtest_an_undocumented_js_file_is_told_the_jsdoc_spelling → check_file_presence
REQ-DDB-GUARD-019inferredtest_an_undocumented_js_file_is_told_the_jsdoc_spelling → check_file_presence → _check_file_block_tags → parse_doxygen_tags
REQ-DDB-GUARD-024inferredtest_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
lines 85–85violations = check_file_presence("thing.js", "export const x = 1;\n", _REQUIRE_FILE)lines 87–87assert len(violations) == 1lines 88–88message = violations[0].messagelines 89–89assert "@fileoverview" in message, f"the remedy does not name a JSDoc tag: {message}"

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

requirementlinkedpath to the implementer
REQ-DDB-GUARD-006measuredtest_every_jsdoc_file_tag_the_index_accepts_is_accepted → check_file_presence
REQ-DDB-GUARD-019measuredtest_every_jsdoc_file_tag_the_index_accepts_is_accepted → check_file_presence → _check_file_block_tags → parse_doxygen_tags
REQ-DDB-GUARD-024inferredtest_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]}"
    )

Activity · 3 steps
lines 43–43content = f"/**\n * {tag}\n * @brief Does a thing.\n * @version 1.0\n */\nexport const x = 1;\n"lines 45–45violations = check_file_presence("thing.js", content, _REQUIRE_FILE)lines 47–50assert 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]}" )