Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
lua/testes/all.lua at 7c519dfbd0c68b952f0849e01deaa3750e1f8153 · lua/lua · GitHub
Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Events
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
lua
lua
Repository navigation
Code
Actions
Security and quality
Insights
More
items
Files
Expand file tree
7c519dfbd0c68b952f0849e01deaa3750e1f8153
Breadcrumbs
lua
/
testes
/
all.lua
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
executable file
·
294 lines (240 loc) · 7.52 KB
7c519df
Breadcrumbs
lua
/
testes
/
all.lua
Copy path
Top
File metadata and controls
Code
Blame
executable file
·
294 lines (240 loc) · 7.52 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
#!
../lua
--
$Id: all.lua,v 1.100 2018/03/09 14:23:48 roberto Exp $
--
See Copyright Notice at the end of this file
local
version
=
"
Lua 5.4
"
if
_VERSION
~=
version
then
io.stderr
:
write
(
"
\n
This test suite is for
"
,
version
,
"
, not for
"
,
_VERSION
,
"
\n
Exiting tests
\n
"
)
return
end
_G
.
ARG
=
arg
--
save arg for other tests
--
next variables control the execution of some tests
--
true means no test (so an undefined variable does not skip a test)
--
defaults are for Linux; test everything.
--
Make true to avoid long or memory consuming tests
_soft
=
rawget
(
_G
,
"
_soft
"
)
or
false
--
Make true to avoid non-portable tests
_port
=
rawget
(
_G
,
"
_port
"
)
or
false
--
Make true to avoid messages about tests not performed
_nomsg
=
rawget
(
_G
,
"
_nomsg
"
)
or
false
local
usertests
=
rawget
(
_G
,
"
_U
"
)
if
usertests
then
--
tests for sissies ;) Avoid problems
_soft
=
true
_port
=
true
_nomsg
=
true
end
--
tests should require debug when needed
debug
=
nil
require
"
bwcoercion
"
if
usertests
then
T
=
nil
--
no "internal" tests for user tests
else
T
=
rawget
(
_G
,
"
T
"
)
--
avoid problems with 'strict' module
end
math.randomseed
(
0
)
--[=[
example of a long [comment],
[[spanning several [lines]]]
]=]
print
(
"
current path:
\n
****
"
..
package.path
..
"
****
\n
"
)
local
initclock
=
os.clock
()
local
lastclock
=
initclock
local
walltime
=
os.time
()
local
collectgarbage
=
collectgarbage
do
--
(
--
track messages for tests not performed
local
msgs
=
{}
function
Message
(
m
)
if
not
_nomsg
then
print
(
m
)
msgs
[
#
msgs
+
1
]
=
string.sub
(
m
,
3
,
-
3
)
end
end
assert
(
os.setlocale
"
C
"
)
local
T
,
print
,
format
,
write
,
assert
,
type
,
unpack
,
floor
=
T
,
print
,
string.format
,
io.write
,
assert
,
type
,
table.unpack
,
math.floor
--
use K for 1000 and M for 1000000 (not 2^10 -- 2^20)
local
function
F
(
m
)
local
function
round
(
m
)
m
=
m
+
0.04999
return
format
(
"
%.1f
"
,
m
)
--
keep one decimal digit
end
if
m
<
1000
then
return
m
else
m
=
m
/
1000
if
m
<
1000
then
return
round
(
m
)
..
"
K
"
else
return
round
(
m
/
1000
)
..
"
M
"
end
end
end
local
showmem
if
not
T
then
local
max
=
0
showmem
=
function
()
local
m
=
collectgarbage
(
"
count
"
)
*
1024
max
=
(
m
>
max
)
and
m
or
max
print
(
format
(
"
---- total memory: %s, max memory: %s ----
\n
"
,
F
(
m
),
F
(
max
)))
end
else
showmem
=
function
()
T
.
checkmemory
()
local
total
,
numblocks
,
maxmem
=
T
.
totalmem
()
local
count
=
collectgarbage
(
"
count
"
)
print
(
format
(
"
\n
---- total memory: %s (%.0fK), max use: %s, blocks: %d
\n
"
,
F
(
total
),
count
,
F
(
maxmem
),
numblocks
))
print
(
format
(
"
\t
(strings: %d, tables: %d, functions: %d,
"
..
"
\n\t
udata: %d, threads: %d)
"
,
T
.
totalmem
"
string
"
,
T
.
totalmem
"
table
"
,
T
.
totalmem
"
function
"
,
T
.
totalmem
"
userdata
"
,
T
.
totalmem
"
thread
"
))
end
end
--
--
redefine dofile to run files through dump/undump
--
local
function
report
(
n
)
print
(
"
\n
***** FILE '
"
..
n
..
"
'*****
"
)
end
local
olddofile
=
dofile
local
dofile
=
function
(
n
,
strip
)
showmem
()
local
c
=
os.clock
()
print
(
string.format
(
"
time: %g (+%g)
"
,
c
-
initclock
,
c
-
lastclock
))
lastclock
=
c
report
(
n
)
local
f
=
assert
(
loadfile
(
n
))
local
b
=
string.dump
(
f
,
strip
)
f
=
assert
(
load
(
b
))
return
f
()
end
dofile
(
'
main.lua
'
)
do
local
next
,
setmetatable
,
stderr
=
next
,
setmetatable
,
io.stderr
--
track collections
local
mt
=
{}
--
each time a table is collected, remark it for finalization
--
on next cycle
mt
.
__gc
=
function
(
o
)
stderr
:
write
'
.
'
--
mark progress
local
n
=
setmetatable
(
o
,
mt
)
--
remark it
end
local
n
=
setmetatable
({},
mt
)
--
create object
end
report
"
gc.lua
"
local
f
=
assert
(
loadfile
(
'
gc.lua
'
))
f
()
dofile
(
'
db.lua
'
)
assert
(
dofile
(
'
calls.lua
'
)
==
deep
and
deep
)
olddofile
(
'
strings.lua
'
)
olddofile
(
'
literals.lua
'
)
dofile
(
'
tpack.lua
'
)
assert
(
dofile
(
'
attrib.lua
'
)
==
27
)
assert
(
dofile
(
'
locals.lua
'
)
==
5
)
dofile
(
'
constructs.lua
'
)
dofile
(
'
code.lua
'
,
true
)
if
not
_G
.
_soft
then
report
(
'
big.lua
'
)
local
f
=
coroutine.wrap
(
assert
(
loadfile
(
'
big.lua
'
)))
assert
(
f
()
==
'
b
'
)
assert
(
f
()
==
'
a
'
)
end
dofile
(
'
nextvar.lua
'
)
dofile
(
'
pm.lua
'
)
dofile
(
'
utf8.lua
'
)
dofile
(
'
api.lua
'
)
assert
(
dofile
(
'
events.lua
'
)
==
12
)
dofile
(
'
vararg.lua
'
)
dofile
(
'
closure.lua
'
)
dofile
(
'
coroutine.lua
'
)
dofile
(
'
goto.lua
'
,
true
)
dofile
(
'
errors.lua
'
)
dofile
(
'
math.lua
'
)
dofile
(
'
sort.lua
'
,
true
)
dofile
(
'
bitwise.lua
'
)
assert
(
dofile
(
'
verybig.lua
'
,
true
)
==
10
);
collectgarbage
()
dofile
(
'
files.lua
'
)
if
#
msgs
>
0
then
print
(
"
\n
tests not performed:
"
)
for
i
=
1
,
#
msgs
do
print
(
msgs
[
i
])
end
print
()
end
--
no test module should define 'debug'
assert
(
debug
==
nil
)
local
debug
=
require
"
debug
"
print
(
string.format
(
"
%d-bit integers, %d-bit floats
"
,
string.packsize
(
"
j
"
)
*
8
,
string.packsize
(
"
n
"
)
*
8
))
debug.sethook
(
function
(
a
)
assert
(
type
(
a
)
==
'
string
'
)
end
,
"
cr
"
)
--
to survive outside block
_G
.
showmem
=
showmem
end
--
)
local
_G
,
showmem
,
print
,
format
,
clock
,
time
,
difftime
,
assert
,
open
=
_G
,
showmem
,
print
,
string.format
,
os.clock
,
os.time
,
os.difftime
,
assert
,
io.open
--
file with time of last performed test
local
fname
=
T
and
"
time-debug.txt
"
or
"
time.txt
"
local
lasttime
if
not
usertests
then
--
open file with time of last performed test
local
f
=
io.open
(
fname
)
if
f
then
lasttime
=
assert
(
tonumber
(
f
:
read
'
a
'
))
f
:
close
();
else
--
no such file; assume it is recording time for first time
lasttime
=
nil
end
end
--
erase (almost) all globals
print
(
'
cleaning all!!!!
'
)
for
n
in
pairs
(
_G
)
do
if
not
({
___Glob
=
1
,
tostring
=
1
})[
n
]
then
_G
[
n
]
=
undef
end
end
collectgarbage
()
collectgarbage
()
collectgarbage
()
collectgarbage
()
collectgarbage
()
collectgarbage
();
showmem
()
local
clocktime
=
clock
()
-
initclock
walltime
=
difftime
(
time
(),
walltime
)
print
(
format
(
"
\n\n
total time: %.2fs (wall time: %gs)
\n
"
,
clocktime
,
walltime
))
if
not
usertests
then
lasttime
=
lasttime
or
clocktime
--
if no last time, ignore difference
--
check whether current test time differs more than 5% from last time
local
diff
=
(
clocktime
-
lasttime
)
/
lasttime
local
tolerance
=
0.05
--
5%
if
(
diff
>=
tolerance
or
diff
<=
-
tolerance
)
then
print
(
format
(
"
WARNING: time difference from previous test: %+.1f%%
"
,
diff
*
100
))
end
assert
(
open
(
fname
,
"
w
"
)):
write
(
clocktime
):
close
()
end
print
(
"
final OK !!!
"
)
--[[
*****************************************************************************
* Copyright (C) 1994-2016 Lua.org, PUC-Rio.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*****************************************************************************
]]
You can’t perform that action at this time.