The generated code can only be trusted if it behaves like the reference implementation, so the same script runs both ways and the outputs are diffed.
18 lines
684 B
Bash
Executable File
18 lines
684 B
Bash
Executable File
#!/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)"
|