diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-12-17 14:46:37 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-12-17 14:46:37 -0200 |
commit | 063d4e4543088e7a21965bda8ee5a0f952a9029e (patch) | |
tree | 6c3f2f8e98c26f071a94a32f9f2754396a66a9de /testes/heavy.lua | |
parent | e354c6355e7f48e087678ec49e340ca0696725b1 (diff) | |
download | lua-5.3.5.tar.gz lua-5.3.5.tar.bz2 lua-5.3.5.zip |
Lua 5.3.5 ported to gitv5.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.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" | ||