#!/usr/bin/env bash
# check-input.sh - Host-cc harness for the typed-character queue
# (jlInputGetChar / jlInputCharPush in src/core/input.c). Compiles the
# core input module with a mocked jlpInputPoll (tests/host/inputHost.c)
# and exercises FIFO order, the character filter, drop-newest overflow,
# reset, and the jlInputPoll refill path.
set -euo pipefail

repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
cc=${CC:-cc}
work=$(mktemp -d -t joeylib-input.XXXXXX)
trap 'rm -rf "$work"' EXIT

cd "$repo"
# The BLANK platform block registers JL_HAS_INPUT_POLL and
# JL_HAS_JOYSTICK_RESET (blank.c normally supplies them); inputHost.c
# provides the mocks here instead, so no extra -D flags are needed.
"$cc" -DJOEYLIB_PLATFORM_BLANK \
    -Iinclude -Iinclude/joey -Isrc/core -Wall \
    src/core/input.c tests/host/inputHost.c \
    -o "$work/inputHost"

"$work/inputHost"
