summaryrefslogtreecommitdiff
path: root/testes/heavy.lua
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-12-17 14:46:37 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-12-17 14:46:37 -0200
commit063d4e4543088e7a21965bda8ee5a0f952a9029e (patch)
tree6c3f2f8e98c26f071a94a32f9f2754396a66a9de /testes/heavy.lua
parente354c6355e7f48e087678ec49e340ca0696725b1 (diff)
downloadlua-github-5.3.5.tar.gz
Lua 5.3.5 ported to gitv5.3.5v5-3-5
This is the first commit for the branch Lua 5.3. All source files were copied from the official distribution of 5.3.5 in the Lua site. The test files are the same of 5.3.4. The manual came from the previous RCS repository, revision 1.167.1.2.
Diffstat (limited to 'testes/heavy.lua')
-rw-r--r--testes/heavy.lua72
1 files changed, 72 insertions, 0 deletions
diff --git a/testes/heavy.lua b/testes/heavy.lua
new file mode 100644
index 00000000..889d9f49
--- /dev/null
+++ b/testes/heavy.lua
@@ -0,0 +1,72 @@
+-- $Id: heavy.lua,v 1.4 2016/11/07 13:11:28 roberto Exp $
+-- See Copyright Notice in file all.lua
+
+print("creating a string too long")
+do
+ local st, msg = pcall(function ()
+ local a = "x"
+ while true do
+ a = a .. a.. a.. a.. a.. a.. a.. a.. a.. a
+ .. a .. a.. a.. a.. a.. a.. a.. a.. a.. a
+ .. a .. a.. a.. a.. a.. a.. a.. a.. a.. a
+ .. a .. a.. a.. a.. a.. a.. a.. a.. a.. a
+ .. a .. a.. a.. a.. a.. a.. a.. a.. a.. a
+ .. a .. a.. a.. a.. a.. a.. a.. a.. a.. a
+ .. a .. a.. a.. a.. a.. a.. a.. a.. a.. a
+ .. a .. a.. a.. a.. a.. a.. a.. a.. a.. a
+ .. a .. a.. a.. a.. a.. a.. a.. a.. a.. a
+ .. a .. a.. a.. a.. a.. a.. a.. a.. a.. a
+ print(string.format("string with %d bytes", #a))
+ end
+ end)
+ assert(not st and
+ (string.find(msg, "string length overflow") or
+ string.find(msg, "not enough memory")))
+end
+print('+')
+
+
+local function loadrep (x, what)
+ local p = 1<<20
+ local s = string.rep(x, p)
+ local count = 0
+ local function f()
+ count = count + p
+ if count % (0x80*p) == 0 then
+ io.stderr:write("(", string.format("0x%x", count), ")")
+ end
+ return s
+ end
+ local st, msg = load(f, "=big")
+ print(string.format("\ntotal: 0x%x %s", count, what))
+ return st, msg
+end
+
+
+print("loading chunk with too many lines")
+do
+ local st, msg = loadrep("\n", "lines")
+ assert(not st and string.find(msg, "too many lines"))
+end
+print('+')
+
+
+print("loading chunk with huge identifier")
+do
+ local st, msg = loadrep("a", "chars")
+ assert(not st and
+ (string.find(msg, "lexical element too long") or
+ string.find(msg, "not enough memory")))
+end
+print('+')
+
+
+print("loading chunk with too many instructions")
+do
+ local st, msg = loadrep("a = 10; ", "instructions")
+ print(st, msg)
+end
+print('+')
+
+
+print "OK"