Avoid excessive name pollution in test files
Test files are more polite regarding the use of globals when locals would do, and when globals are necessary deleting them after use.
This commit is contained in:
@@ -125,7 +125,7 @@ do
|
||||
end
|
||||
|
||||
a:test()
|
||||
|
||||
_G.temp = nil
|
||||
end
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ do local f = function () end end
|
||||
|
||||
|
||||
print("functions with errors")
|
||||
prog = [[
|
||||
local prog = [[
|
||||
do
|
||||
a = 10;
|
||||
function foo(x,y)
|
||||
@@ -153,22 +153,25 @@ do
|
||||
end
|
||||
end
|
||||
end
|
||||
rawset(_G, "a", nil)
|
||||
_G.x = nil
|
||||
|
||||
foo = nil
|
||||
print('long strings')
|
||||
x = "01234567890123456789012345678901234567890123456789012345678901234567890123456789"
|
||||
assert(string.len(x)==80)
|
||||
s = ''
|
||||
k = math.min(300, (math.maxinteger // 80) // 2)
|
||||
for n = 1, k do s = s..x; j=tostring(n) end
|
||||
assert(string.len(s) == k*80)
|
||||
s = string.sub(s, 1, 10000)
|
||||
s, i = string.gsub(s, '(%d%d%d%d)', '')
|
||||
assert(i==10000 // 4)
|
||||
s = nil
|
||||
x = nil
|
||||
do
|
||||
foo = nil
|
||||
print('long strings')
|
||||
local x = "01234567890123456789012345678901234567890123456789012345678901234567890123456789"
|
||||
assert(string.len(x)==80)
|
||||
local s = ''
|
||||
local k = math.min(300, (math.maxinteger // 80) // 2)
|
||||
for n = 1, k do s = s..x; local j=tostring(n) end
|
||||
assert(string.len(s) == k*80)
|
||||
s = string.sub(s, 1, 10000)
|
||||
local s, i = string.gsub(s, '(%d%d%d%d)', '')
|
||||
assert(i==10000 // 4)
|
||||
|
||||
assert(_G["while"] == 234)
|
||||
assert(_G["while"] == 234)
|
||||
_G["while"] = nil
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
@@ -227,8 +230,8 @@ end
|
||||
|
||||
|
||||
print("clearing tables")
|
||||
lim = 15
|
||||
a = {}
|
||||
local lim = 15
|
||||
local a = {}
|
||||
-- fill a with `collectable' indices
|
||||
for i=1,lim do a[{}] = i end
|
||||
b = {}
|
||||
@@ -552,6 +555,7 @@ do
|
||||
for i=1,1000 do _ENV.a = {} end -- no collection during the loop
|
||||
until gcinfo() > 2 * x
|
||||
collectgarbage"restart"
|
||||
_ENV.a = nil
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user