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/verybig.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 '')
-rw-r--r-- | testes/verybig.lua | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/testes/verybig.lua b/testes/verybig.lua new file mode 100644 index 00000000..1cfd10be --- /dev/null +++ b/testes/verybig.lua | |||
@@ -0,0 +1,152 @@ | |||
1 | -- $Id: verybig.lua,v 1.25 2016/11/07 13:11:28 roberto Exp $ | ||
2 | -- See Copyright Notice in file all.lua | ||
3 | |||
4 | print "testing RK" | ||
5 | |||
6 | -- testing opcodes with RK arguments larger than K limit | ||
7 | local function foo () | ||
8 | local dummy = { | ||
9 | -- fill first 256 entries in table of constants | ||
10 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, | ||
11 | 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, | ||
12 | 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, | ||
13 | 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, | ||
14 | 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, | ||
15 | 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, | ||
16 | 97, 98, 99, 100, 101, 102, 103, 104, | ||
17 | 105, 106, 107, 108, 109, 110, 111, 112, | ||
18 | 113, 114, 115, 116, 117, 118, 119, 120, | ||
19 | 121, 122, 123, 124, 125, 126, 127, 128, | ||
20 | 129, 130, 131, 132, 133, 134, 135, 136, | ||
21 | 137, 138, 139, 140, 141, 142, 143, 144, | ||
22 | 145, 146, 147, 148, 149, 150, 151, 152, | ||
23 | 153, 154, 155, 156, 157, 158, 159, 160, | ||
24 | 161, 162, 163, 164, 165, 166, 167, 168, | ||
25 | 169, 170, 171, 172, 173, 174, 175, 176, | ||
26 | 177, 178, 179, 180, 181, 182, 183, 184, | ||
27 | 185, 186, 187, 188, 189, 190, 191, 192, | ||
28 | 193, 194, 195, 196, 197, 198, 199, 200, | ||
29 | 201, 202, 203, 204, 205, 206, 207, 208, | ||
30 | 209, 210, 211, 212, 213, 214, 215, 216, | ||
31 | 217, 218, 219, 220, 221, 222, 223, 224, | ||
32 | 225, 226, 227, 228, 229, 230, 231, 232, | ||
33 | 233, 234, 235, 236, 237, 238, 239, 240, | ||
34 | 241, 242, 243, 244, 245, 246, 247, 248, | ||
35 | 249, 250, 251, 252, 253, 254, 255, 256, | ||
36 | } | ||
37 | assert(24.5 + 0.6 == 25.1) | ||
38 | local t = {foo = function (self, x) return x + self.x end, x = 10} | ||
39 | t.t = t | ||
40 | assert(t:foo(1.5) == 11.5) | ||
41 | assert(t.t:foo(0.5) == 10.5) -- bug in 5.2 alpha | ||
42 | assert(24.3 == 24.3) | ||
43 | assert((function () return t.x end)() == 10) | ||
44 | end | ||
45 | |||
46 | |||
47 | foo() | ||
48 | foo = nil | ||
49 | |||
50 | if _soft then return 10 end | ||
51 | |||
52 | print "testing large programs (>64k)" | ||
53 | |||
54 | -- template to create a very big test file | ||
55 | prog = [[$ | ||
56 | |||
57 | local a,b | ||
58 | |||
59 | b = {$1$ | ||
60 | b30009 = 65534, | ||
61 | b30010 = 65535, | ||
62 | b30011 = 65536, | ||
63 | b30012 = 65537, | ||
64 | b30013 = 16777214, | ||
65 | b30014 = 16777215, | ||
66 | b30015 = 16777216, | ||
67 | b30016 = 16777217, | ||
68 | b30017 = 0x7fffff, | ||
69 | b30018 = -0x7fffff, | ||
70 | b30019 = 0x1ffffff, | ||
71 | b30020 = -0x1ffffd, | ||
72 | b30021 = -65534, | ||
73 | b30022 = -65535, | ||
74 | b30023 = -65536, | ||
75 | b30024 = -0xffffff, | ||
76 | b30025 = 15012.5, | ||
77 | $2$ | ||
78 | }; | ||
79 | |||
80 | assert(b.a50008 == 25004 and b["a11"] == -5.5) | ||
81 | assert(b.a33007 == -16503.5 and b.a50009 == -25004.5) | ||
82 | assert(b["b"..30024] == -0xffffff) | ||
83 | |||
84 | function b:xxx (a,b) return a+b end | ||
85 | assert(b:xxx(10, 12) == 22) -- pushself with non-constant index | ||
86 | b.xxx = nil | ||
87 | |||
88 | s = 0; n=0 | ||
89 | for a,b in pairs(b) do s=s+b; n=n+1 end | ||
90 | -- with 32-bit floats, exact value of 's' depends on summation order | ||
91 | assert(81800000.0 < s and s < 81860000 and n == 70001) | ||
92 | |||
93 | a = nil; b = nil | ||
94 | print'+' | ||
95 | |||
96 | function f(x) b=x end | ||
97 | |||
98 | a = f{$3$} or 10 | ||
99 | |||
100 | assert(a==10) | ||
101 | assert(b[1] == "a10" and b[2] == 5 and b[#b-1] == "a50009") | ||
102 | |||
103 | |||
104 | function xxxx (x) return b[x] end | ||
105 | |||
106 | assert(xxxx(3) == "a11") | ||
107 | |||
108 | a = nil; b=nil | ||
109 | xxxx = nil | ||
110 | |||
111 | return 10 | ||
112 | |||
113 | ]] | ||
114 | |||
115 | -- functions to fill in the $n$ | ||
116 | |||
117 | local function sig (x) | ||
118 | return (x % 2 == 0) and '' or '-' | ||
119 | end | ||
120 | |||
121 | F = { | ||
122 | function () -- $1$ | ||
123 | for i=10,50009 do | ||
124 | io.write('a', i, ' = ', sig(i), 5+((i-10)/2), ',\n') | ||
125 | end | ||
126 | end, | ||
127 | |||
128 | function () -- $2$ | ||
129 | for i=30026,50009 do | ||
130 | io.write('b', i, ' = ', sig(i), 15013+((i-30026)/2), ',\n') | ||
131 | end | ||
132 | end, | ||
133 | |||
134 | function () -- $3$ | ||
135 | for i=10,50009 do | ||
136 | io.write('"a', i, '", ', sig(i), 5+((i-10)/2), ',\n') | ||
137 | end | ||
138 | end, | ||
139 | } | ||
140 | |||
141 | file = os.tmpname() | ||
142 | io.output(file) | ||
143 | for s in string.gmatch(prog, "$([^$]+)") do | ||
144 | local n = tonumber(s) | ||
145 | if not n then io.write(s) else F[n]() end | ||
146 | end | ||
147 | io.close() | ||
148 | result = dofile(file) | ||
149 | assert(os.remove(file)) | ||
150 | print'OK' | ||
151 | return result | ||
152 | |||