From 314745ed8438d1276c6c928d5f9d4be018dfadb6 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 28 Dec 2022 18:34:11 -0300 Subject: 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. --- testes/strings.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'testes/strings.lua') diff --git a/testes/strings.lua b/testes/strings.lua index 337c2937..b033c6ab 100644 --- a/testes/strings.lua +++ b/testes/strings.lua @@ -52,7 +52,7 @@ assert(("\000123456789"):sub(8) == "789") -- testing string.find assert(string.find("123456789", "345") == 3) -a,b = string.find("123456789", "345") +local a,b = string.find("123456789", "345") assert(string.sub("123456789", a, b) == "345") assert(string.find("1234567890123456789", "345", 3) == 3) assert(string.find("1234567890123456789", "345", 4) == 13) @@ -192,7 +192,7 @@ do -- tests for '%p' format end end -x = '"ílo"\n\\' +local x = '"ílo"\n\\' assert(string.format('%q%s', x, x) == '"\\"ílo\\"\\\n\\\\""ílo"\n\\') assert(string.format('%q', "\0") == [["\0"]]) assert(load(string.format('return %q', x))() == x) @@ -452,7 +452,7 @@ end do local f = string.gmatch("1 2 3 4 5", "%d+") assert(f() == "1") - co = coroutine.wrap(f) + local co = coroutine.wrap(f) assert(co() == "2") end -- cgit v1.2.3-55-g6feb