@@ -27,15 +27,16 @@ local function serialize(value, seen)
2727
2828 local keys = {}
2929 for key in pairs (value ) do
30- keys [ # keys + 1 ] = key
30+ table.insert ( keys , key )
3131 end
32+
3233 table.sort (keys , function (left , right )
3334 return tostring (left ) < tostring (right )
3435 end )
3536
3637 local parts = {}
3738 for _ , key in ipairs (keys ) do
38- parts [ # parts + 1 ] = tostring (key ) .. " = " .. serialize (value [key ], seen )
39+ table.insert ( parts , tostring (key ) .. " = " .. serialize (value [key ], seen ) )
3940 end
4041
4142 seen [value ] = nil
@@ -104,7 +105,6 @@ function Suite.new()
104105 return setmetatable ({
105106 groups = {},
106107 results = {},
107- infiniteLoopLimit = INFINITE_LOOP_LIMIT ,
108108 }, Suite )
109109end
110110
@@ -143,14 +143,14 @@ function Suite:it(name, func)
143143 error (
144144 string.format (
145145 " TLCTest: Infinite loop detected after %d instructions" ,
146- self . infiniteLoopLimit
146+ INFINITE_LOOP_LIMIT
147147 ),
148148 0
149149 )
150150 end
151151
152152 if debug.sethook then
153- debug.sethook (terminateInfiniteLoop , " " , self . infiniteLoopLimit )
153+ debug.sethook (terminateInfiniteLoop , " " , INFINITE_LOOP_LIMIT )
154154 end
155155
156156 local ok , result = xpcall (func , function (err )
195195
196196function Suite :compileAndRun (code )
197197 if _VERSION == " Lua 5.1" then
198+ -- TODO: When running on Lua 5.1, we probably should run it both in the VM
199+ -- and through `loadstring`.
200+
198201 local func , err = loadstring (tlc .compile (code ))
199202 if not func then
200203 error (err , 0 )
0 commit comments