Make GRAPHIC select the text plane
Some checks failed
akbasic CI Build / cmake_build (push) Failing after 3m22s
akbasic CI Build / sanitizers (push) Failing after 4m43s
akbasic CI Build / coverage (push) Failing after 3m43s
akbasic CI Build / akgl_build (push) Failing after 4m48s
akbasic CI Build / mutation_test (push) Failing after 3m31s
Some checks failed
akbasic CI Build / cmake_build (push) Failing after 3m22s
akbasic CI Build / sanitizers (push) Failing after 4m43s
akbasic CI Build / coverage (push) Failing after 3m43s
akbasic CI Build / akgl_build (push) Failing after 4m48s
akbasic CI Build / mutation_test (push) Failing after 3m31s
Co-authored-by: Andrew Kesterson <andrew@aklabs.net>
This commit is contained in:
@@ -34,6 +34,22 @@ static akerr_ErrorContext AKERR_NOIGNORE *run_program(const char *source)
|
||||
SUCCEED_RETURN(errctx);
|
||||
}
|
||||
|
||||
/** @brief The values delivered through GRAPHIC's optional text-plane hook. */
|
||||
static int GRAPHIC_CALLS = 0;
|
||||
static int GRAPHIC_MODE = 0;
|
||||
static int GRAPHIC_SPLIT = 0;
|
||||
|
||||
static akerr_ErrorContext AKERR_NOIGNORE *record_graphic(akbasic_TextSink *self, int mode, int split)
|
||||
{
|
||||
PREPARE_ERROR(errctx);
|
||||
|
||||
(void)self;
|
||||
GRAPHIC_CALLS += 1;
|
||||
GRAPHIC_MODE = mode;
|
||||
GRAPHIC_SPLIT = split;
|
||||
SUCCEED_RETURN(errctx);
|
||||
}
|
||||
|
||||
/** @brief The white of palette index 2, which most of these draw with. */
|
||||
#define WHITE "#ffffff"
|
||||
/** @brief The red of palette index 3. */
|
||||
@@ -323,6 +339,21 @@ static void test_graphic(void)
|
||||
TEST_REQUIRE_STR(MOCK.log, "");
|
||||
harness_stop();
|
||||
|
||||
/* The third argument reaches a graphical text sink as the first text row. */
|
||||
TEST_REQUIRE_OK(harness_start(NULL));
|
||||
mock_devices_init();
|
||||
GRAPHIC_CALLS = 0;
|
||||
HARNESS_SINK.graphic = record_graphic;
|
||||
TEST_REQUIRE_OK(akbasic_runtime_set_devices(&HARNESS_RUNTIME, &MOCK_GRAPHICS,
|
||||
&MOCK_AUDIO, &MOCK_INPUT, NULL));
|
||||
TEST_REQUIRE_OK(akbasic_runtime_load(&HARNESS_RUNTIME, "10 GRAPHIC 2, 1, 19\n"));
|
||||
TEST_REQUIRE_OK(akbasic_runtime_start(&HARNESS_RUNTIME, AKBASIC_MODE_RUN));
|
||||
TEST_REQUIRE_OK(akbasic_runtime_run(&HARNESS_RUNTIME, 0));
|
||||
TEST_REQUIRE_INT(GRAPHIC_CALLS, 1);
|
||||
TEST_REQUIRE_INT(GRAPHIC_MODE, 2);
|
||||
TEST_REQUIRE_INT(GRAPHIC_SPLIT, 19);
|
||||
harness_stop();
|
||||
|
||||
/* GRAPHIC CLR drops the saved shapes and resets the whole state. */
|
||||
TEST_REQUIRE_OK(run_program("10 COLOR 1, 3\n20 GRAPHIC 5\n"));
|
||||
TEST_REQUIRE_STR(MOCK.log, "freeshapes\n");
|
||||
|
||||
Reference in New Issue
Block a user