Files
akbasic/tests/language/numeric/val_refuses_garbage.bas

7 lines
293 B
QBasic
Raw Normal View History

Delete src/convert.c: libakstdlib 0.2.0 grew the contract it existed for That file wrapped strtoll and strtod because libakstdlib's aksl_ato* family could not report a conversion failure at all -- atoi("not a number") returned success with 0, turning four diagnosable errors into wrong answers. Its own note said what to do when that changed: "When it grows it, delete src/convert.c and switch the call sites over." 0.2.0 grew it, so it is gone. Six call sites go straight to the library now: both literal constructors in src/grammar.c, the line number in src/scanner.c, FunctionVAL in src/runtime_functions.c, INPUT in src/runtime_commands.c, and GSHAPE's handle in src/runtime_graphics.c. aksl_strtoll(str, NULL, base, &dest) rather than aksl_atoll wherever a base is involved, because the ato* forms are base 10 and grammar.c picks base 8 or 16 off the lexeme's prefix; the NULL endptr is what makes trailing junk an error rather than a stopping point. The raised status changed from AKBASIC_ERR_VALUE to AKERR_VALUE, and the message with it -- VAL("garbage") now says `no digits in "garbage"`. Section 1.8 makes message text part of the acceptance contract, so that was checked against the corpus before touching anything: no golden file contained a conversion message, which is also why section 1.9 had been asking for one. Two exist now, so the next change to that text has to move a golden file, and one of them pins the reference's octal-literal defect (section 6 item 10) while it is still deliberately reproduced. tests/convert.c became tests/numeric_contract.c rather than being deleted with the code. The assertions did not stop being worth making when the wrapper went away -- they became assertions about a contract this port depends on and no longer owns, and a regression in it would make four things quietly return zero. Repoints the CI mutation job, which was bounded to src/convert.c and src/symtab.c. src/symtab.c alone measures 74.1% against the gate of 65. src/audio_tables.c was measured as a replacement second file and scored 64.7%: that is a real gap rather than a reason to skip it, since almost every survivor is in akbasic_audio_state_init, where nothing asserts a freshly initialised audio state is actually zeroed -- the same gap this job's history records closing for symtab. Recorded in TODO.md so the file can earn its place back. One thing worth knowing before reading any score here, and now written down: the harness's ICR operator only rewrites the constants 0 and 1, so a lookup table of other values produces no mutants and a high score over one says nothing about whether its entries are right. tests/audio_verbs.c now asserts all 32 ADSR entries against the datasheet anyway, because a hand-edit typo is the real failure mode there -- but that could not and did not move the mutation number, and claiming otherwise would be the kind of thing this file exists to stop. 72/72 core, 73/73 with libakgl, 72/72 under ASan+UBSan, coverage 93.6% line and 97.8% function, clean under -Wall -Wextra, doxygen clean. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-31 10:28:04 -04:00
10 REM VAL on a non-numeric string must raise rather than quietly return 0.
20 REM There was no golden coverage of this until the converters moved onto
30 REM libakstdlib 0.2.0, which is when the message became that library's.
40 PRINT VAL("32")
50 PRINT VAL("garbage")
60 PRINT "UNREACHABLE"