diff options
Diffstat (limited to 'tests/unit/extraction.bats')
| -rw-r--r-- | tests/unit/extraction.bats | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/unit/extraction.bats b/tests/unit/extraction.bats index 21c6784..492d4e5 100644 --- a/tests/unit/extraction.bats +++ b/tests/unit/extraction.bats @@ -91,6 +91,46 @@ teardown() { chunk_contains "$CACHE" "Second chunk content" } +@test "C: opening-tag indent is stripped from body lines" { + local prog chunk line + prog="$(awk_prog_c "$CACHE")" + run_extraction "$FIXTURES/c/indented.c" "$prog" "$CACHE" + assert_equal "$(chunk_count "$CACHE")" "2" + chunk_contains "$CACHE" "@name my_enum/one" + chunk_contains "$CACHE" "My explanation of type_one" + # Body lines must not retain the 4-space indent from before /* + if grep -rlE '^ @name |^ My explanation' "$CACHE/chunks" >/dev/null 2>&1; then + echo "FAILED: opener indent was left on body lines" >&2 + grep -rn . "$CACHE/chunks" >&2 || true + return 1 + fi + # Relative extra indent inside the comment is preserved after stripping opener indent + chunk=$(grep -rl "relative indented line" "$CACHE/chunks") + line=$(grep -F "relative indented line" "$chunk") + # shellcheck disable=SC2016 + if [ "$line" != "$(printf '\trelative indented line')" ]; then + echo "FAILED: expected relative tab indent to remain after strip" >&2 + printf 'got: %q\n' "$line" >&2 + cat "$chunk" >&2 + return 1 + fi +} + +@test "C: tab indent before opening tag is stripped from body lines" { + local prog chunk line + prog="$(awk_prog_c "$CACHE")" + run_extraction "$FIXTURES/c/indented_tabs.c" "$prog" "$CACHE" + assert_equal "$(chunk_count "$CACHE")" "1" + chunk=$(grep -rl "Tab-indented body" "$CACHE/chunks") + line=$(grep -F "Tab-indented body" "$chunk") + if [ "$line" != "Tab-indented body" ]; then + echo "FAILED: expected tab opener indent stripped from body" >&2 + printf 'got: %q\n' "$line" >&2 + cat "$chunk" >&2 + return 1 + fi +} + # ── Lua (--[[ ... ]]) ────────────────────────────────────────────────────── @test "Lua: single doc comment produces one chunk" { |
