#!/usr/bin/env bash # Compares the compiled module output with the reference Lua 5.4 interpreter. set -euo pipefail cd "$(dirname "$0")/.." BINARY="${1:-build/tests/luacpp_conformance}" if ! command -v lua5.4 >/dev/null 2>&1 && ! command -v lua >/dev/null 2>&1; then echo "no Lua interpreter found; skipping reference comparison" >&2 exit 0 fi LUA_BIN="$(command -v lua5.4 || command -v lua)" "${LUA_BIN}" tests/reference.lua tests/lua/core.lua > /tmp/luacpp_reference.txt "${BINARY}" > /tmp/luacpp_compiled.txt diff -u /tmp/luacpp_reference.txt /tmp/luacpp_compiled.txt echo "OK: compiled module matches the reference interpreter ($(wc -l < /tmp/luacpp_compiled.txt) checks)"