aboutsummaryrefslogtreecommitdiff
path: root/testes/code.lua
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2022-12-28 18:34:11 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2022-12-28 18:34:11 -0300
commit314745ed8438d1276c6c928d5f9d4be018dfadb6 (patch)
tree594b7e873f2c29113d95c75147ab10865cdd772c /testes/code.lua
parent0825cf237d9d3505155f8b40bcf83ea1b135e8da (diff)
downloadlua-314745ed8438d1276c6c928d5f9d4be018dfadb6.tar.gz
lua-314745ed8438d1276c6c928d5f9d4be018dfadb6.tar.bz2
lua-314745ed8438d1276c6c928d5f9d4be018dfadb6.zip
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.
Diffstat (limited to 'testes/code.lua')
-rw-r--r--testes/code.lua6
1 files changed, 3 insertions, 3 deletions
diff --git a/testes/code.lua b/testes/code.lua
index 543743fc..bd4b10d0 100644
--- a/testes/code.lua
+++ b/testes/code.lua
@@ -86,7 +86,7 @@ checkKlist(foo, {1, 1.0, 2, 2.0, 0, 0.0})
86-- testing opcodes 86-- testing opcodes
87 87
88-- check that 'f' opcodes match '...' 88-- check that 'f' opcodes match '...'
89function check (f, ...) 89local function check (f, ...)
90 local arg = {...} 90 local arg = {...}
91 local c = T.listcode(f) 91 local c = T.listcode(f)
92 for i=1, #arg do 92 for i=1, #arg do
@@ -99,7 +99,7 @@ end
99 99
100 100
101-- check that 'f' opcodes match '...' and that 'f(p) == r'. 101-- check that 'f' opcodes match '...' and that 'f(p) == r'.
102function checkR (f, p, r, ...) 102local function checkR (f, p, r, ...)
103 local r1 = f(p) 103 local r1 = f(p)
104 assert(r == r1 and math.type(r) == math.type(r1)) 104 assert(r == r1 and math.type(r) == math.type(r1))
105 check(f, ...) 105 check(f, ...)
@@ -107,7 +107,7 @@ end
107 107
108 108
109-- check that 'a' and 'b' has the same opcodes 109-- check that 'a' and 'b' has the same opcodes
110function checkequal (a, b) 110local function checkequal (a, b)
111 a = T.listcode(a) 111 a = T.listcode(a)
112 b = T.listcode(b) 112 b = T.listcode(b)
113 assert(#a == #b) 113 assert(#a == #b)