@@ -3,6 +3,46 @@ local unindent = require 'spec.unindent'
33local is_luajit , ffi = pcall (require , ' ffi' )
44local has_rawlen = type (_G .rawlen ) == ' function'
55
6+ local function get_host_architecture ()
7+ local arch = nil
8+
9+ -- Try Windows environment variable
10+ arch = os.getenv (" PROCESSOR_ARCHITECTURE" )
11+ if arch and arch ~= " " then
12+ arch = arch :lower ()
13+ if arch == " amd64" or arch == " x86_64" then
14+ return " x86_64" -- Standardize 64-bit Intel/AMD
15+ elseif arch == " x86" then
16+ return " i686" -- Standardize 32-bit Intel/AMD
17+ end
18+ return arch -- Return other Windows arch if found (e.g., ARM64)
19+ end
20+
21+ -- Try Unix-like systems using 'uname -m'
22+ -- io.popen is available on most standard Lua installs on these systems
23+ local f = io.popen (" uname -m" , " r" )
24+ if f then
25+ arch = f :read (" *a" ):match (" %S+" ) -- Read output and trim whitespace
26+ f :close ()
27+
28+ if arch and arch ~= " " then
29+ arch = arch :lower ()
30+ -- Standardize common Unix architectures
31+ if arch :match (" ^(x86_64|amd64|aarch64|arm64|mips64)" ) then
32+ return arch
33+ elseif arch :match (" ^(i%d86|x86|i386|arm|mips)" ) then
34+ return arch
35+ end
36+ return arch -- Return raw uname output if not a common match
37+ end
38+ end
39+
40+ -- Fallback for systems where popen or env var fails
41+ return " unknown"
42+ end
43+
44+ local host_arch = get_host_architecture ()
45+
646describe ( ' inspect' , function ()
747
848 describe (' numbers' , function ()
@@ -423,7 +463,15 @@ describe( 'inspect', function()
423463 assert .equals (unindent (' {}' ), inspector (foo ))
424464 assert .equals (unindent (' {}' ), inspector (bar ))
425465 assert .equals (unindent (' {}' ), inspector (baz ))
426- assert .equals (unindent (' {}' ), inspector (spam ))
466+ if is_luajit and (get_host_architecture () == " aarch64" ) then
467+ assert .equals (unindent (' {}' ), inspector (spam ))
468+ else
469+ assert .equals (unindent ([[
470+ {
471+ <metatable> = {}
472+ }
473+ ]] ), inspector (spam ))
474+ end
427475 assert .equals (unindent ([[
428476 {
429477 <metatable> = {}
0 commit comments