aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/extraction.bats
diff options
context:
space:
mode:
authorAlexander M Pickering <alex@cogarr.net>2026-08-03 21:52:33 -0500
committerAlexander M Pickering <alex@cogarr.net>2026-08-03 21:52:33 -0500
commit6705bdc69e1682982832ebea24e791581c44d0d2 (patch)
tree48ec63b522c03f4e0b5abf6a2cd520dc96ba7eee /tests/unit/extraction.bats
parent21eb6acc2fdf0c43a2a1f6d4892cbd253909f82b (diff)
downloadtrbldoc-6705bdc69e1682982832ebea24e791581c44d0d2.tar.gz
trbldoc-6705bdc69e1682982832ebea24e791581c44d0d2.tar.bz2
trbldoc-6705bdc69e1682982832ebea24e791581c44d0d2.zip
Allow comments to have tabsHEADmaster
Currently, comments need to be left-aligned, even if they appear in an indented block. change the comment form to strip the same whitespace as the first line so that comments can be indented without embedding indents in the stdin.
Diffstat (limited to 'tests/unit/extraction.bats')
-rw-r--r--tests/unit/extraction.bats40
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" {