Files
akbasic/tests/known_reference_defects.c
Andrew Kesterson 1eb8f9ffaa Fix five defects the port uncovered in the reference parser and scanner
Chained subtraction and exponentiation fold left instead of abandoning the
rest of the line -- `1 - 2 - 3` gave -1 and dropped the `- 3`. A unary leaf's
operand moves to .left, so a negative literal is one argument again and a
second argument no longer overwrites it. An operator in a line's final column
survives. Hex literals reach the parser whole. A leading zero is padding, not
a radix.

Item 16 stays pinned: the fix works and costs an upstream golden case, which
is a decision rather than a defect.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-31 11:35:14 -04:00

47 lines
2.0 KiB
C

/**
* @file known_reference_defects.c
* @brief Asserts the *correct* contract for defects carried over from the reference.
*
* Registered in AKBASIC_KNOWN_FAILING_TESTS, so CTest expects it to fail. Every
* assertion here states what the interpreter *should* do, not what it currently
* does -- pinning current-but-wrong behaviour would turn the eventual fix into a
* test failure.
*
* When one of these is fixed, this test starts passing and CTest reports
* "unexpectedly passed". That is the cue to split the fixed assertion out into
* the corresponding suite in AKBASIC_TESTS and strike the item from TODO.md
* section 6.
*
* Five of the six this file was written with are gone that way. What is left is
* the one whose fix is not a coding question but a decision, and it is described
* where it is asserted.
*/
#include "harness.h"
int main(void)
{
TEST_REQUIRE_OK(harness_start(NULL));
/*
* 6.16 -- "Reserved word in variable name" never fires, because the lexeme
* still carries its type suffix when the verb table is searched, so PRINT$
* misses every table and becomes an ordinary string variable.
*
* Still here rather than fixed, and the reason is worth knowing before
* anybody "just fixes it": stripping the suffix before the lookup is four
* lines and it works, and it costs a golden case. The reference's own
* examples/strreverse.bas names a variable INPUT$ -- which a real C128 would
* refuse too, so the reference program is the wrong one. But the corpus is
* the acceptance contract and it lives in a submodule this repository may
* not edit, so the diagnostic and the corpus cannot both be right. TODO.md
* section 6 records the trade rather than making it silently.
*/
HARNESS_RUNTIME.hasError = false;
TEST_REQUIRE_OK(akbasic_scanner_scan(&HARNESS_RUNTIME, "PRINT$ = 1", NULL, 0));
TEST_REQUIRE(HARNESS_RUNTIME.hasError, "PRINT$ should be refused as a variable name");
harness_stop();
return akbasic_test_failures;
}