Harden and fully cover the C++ translation

Add an exhaustive readable-instance sweep and a coverage gate requiring
100% line coverage of the summarised implementation. Delete branches that
are unreachable under `Readable`, centralise and assert the 32-bit offset
contract at the public entry points, and stop materialising `n` zero bytes
when deciding `keyAfterN n k < upper`.

Also add the extreme-offset regression test, harden the corpus parsers,
remove unused model helpers, document the literal-total / fast-readable
split, and refresh the validation and benchmark numbers.
This commit is contained in:
andrew committed 2026-11-17 18:46:24 -05:00
1 parent e32e42d933
commit 3bb5d062ff
15 files changed
+620 -196

No files matched your search

+46
View File
@@ -0,0 +1,46 @@
#!/usr/bin/env bash
# Build with Clang source-based coverage and require 100% line coverage of the
# summarised implementation (`src/fast.cpp`). `exhaustive_test` enumerates
# small readable instances deterministically and is sufficient on its own.
set -euo pipefail
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
build="${1:-$here/build-coverage}"
cxx="${CXX:-clang++-21}"
profdata="${LLVM_PROFDATA:-$(command -v llvm-profdata-21 || command -v llvm-profdata || true)}"
cov="${LLVM_COV:-$(command -v llvm-cov-21 || command -v llvm-cov || true)}"
if [[ -z "$profdata" || -z "$cov" ]]; then
echo "llvm-profdata and llvm-cov are required" >&2
exit 2
fi
cmake -S "$here" -B "$build" -G Ninja \
-DCMAKE_CXX_COMPILER="$cxx" \
-DCMAKE_BUILD_TYPE=Debug \
-DCR_BUILD_FUZZERS=OFF \
-DCR_BUILD_BENCH=OFF \
-DCMAKE_CXX_FLAGS="-fprofile-instr-generate -fcoverage-mapping" \
-DCMAKE_EXE_LINKER_FLAGS="-fprofile-instr-generate"
cmake --build "$build" --target exhaustive_test
profdir="$build/prof"
rm -rf "$profdir"
mkdir -p "$profdir"
cd "$here"
LLVM_PROFILE_FILE="$profdir/exhaustive-%p.profraw" "$build/exhaustive_test"
"$profdata" merge -sparse "$profdir"/*.profraw -o "$profdir/cov.profdata"
report() {
"$cov" report "$build/exhaustive_test" \
-instr-profile="$profdir/cov.profdata" src/fast.cpp
}
output="$(report)"
printf '%s\n' "$output"
line_cover="$(printf '%s\n' "$output" | awk '/fast\.cpp/ { print $10 }')"
if [[ "$line_cover" != "100.00%" ]]; then
echo "fast.cpp line coverage is $line_cover, expected 100.00%" >&2
exit 1
fi
echo "fast.cpp: 100.00% line coverage"