test: compare compiled modules with the Lua 5.4 interpreter
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.
This commit is contained in:
5 files changed
+250
No files matched your search
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/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)"
|
||||
Reference in new issue
Block a user