summaryrefslogtreecommitdiff
path: root/testes/heavy.lua
diff options
context:
space:
mode:
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 @@
1-- $Id: heavy.lua,v 1.4 2016/11/07 13:11:28 roberto Exp $
2-- See Copyright Notice in file all.lua
3
4print("creating a string too long")
5do
6 local st, msg = pcall(function ()
7 local a = "x"
8 while true do
9 a = a .. a.. a.. a.. a.. a.. a.. a.. a.. a
10 .. a .. a.. a.. a.. a.. a.. a.. a.. a.. a
11 .. a .. a.. a.. a.. a.. a.. a.. a.. a.. a
12 .. a .. a.. a.. a.. a.. a.. a.. a.. a.. a
13 .. a .. a.. a.. a.. a.. a.. a.. a.. a.. a
14 .. a .. a.. a.. a.. a.. a.. a.. a.. a.. a
15 .. a .. a.. a.. a.. a.. a.. a.. a.. a.. a
16 .. a .. a.. a.. a.. a.. a.. a.. a.. a.. a
17 .. a .. a.. a.. a.. a.. a.. a.. a.. a.. a
18 .. a .. a.. a.. a.. a.. a.. a.. a.. a.. a
19 print(string.format("string with %d bytes", #a))
20 end
21 end)
22 assert(not st and
23 (string.find(msg, "string length overflow") or
24 string.find(msg, "not enough memory")))
25end
26print('+')
27
28
29local function loadrep (x, what)
30 local p = 1<<20
31 local s = string.rep(x, p)
32 local count = 0
33 local function f()
34 count = count + p
35 if count % (0x80*p) == 0 then
36 io.stderr:write("(", string.format("0x%x", count), ")")
37 end
38 return s
39 end
40 local st, msg = load(f, "=big")
41 print(string.format("\ntotal: 0x%x %s", count, what))
42 return st, msg
43end
44
45
46print("loading chunk with too many lines")
47do
48 local st, msg = loadrep("\n", "lines")
49 assert(not st and string.find(msg, "too many lines"))
50end
51print('+')
52
53
54print("loading chunk with huge identifier")
55do
56 local st, msg = loadrep("a", "chars")
57 assert(not st and
58 (string.find(msg, "lexical element too long") or
59 string.find(msg, "not enough memory")))
60end
61print('+')
62
63
64print("loading chunk with too many instructions")
65do
66 local st, msg = loadrep("a = 10; ", "instructions")
67 print(st, msg)
68end
69print('+')
70
71
72print "OK"