Report prescan errors on their source lines
Some checks failed
akbasic CI Build / coverage (push) Failing after 27s
akbasic CI Build / cmake_build (push) Failing after 33s
akbasic CI Build / akgl_build (push) Failing after 18s
akbasic CI Build / sanitizers (push) Failing after 1m7s
akbasic CI Build / mutation_test (push) Failing after 39s
Some checks failed
akbasic CI Build / coverage (push) Failing after 27s
akbasic CI Build / cmake_build (push) Failing after 33s
akbasic CI Build / akgl_build (push) Failing after 18s
akbasic CI Build / sanitizers (push) Failing after 1m7s
akbasic CI Build / mutation_test (push) Failing after 39s
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
* below.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "harness.h"
|
||||
|
||||
/**
|
||||
@@ -341,6 +343,28 @@ static akerr_ErrorContext AKERR_NOIGNORE *test_prescan_boundaries(void)
|
||||
SUCCEED_RETURN(errctx);
|
||||
}
|
||||
|
||||
/** @brief A full label table reports the line whose label could not be filed. */
|
||||
static void test_label_prescan_error_line(void)
|
||||
{
|
||||
char source[4096] = "";
|
||||
size_t used = 0;
|
||||
int i = 0;
|
||||
|
||||
for ( i = 1; i <= AKBASIC_MAX_LABELS + 1; i++ ) {
|
||||
used += (size_t)snprintf(source + used, sizeof(source) - used,
|
||||
"%d LABEL L%d\n", i, i);
|
||||
}
|
||||
(void)snprintf(source + used, sizeof(source) - used, "100 PRINT 1\n");
|
||||
|
||||
TEST_REQUIRE_OK(harness_start(NULL));
|
||||
TEST_REQUIRE_OK(akbasic_runtime_load(&HARNESS_RUNTIME, source));
|
||||
TEST_REQUIRE_OK(akbasic_runtime_start(&HARNESS_RUNTIME, AKBASIC_MODE_RUN));
|
||||
TEST_REQUIRE(strstr(HARNESS_OUTPUT, "? 65 : PARSE ERROR") != NULL,
|
||||
"a full label table should report its source line, got \"%s\"",
|
||||
HARNESS_OUTPUT);
|
||||
harness_stop();
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
PREPARE_ERROR(errctx);
|
||||
@@ -355,6 +379,7 @@ int main(void)
|
||||
CATCH(errctx, test_undefined_label_is_reported());
|
||||
CATCH(errctx, test_arm_refusals());
|
||||
CATCH(errctx, test_prescan_boundaries());
|
||||
test_label_prescan_error_line();
|
||||
} CLEANUP {
|
||||
} PROCESS(errctx) {
|
||||
} HANDLE_DEFAULT(errctx) {
|
||||
|
||||
Reference in New Issue
Block a user