Files
libakstdlib/test.sh

5 lines
223 B
Bash
Raw Normal View History

Wrap the strings, streams and collections the wishlist asked for TODO.md section 3.1's high-priority list and section 3.6's data structures. This is the surface akbasic went without: it makes 10 calls into this library and 116 to raw libc, and 69 of those 116 are strlen, strcmp, strncpy and strstr. Three new translation units, because src/stdlib.c covering four times what it did would stop being readable: src/string.c lengths, bounded copy and concatenation, duplication, comparison including the case-insensitive forms, searching, the reentrant tokenisers, and a status message that knows this library's own statuses as well as errno's. src/stream.c positioning, flushing and buffering, character and line I/O, stream state, freopen/fdopen/tmpfile, formatted input, and the file operations. src/collections.c the list functions that were missing, a head/tail container so append is O(1), a binary search tree, FNV-1a, a fixed-capacity hash map and a growable string buffer. Two conventions run through all of it. The copying functions take the destination size even where the libc function they are named for does not, because strcpy(3) cannot be called safely without it, and truncation is an error that writes nothing rather than a plausible prefix -- this is the idiom akbasic writes out by hand at ten sites. The searching functions treat "not found" as a successful answer of NULL, because absent is an answer and raising on it would make every caller handle a non-error. The hash map is akbasic's src/symtab.c generalised: open-addressed with linear probing over a caller-supplied slot array, keys copied into fixed slots so the map owns them, tombstones on delete so a removal cannot cut a probe chain, and a refusal rather than a resize when full. Tests: 16 binaries, green under the normal and sanitizer builds. The scanf wrappers take the number of conversions the caller expects, since comparing scanf(3)'s return against that by hand is the check everyone eventually forgets. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-31 07:32:35 -04:00
cmake -S . -B build
cmake --build build
ctest --test-dir build --output-on-failure --output-junit "$(pwd)/ctest-junit.xml"
python3 scripts/mutation_test.py --target src/error.c --junit mutation-junit.xml --threshold 65