diff options
Diffstat (limited to 'testes/heavy.lua')
-rw-r--r-- | testes/heavy.lua | 72 |
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 | |||
4 | print("creating a string too long") | ||
5 | do | ||
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"))) | ||
25 | end | ||
26 | print('+') | ||
27 | |||
28 | |||
29 | local 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 | ||
43 | end | ||
44 | |||
45 | |||
46 | print("loading chunk with too many lines") | ||
47 | do | ||
48 | local st, msg = loadrep("\n", "lines") | ||
49 | assert(not st and string.find(msg, "too many lines")) | ||
50 | end | ||
51 | print('+') | ||
52 | |||
53 | |||
54 | print("loading chunk with huge identifier") | ||
55 | do | ||
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"))) | ||
60 | end | ||
61 | print('+') | ||
62 | |||
63 | |||
64 | print("loading chunk with too many instructions") | ||
65 | do | ||
66 | local st, msg = loadrep("a = 10; ", "instructions") | ||
67 | print(st, msg) | ||
68 | end | ||
69 | print('+') | ||
70 | |||
71 | |||
72 | print "OK" | ||