TestCase gained a trailing `contract` field (WordContract) at some point
after all 20 test-module files' compound literals were written -- every
single TestCase/WordTestSuite initializer in the tree (sentinels, real
entries, and per-suite entries) omitted it, producing ~3010 warnings on
every build. CLAUDE.md's own documentation claimed this was isolated to
one file (vocabulary_words_test.c); a full audit found it systemic
across all 20 files.
Fixed mechanically: added the missing `{0}` trailing initializer
everywhere. Semantically a no-op -- C99 already zero-fills unlisted
trailing struct fields, so this only silences the diagnostic, changes
no behavior. Verified: all three architectures (amd64/aarch64/riscv64)
build clean, remaining warning count unchanged (30, matching the other
three known -Wno-error-exempted classes: unused-parameter, sign-compare,
plus mkcapsule.c's stringop-truncation which was never actually gated
by this policy -- it's a separate host tool with no -Werror at all).
.claude/CLAUDE.md corrected to describe the actual -Wno-error= exemption
list (four classes, not "build with -Wall -Werror" unconditionally) and
the real current warning inventory.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
133 lines
4.5 KiB
C
133 lines
4.5 KiB
C
/*
|
||
StarForth — Steady-State Virtual Machine Runtime
|
||
|
||
Copyright (c) 2023–2025 Robert A. James
|
||
All rights reserved.
|
||
|
||
This file is part of the StarForth project.
|
||
|
||
Licensed under the StarForth License, Version 1.0 (the "License");
|
||
you may not use this file except in compliance with the License.
|
||
|
||
You may obtain a copy of the License at:
|
||
https://github.com/star.4th@proton.me/StarForth/LICENSE.txt
|
||
|
||
This software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||
express or implied, including but not limited to the warranties of
|
||
merchantability, fitness for a particular purpose, and noninfringement.
|
||
|
||
See the License for the specific language governing permissions and
|
||
limitations under the License.
|
||
|
||
StarForth — Steady-State Virtual Machine Runtime
|
||
Copyright (c) 2023–2025 Robert A. James
|
||
All rights reserved.
|
||
|
||
This file is part of the StarForth project.
|
||
|
||
Licensed under the StarForth License, Version 1.0 (the "License");
|
||
you may not use this file except in compliance with the License.
|
||
|
||
You may obtain a copy of the License at:
|
||
https://github.com/star.4th@proton.me/StarForth/LICENSE.txt
|
||
|
||
This software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||
express or implied, including but not limited to the warranties of
|
||
merchantability, fitness for a particular purpose, and noninfringement.
|
||
|
||
See the License for the specific language governing permissions and
|
||
limitations under the License.
|
||
|
||
*/
|
||
|
||
#include "../include/test_runner.h"
|
||
#include "../include/test_common.h"
|
||
|
||
/**
|
||
* @brief Test suite definitions for system control words
|
||
* @details Contains test cases for each system word including normal operations
|
||
* and error conditions
|
||
*/
|
||
static WordTestSuite system_word_suites[] = {
|
||
{
|
||
"QUIT", {
|
||
{"basic", "QUIT", "Should reset stacks and state", TEST_NORMAL, 0, 0, {0}}, // Interactive
|
||
{"in_definition", ": BAD-WORD QUIT ;", "Should prevent compilation", TEST_ERROR_CASE, 1, 1, {0}},
|
||
{NULL, NULL, NULL, TEST_NORMAL, 0, 0, {0}}
|
||
},
|
||
2, {0}
|
||
},
|
||
|
||
{
|
||
"ABORT", {
|
||
{"basic", "ABORT", "Should clear stacks and return to QUIT", TEST_NORMAL, 0, 1, {0}},
|
||
{"with_data", "1 2 3 ABORT DEPTH . CR", "Should clear stack", TEST_NORMAL, 0, 1, {0}},
|
||
{
|
||
"in_definition_runtime", ": BAD-WORD ABORT ; 123 BAD-WORD DEPTH . CR",
|
||
"ABORT may appear in a definition; when executed it clears both stacks", TEST_NORMAL, 0, 1, {0}
|
||
},
|
||
{NULL, NULL, NULL, TEST_NORMAL, 0, 0, {0}}
|
||
},
|
||
3, {0}
|
||
},
|
||
|
||
{
|
||
"ABORT\"", {
|
||
{
|
||
"condition_true", "-1 ABORT\" Error\"", "Should abort with message (no error; stacks cleared to QUIT)",
|
||
TEST_NORMAL, 0, 1, {0}
|
||
},
|
||
{"condition_false", "0 ABORT\" Error\"", "Should not abort", TEST_NORMAL, 0, 1, {0}},
|
||
{"empty_stack", "ABORT\"", "Should cause stack underflow", TEST_ERROR_CASE, 1, 1, {0}},
|
||
{NULL, NULL, NULL, TEST_NORMAL, 0, 0, {0}}
|
||
},
|
||
3, {0}
|
||
},
|
||
|
||
{
|
||
"BYE", {
|
||
{"basic", "BYE", "Should exit cleanly", TEST_NORMAL, 0, 0, {0}}, // Can't really test
|
||
{NULL, NULL, NULL, TEST_NORMAL, 0, 0, {0}}
|
||
},
|
||
1, {0}
|
||
},
|
||
|
||
{
|
||
"COLD", {
|
||
{"basic", "COLD", "Should reset system", TEST_NORMAL, 0, 0, {0}}, // Dangerous to test
|
||
{NULL, NULL, NULL, TEST_NORMAL, 0, 0, {0}}
|
||
},
|
||
1, {0}
|
||
},
|
||
|
||
{
|
||
"WARM", {
|
||
{"basic", "WARM", "Should soft reset", TEST_NORMAL, 0, 0, {0}}, // Dangerous to test
|
||
{NULL, NULL, NULL, TEST_NORMAL, 0, 0, {0}}
|
||
},
|
||
1, {0}
|
||
},
|
||
|
||
/* End marker */
|
||
{NULL, {{NULL, NULL, NULL, TEST_NORMAL, 0, 0, {0}}}, 0, {0}}
|
||
};
|
||
|
||
/**
|
||
* @brief Executes all system word tests
|
||
* @details Runs test suites for FORTH system control operations including QUIT,
|
||
* ABORT, ABORT", BYE, COLD, and WARM. Some tests are marked as unimplemented
|
||
* due to their system-level effects
|
||
*
|
||
* @param vm Pointer to the Forth virtual machine instance
|
||
*/
|
||
void run_system_words_tests(VM *vm) {
|
||
log_message(LOG_INFO, "Running System Words Tests (Module 18)...");
|
||
log_message(LOG_WARN, "Some system tests marked as unimplemented due to system-level effects");
|
||
|
||
for (int i = 0; system_word_suites[i].word_name != NULL; i++) {
|
||
log_message(LOG_TEST, "▶ Testing module: %s", __FILE__);
|
||
run_test_suite(vm, &system_word_suites[i]);
|
||
}
|
||
|
||
print_module_summary("System Words", 0, 0, 0, 0);
|
||
} |