diff options
Diffstat (limited to '')
8 files changed, 0 insertions, 1257 deletions
diff --git a/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/bench_llex.lua b/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/bench_llex.lua deleted file mode 100644 index b904470..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/bench_llex.lua +++ /dev/null | |||
@@ -1,99 +0,0 @@ | |||
1 | --[[-------------------------------------------------------------------- | ||
2 | |||
3 | bench_llex.lua | ||
4 | Benchmark test for llex.lua | ||
5 | This file is part of Yueliang. | ||
6 | |||
7 | Copyright (c) 2006 Kein-Hong Man <khman@users.sf.net> | ||
8 | The COPYRIGHT file describes the conditions | ||
9 | under which this software may be distributed. | ||
10 | |||
11 | See the ChangeLog for more information. | ||
12 | |||
13 | ----------------------------------------------------------------------]] | ||
14 | |||
15 | dofile("../lzio.lua") | ||
16 | dofile("../llex.lua") | ||
17 | luaX:init() | ||
18 | |||
19 | ------------------------------------------------------------------------ | ||
20 | -- load in a standard set of sample files | ||
21 | -- * file set is 5.0.3 front end set sans luac.lua | ||
22 | ------------------------------------------------------------------------ | ||
23 | |||
24 | local fileset, totalsize = {}, 0 | ||
25 | for fn in string.gmatch([[ | ||
26 | ../../orig-5.0.3/lcode.lua | ||
27 | ../../orig-5.0.3/ldump.lua | ||
28 | ../../orig-5.0.3/llex.lua | ||
29 | ../../orig-5.0.3/lopcodes.lua | ||
30 | ../../orig-5.0.3/lparser.lua | ||
31 | ../../orig-5.0.3/lzio.lua | ||
32 | ]], "%S+") do | ||
33 | fileset[#fileset+1] = fn | ||
34 | end | ||
35 | |||
36 | for i = 1, #fileset do | ||
37 | local fn = fileset[i] | ||
38 | local inf = io.open(fn, "rb") | ||
39 | if not inf then | ||
40 | error("failed to open "..fn.." for reading") | ||
41 | end | ||
42 | local data = inf:read("*a") | ||
43 | local data_sz = #data | ||
44 | inf:close() | ||
45 | if not data or data_sz == 0 then | ||
46 | error("failed to read data from "..fn.." or file is zero-length") | ||
47 | end | ||
48 | totalsize = totalsize + data_sz | ||
49 | fileset[i] = data | ||
50 | end | ||
51 | |||
52 | ------------------------------------------------------------------------ | ||
53 | -- benchmark tester | ||
54 | ------------------------------------------------------------------------ | ||
55 | |||
56 | local DURATION = 5 -- how long the benchmark should run | ||
57 | |||
58 | local L = {} -- LuaState | ||
59 | local LS = {} -- LexState | ||
60 | |||
61 | local time = os.time | ||
62 | local lexedsize = 0 | ||
63 | local tnow, elapsed = time(), 0 | ||
64 | |||
65 | while time() == tnow do end -- wait for second to click over | ||
66 | tnow = time() | ||
67 | |||
68 | while true do | ||
69 | for i = 1, #fileset do | ||
70 | ------------------------------------------------------------ | ||
71 | local chunk = fileset[i] | ||
72 | local z = luaZ:init(luaZ:make_getS(chunk), nil) | ||
73 | luaX:setinput(L, LS, z, "=string") | ||
74 | while true do | ||
75 | LS.t.token = luaX:llex(LS, LS.t) | ||
76 | local tok, seminfo = LS.t.token, LS.t.seminfo | ||
77 | if tok == "TK_EOS" then break end | ||
78 | end | ||
79 | ------------------------------------------------------------ | ||
80 | lexedsize = lexedsize + #chunk | ||
81 | if time() > tnow then | ||
82 | tnow = time() | ||
83 | elapsed = elapsed + 1 | ||
84 | if elapsed >= DURATION then | ||
85 | -- report performance of lexer | ||
86 | lexedsize = lexedsize / 1024 | ||
87 | local speed = lexedsize / DURATION | ||
88 | print("Lexer performance:") | ||
89 | print("Size of data lexed (KB): "..string.format("%.1f", lexedsize)) | ||
90 | print("Speed of lexer (KB/s): "..string.format("%.1f", speed)) | ||
91 | -- repeat until user breaks program | ||
92 | elapsed = 0 | ||
93 | end | ||
94 | end | ||
95 | ------------------------------------------------------------ | ||
96 | end--for | ||
97 | end--while | ||
98 | |||
99 | -- end of script | ||
diff --git a/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/sample.lua b/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/sample.lua deleted file mode 100644 index dc6eaee..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/sample.lua +++ /dev/null | |||
@@ -1,3 +0,0 @@ | |||
1 | local a = 47 | ||
2 | local b = "hello, world!" | ||
3 | print(a, b) | ||
diff --git a/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/test_ldump.lua b/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/test_ldump.lua deleted file mode 100644 index 2d113dd..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/test_ldump.lua +++ /dev/null | |||
@@ -1,99 +0,0 @@ | |||
1 | --[[-------------------------------------------------------------------- | ||
2 | |||
3 | test_ldump.lua | ||
4 | Test for ldump.lua | ||
5 | This file is part of Yueliang. | ||
6 | |||
7 | Copyright (c) 2006 Kein-Hong Man <khman@users.sf.net> | ||
8 | The COPYRIGHT file describes the conditions | ||
9 | under which this software may be distributed. | ||
10 | |||
11 | See the ChangeLog for more information. | ||
12 | |||
13 | ----------------------------------------------------------------------]] | ||
14 | |||
15 | ------------------------------------------------------------------------ | ||
16 | -- test dump chunkwriter style | ||
17 | ------------------------------------------------------------------------ | ||
18 | |||
19 | dofile("../lopcodes.lua") | ||
20 | dofile("../ldump.lua") | ||
21 | |||
22 | -- Original typedef: | ||
23 | --int (*lua_Chunkwriter) (lua_State *L, const void* p, size_t sz, void* ud); | ||
24 | |||
25 | local MyWriter, MyBuff = luaU:make_setS() | ||
26 | if not MyWriter then | ||
27 | error("failed to initialize using make_setS") | ||
28 | end | ||
29 | MyWriter("hello, ", MyBuff) | ||
30 | MyWriter("world!", MyBuff) | ||
31 | print(MyBuff.data) | ||
32 | |||
33 | local MyWriter, MyBuff = luaU:make_setF("try.txt") | ||
34 | if not MyWriter then | ||
35 | error("failed to initialize using make_setF") | ||
36 | end | ||
37 | MyWriter("hello, ", MyBuff) | ||
38 | MyWriter("world!", MyBuff) | ||
39 | MyWriter(nil, MyBuff) | ||
40 | |||
41 | ------------------------------------------------------------------------ | ||
42 | -- test output of a function prototype | ||
43 | -- * data can be copied from a ChunkSpy listing output | ||
44 | ------------------------------------------------------------------------ | ||
45 | -- local a = 47 | ||
46 | -- local b = "hello, world!" | ||
47 | -- print(a, b) | ||
48 | ------------------------------------------------------------------------ | ||
49 | |||
50 | local F = {} | ||
51 | F.source = "sample.lua" | ||
52 | F.lineDefined = 0 | ||
53 | F.lastlinedefined = 0 | ||
54 | F.nups = 0 | ||
55 | F.numparams = 0 | ||
56 | F.is_vararg = 2 | ||
57 | F.maxstacksize = 5 | ||
58 | F.sizecode = 7 | ||
59 | F.code = {} | ||
60 | F.code[0] = { OP = 1, A = 0, Bx = 0 } | ||
61 | F.code[1] = { OP = 1, A = 1, Bx = 1 } | ||
62 | F.code[2] = { OP = 5, A = 2, Bx = 2 } | ||
63 | F.code[3] = { OP = 0, A = 3, B = 0, C = 0 } | ||
64 | F.code[4] = { OP = 0, A = 4, B = 1, C = 0 } | ||
65 | F.code[5] = { OP = 28, A = 2, B = 3, C = 1 } | ||
66 | F.code[6] = { OP = 30, A = 0, B = 1, C = 0 } | ||
67 | F.sizek = 3 | ||
68 | F.k = {} | ||
69 | F.k[0] = { value = 47 } | ||
70 | F.k[1] = { value = "hello, world!" } | ||
71 | F.k[2] = { value = "print" } | ||
72 | F.sizep = 0 | ||
73 | F.p = {} | ||
74 | F.sizelineinfo = 7 | ||
75 | F.lineinfo = {} | ||
76 | F.lineinfo[0] = 1 | ||
77 | F.lineinfo[1] = 2 | ||
78 | F.lineinfo[2] = 3 | ||
79 | F.lineinfo[3] = 3 | ||
80 | F.lineinfo[4] = 3 | ||
81 | F.lineinfo[5] = 3 | ||
82 | F.lineinfo[6] = 3 | ||
83 | F.sizelocvars = 2 | ||
84 | F.locvars = {} | ||
85 | F.locvars[0] = { varname = "a", startpc = 1, endpc = 6 } | ||
86 | F.locvars[1] = { varname = "b", startpc = 2, endpc = 6 } | ||
87 | F.sizeupvalues = 0 | ||
88 | F.upvalues = {} | ||
89 | |||
90 | local L = {} | ||
91 | --[[ | ||
92 | local Writer, Buff = luaU:make_setS() | ||
93 | luaU:dump(L, F, Writer, Buff) | ||
94 | for i = 1, string.len(Buff.data) do | ||
95 | io.stdout:write(string.byte(string.sub(Buff.data, i, i)).." ") | ||
96 | end | ||
97 | --]] | ||
98 | local Writer, Buff = luaU:make_setF("try.out") | ||
99 | luaU:dump(L, F, Writer, Buff) | ||
diff --git a/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/test_llex.lua b/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/test_llex.lua deleted file mode 100644 index 0548476..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/test_llex.lua +++ /dev/null | |||
@@ -1,580 +0,0 @@ | |||
1 | --[[-------------------------------------------------------------------- | ||
2 | |||
3 | test_llex.lua | ||
4 | Test for llex.lua | ||
5 | This file is part of Yueliang. | ||
6 | |||
7 | Copyright (c) 2005-2006 Kein-Hong Man <khman@users.sf.net> | ||
8 | The COPYRIGHT file describes the conditions | ||
9 | under which this software may be distributed. | ||
10 | |||
11 | See the ChangeLog for more information. | ||
12 | |||
13 | ----------------------------------------------------------------------]] | ||
14 | |||
15 | ------------------------------------------------------------------------ | ||
16 | -- if BRIEF is not set to false, auto-test will silently succeed | ||
17 | ------------------------------------------------------------------------ | ||
18 | BRIEF = true -- if set to true, messages are less verbose | ||
19 | |||
20 | dofile("../lzio.lua") | ||
21 | dofile("../llex.lua") | ||
22 | luaX:init() | ||
23 | |||
24 | ------------------------------------------------------------------------ | ||
25 | -- simple manual tests | ||
26 | ------------------------------------------------------------------------ | ||
27 | |||
28 | --[[ | ||
29 | local L = {} -- LuaState | ||
30 | local LS = {} -- LexState | ||
31 | |||
32 | local function dump(z) | ||
33 | luaX:setinput(L, LS, z, z.name) | ||
34 | while true do | ||
35 | LS.t.token = luaX:lex(LS, LS.t) | ||
36 | local tok, seminfo = LS.t.token, LS.t.seminfo | ||
37 | if tok == "TK_NAME" then | ||
38 | seminfo = " "..seminfo | ||
39 | elseif tok == "TK_NUMBER" then | ||
40 | seminfo = " "..seminfo | ||
41 | elseif tok == "TK_STRING" then | ||
42 | seminfo = " '"..seminfo.."'" | ||
43 | else | ||
44 | seminfo = "" | ||
45 | end | ||
46 | io.stdout:write(tok..seminfo.."\n") | ||
47 | if tok == "TK_EOS" then break end | ||
48 | end | ||
49 | end | ||
50 | |||
51 | local function try_string(chunk) | ||
52 | dump(luaZ:init(luaZ:make_getS(chunk), nil, "=string")) | ||
53 | end | ||
54 | local function try_file(filename) | ||
55 | dump(luaZ:init(luaZ:make_getF(filename), nil, filename)) | ||
56 | end | ||
57 | |||
58 | z = try_string("local c = luaZ:zgetc(z)") | ||
59 | z = try_file("test_lzio.lua") | ||
60 | z = try_file("test_llex.lua") | ||
61 | os.exit() | ||
62 | --]] | ||
63 | |||
64 | ------------------------------------------------------------------------ | ||
65 | -- auto-testing of simple test cases to validate lexer behaviour: | ||
66 | -- * NOTE coverage has not been checked; not comprehensive | ||
67 | -- * only test cases with non-empty comments are processed | ||
68 | -- * if no result, then the output is displayed for manual decision | ||
69 | -- (output may be used to set expected success or fail text) | ||
70 | -- * cases expected to be successful may be a partial match | ||
71 | -- * cases expected to fail may also be a partial match | ||
72 | ------------------------------------------------------------------------ | ||
73 | |||
74 | -- [[ | ||
75 | local function auto_test() | ||
76 | local PASS, FAIL = true, false | ||
77 | ------------------------------------------------------------------ | ||
78 | -- table of test cases | ||
79 | ------------------------------------------------------------------ | ||
80 | local test_cases = | ||
81 | { | ||
82 | ------------------------------------------------------------- | ||
83 | --{ "comment", -- comment about the test | ||
84 | -- "chunk", -- chunk to test | ||
85 | -- PASS, -- PASS or FAIL outcome | ||
86 | -- "output", -- output to compare against | ||
87 | --}, | ||
88 | ------------------------------------------------------------- | ||
89 | { "empty chunk string, test EOS", | ||
90 | "", | ||
91 | PASS, "1 TK_EOS", | ||
92 | }, | ||
93 | ------------------------------------------------------------- | ||
94 | { "line number counting", | ||
95 | "\n\n\r\n", | ||
96 | PASS, "4 TK_EOS", | ||
97 | }, | ||
98 | ------------------------------------------------------------- | ||
99 | { "various whitespaces", | ||
100 | " \n\t\t\n \t \t \n\n", | ||
101 | PASS, "5 TK_EOS", | ||
102 | }, | ||
103 | ------------------------------------------------------------- | ||
104 | { "short comment ending in EOS", | ||
105 | "-- moo moo", | ||
106 | PASS, "1 TK_EOS", | ||
107 | }, | ||
108 | ------------------------------------------------------------- | ||
109 | { "short comment ending in newline", | ||
110 | "-- moo moo\n", | ||
111 | PASS, "2 TK_EOS", | ||
112 | }, | ||
113 | ------------------------------------------------------------- | ||
114 | { "several lines of short comments", | ||
115 | "--moo\n-- moo moo\n\n--\tmoo\n", | ||
116 | PASS, "5 TK_EOS", | ||
117 | }, | ||
118 | ------------------------------------------------------------- | ||
119 | { "basic block comment 1", | ||
120 | "--[[bovine]]", | ||
121 | PASS, "1 TK_EOS", | ||
122 | }, | ||
123 | ------------------------------------------------------------- | ||
124 | { "basic block comment 2", | ||
125 | "--[=[bovine]=]", | ||
126 | PASS, "1 TK_EOS", | ||
127 | }, | ||
128 | ------------------------------------------------------------- | ||
129 | { "basic block comment 3", | ||
130 | "--[====[-[[bovine]]-]====]", | ||
131 | PASS, "1 TK_EOS", | ||
132 | }, | ||
133 | ------------------------------------------------------------- | ||
134 | { "unterminated block comment 1", | ||
135 | "--[[bovine", | ||
136 | FAIL, ":1: unfinished long comment near '<eof>'", | ||
137 | }, | ||
138 | ------------------------------------------------------------- | ||
139 | { "unterminated block comment 2", | ||
140 | "--[==[bovine", | ||
141 | FAIL, ":1: unfinished long comment near '<eof>'", | ||
142 | }, | ||
143 | ------------------------------------------------------------- | ||
144 | { "unterminated block comment 3", | ||
145 | "--[[bovine]", | ||
146 | FAIL, ":1: unfinished long comment near '<eof>'", | ||
147 | }, | ||
148 | ------------------------------------------------------------- | ||
149 | { "unterminated block comment 4", | ||
150 | "--[[bovine\nmoo moo\nwoof", | ||
151 | FAIL, ":3: unfinished long comment near '<eof>'", | ||
152 | }, | ||
153 | ------------------------------------------------------------- | ||
154 | { "basic long string 1", | ||
155 | "\n[[bovine]]\n", | ||
156 | PASS, "2 TK_STRING = bovine\n3 TK_EOS", | ||
157 | }, | ||
158 | ------------------------------------------------------------- | ||
159 | { "basic long string 2", | ||
160 | "\n[=[bovine]=]\n", | ||
161 | PASS, "2 TK_STRING = bovine\n3 TK_EOS", | ||
162 | }, | ||
163 | ------------------------------------------------------------- | ||
164 | { "first newline consumed in long string", | ||
165 | "[[\nmoo]]", | ||
166 | PASS, "2 TK_STRING = moo\n2 TK_EOS", | ||
167 | }, | ||
168 | ------------------------------------------------------------- | ||
169 | { "multiline long string 1", | ||
170 | "[[moo\nmoo moo\n]]", | ||
171 | PASS, "3 TK_STRING = moo\nmoo moo\n\n3 TK_EOS", | ||
172 | }, | ||
173 | ------------------------------------------------------------- | ||
174 | { "multiline long string 2", | ||
175 | "[===[moo\n[=[moo moo]=]\n]===]", | ||
176 | PASS, "3 TK_STRING = moo\n[=[moo moo]=]\n\n3 TK_EOS", | ||
177 | }, | ||
178 | ------------------------------------------------------------- | ||
179 | { "unterminated long string 1", | ||
180 | "\n[[\nbovine", | ||
181 | FAIL, ":3: unfinished long string near '<eof>'", | ||
182 | }, | ||
183 | ------------------------------------------------------------- | ||
184 | { "unterminated long string 2", | ||
185 | "[[bovine]", | ||
186 | FAIL, ":1: unfinished long string near '<eof>'", | ||
187 | }, | ||
188 | ------------------------------------------------------------- | ||
189 | { "unterminated long string 2", | ||
190 | "[==[bovine]==", | ||
191 | FAIL, ":1: unfinished long string near '<eof>'", | ||
192 | }, | ||
193 | ------------------------------------------------------------- | ||
194 | { "complex long string 1", | ||
195 | "[=[moo[[moo]]moo]=]", | ||
196 | PASS, "moo[[moo]]moo", | ||
197 | }, | ||
198 | ------------------------------------------------------------- | ||
199 | { "complex long string 2", | ||
200 | "[=[moo[[moo[[[[]]]]moo]]moo]=]", | ||
201 | PASS, "moo[[moo[[[[]]]]moo]]moo", | ||
202 | }, | ||
203 | ------------------------------------------------------------- | ||
204 | { "complex long string 3", | ||
205 | "[=[[[[[]]]][[[[]]]]]=]", | ||
206 | PASS, "[[[[]]]][[[[]]]]", | ||
207 | }, | ||
208 | ------------------------------------------------------------- | ||
209 | { "deprecated long string 1", | ||
210 | "[[moo[[moo]]moo]]", | ||
211 | FAIL, ":1: nesting of [[...]] is deprecated near '['", | ||
212 | }, | ||
213 | ------------------------------------------------------------- | ||
214 | { "deprecated long string 2", | ||
215 | "[[[[ \n", | ||
216 | FAIL, ":1: nesting of [[...]] is deprecated near '['", | ||
217 | }, | ||
218 | ------------------------------------------------------------- | ||
219 | { "deprecated long string 3", | ||
220 | "[[moo[[moo[[[[]]]]moo]]moo]]", | ||
221 | FAIL, ":1: nesting of [[...]] is deprecated near '['", | ||
222 | }, | ||
223 | ------------------------------------------------------------- | ||
224 | { "deprecated long string 4", | ||
225 | "[[[[[[]]]][[[[]]]]]]", | ||
226 | FAIL, ":1: nesting of [[...]] is deprecated near '['", | ||
227 | }, | ||
228 | ------------------------------------------------------------- | ||
229 | { "brackets in long strings 1", | ||
230 | "[[moo[moo]]", | ||
231 | PASS, "moo[moo", | ||
232 | }, | ||
233 | ------------------------------------------------------------- | ||
234 | { "brackets in long strings 2", | ||
235 | "[=[moo[[moo]moo]]moo]=]", | ||
236 | PASS, "moo[[moo]moo]]moo", | ||
237 | }, | ||
238 | ------------------------------------------------------------- | ||
239 | { "unprocessed escapes in long strings", | ||
240 | [[ [=[\a\b\f\n\r\t\v\123]=] ]], | ||
241 | PASS, [[\a\b\f\n\r\t\v\123]], | ||
242 | }, | ||
243 | ------------------------------------------------------------- | ||
244 | { "unbalanced long string", | ||
245 | "[[moo]]moo]]", | ||
246 | PASS, "1 TK_STRING = moo\n1 TK_NAME = moo\n1 CHAR = ']'\n1 CHAR = ']'\n1 TK_EOS", | ||
247 | }, | ||
248 | ------------------------------------------------------------- | ||
249 | { "keywords 1", | ||
250 | "and break do else", | ||
251 | PASS, "1 TK_AND\n1 TK_BREAK\n1 TK_DO\n1 TK_ELSE\n1 TK_EOS", | ||
252 | }, | ||
253 | ------------------------------------------------------------- | ||
254 | { "keywords 2", | ||
255 | "elseif end false for", | ||
256 | PASS, "1 TK_ELSEIF\n1 TK_END\n1 TK_FALSE\n1 TK_FOR\n1 TK_EOS", | ||
257 | }, | ||
258 | ------------------------------------------------------------- | ||
259 | { "keywords 3", | ||
260 | "function if in local nil", | ||
261 | PASS, "1 TK_FUNCTION\n1 TK_IF\n1 TK_IN\n1 TK_LOCAL\n1 TK_NIL\n1 TK_EOS", | ||
262 | }, | ||
263 | ------------------------------------------------------------- | ||
264 | { "keywords 4", | ||
265 | "not or repeat return", | ||
266 | PASS, "1 TK_NOT\n1 TK_OR\n1 TK_REPEAT\n1 TK_RETURN\n1 TK_EOS", | ||
267 | }, | ||
268 | ------------------------------------------------------------- | ||
269 | { "keywords 5", | ||
270 | "then true until while", | ||
271 | PASS, "1 TK_THEN\n1 TK_TRUE\n1 TK_UNTIL\n1 TK_WHILE\n1 TK_EOS", | ||
272 | }, | ||
273 | ------------------------------------------------------------- | ||
274 | { "concat and dots", | ||
275 | ".. ...", | ||
276 | PASS, "1 TK_CONCAT\n1 TK_DOTS\n1 TK_EOS", | ||
277 | }, | ||
278 | ------------------------------------------------------------- | ||
279 | -- NOTE: in Lua 5.1.x, shbang handling is no longer performed | ||
280 | -- in the lexer; it is now done in lauxlib.c (luaL_loadfile) | ||
281 | -- so the following cannot be performed by the lexer... | ||
282 | ------------------------------------------------------------- | ||
283 | --{ "shbang handling 1", | ||
284 | -- "#blahblah", | ||
285 | -- PASS, "1 TK_EOS", | ||
286 | --}, | ||
287 | ------------------------------------------------------------- | ||
288 | --{ "shbang handling 2", | ||
289 | -- "#blahblah\nmoo moo\n", | ||
290 | -- PASS, "2 TK_NAME = moo\n2 TK_NAME = moo\n3 TK_EOS", | ||
291 | --}, | ||
292 | ------------------------------------------------------------- | ||
293 | { "empty string", | ||
294 | [['']], | ||
295 | PASS, "1 TK_STRING = \n1 TK_EOS", | ||
296 | }, | ||
297 | ------------------------------------------------------------- | ||
298 | { "single-quoted string", | ||
299 | [['bovine']], | ||
300 | PASS, "1 TK_STRING = bovine\n1 TK_EOS", | ||
301 | }, | ||
302 | ------------------------------------------------------------- | ||
303 | { "double-quoted string", | ||
304 | [["bovine"]], | ||
305 | PASS, "1 TK_STRING = bovine\n1 TK_EOS", | ||
306 | }, | ||
307 | ------------------------------------------------------------- | ||
308 | { "unterminated string 1", | ||
309 | [['moo ]], | ||
310 | FAIL, ":1: unfinished string near '<eof>'", | ||
311 | }, | ||
312 | ------------------------------------------------------------- | ||
313 | { "unterminated string 2", | ||
314 | [["moo \n]], | ||
315 | FAIL, ":1: unfinished string near '<eof>'", | ||
316 | }, | ||
317 | ------------------------------------------------------------- | ||
318 | { "escaped newline in string, line number counted", | ||
319 | "\"moo\\\nmoo\\\nmoo\"", | ||
320 | PASS, "3 TK_STRING = moo\nmoo\nmoo\n3 TK_EOS", | ||
321 | }, | ||
322 | ------------------------------------------------------------- | ||
323 | { "escaped characters in string 1", | ||
324 | [["moo\amoo"]], | ||
325 | PASS, "1 TK_STRING = moo\amoo", | ||
326 | }, | ||
327 | ------------------------------------------------------------- | ||
328 | { "escaped characters in string 2", | ||
329 | [["moo\bmoo"]], | ||
330 | PASS, "1 TK_STRING = moo\bmoo", | ||
331 | }, | ||
332 | ------------------------------------------------------------- | ||
333 | { "escaped characters in string 3", | ||
334 | [["moo\f\n\r\t\vmoo"]], | ||
335 | PASS, "1 TK_STRING = moo\f\n\r\t\vmoo", | ||
336 | }, | ||
337 | ------------------------------------------------------------- | ||
338 | { "escaped characters in string 4", | ||
339 | [["\\ \" \' \? \[ \]"]], | ||
340 | PASS, "1 TK_STRING = \\ \" \' \? \[ \]", | ||
341 | }, | ||
342 | ------------------------------------------------------------- | ||
343 | { "escaped characters in string 5", | ||
344 | [["\z \k \: \;"]], | ||
345 | PASS, "1 TK_STRING = z k : ;", | ||
346 | }, | ||
347 | ------------------------------------------------------------- | ||
348 | { "escaped characters in string 6", | ||
349 | [["\8 \65 \160 \180K \097097"]], | ||
350 | PASS, "1 TK_STRING = \8 \65 \160 \180K \097097\n", | ||
351 | }, | ||
352 | ------------------------------------------------------------- | ||
353 | { "escaped characters in string 7", | ||
354 | [["\666"]], | ||
355 | FAIL, ":1: escape sequence too large near '\"'", | ||
356 | }, | ||
357 | ------------------------------------------------------------- | ||
358 | { "simple numbers", | ||
359 | "123 123+", | ||
360 | PASS, "1 TK_NUMBER = 123\n1 TK_NUMBER = 123\n1 CHAR = '+'\n1 TK_EOS", | ||
361 | }, | ||
362 | ------------------------------------------------------------- | ||
363 | { "longer numbers", | ||
364 | "1234567890 12345678901234567890", | ||
365 | PASS, "1 TK_NUMBER = 1234567890\n1 TK_NUMBER = 1.2345678901235e+19\n", | ||
366 | }, | ||
367 | ------------------------------------------------------------- | ||
368 | { "fractional numbers", | ||
369 | ".123 .12345678901234567890", | ||
370 | PASS, "1 TK_NUMBER = 0.123\n1 TK_NUMBER = 0.12345678901235\n", | ||
371 | }, | ||
372 | ------------------------------------------------------------- | ||
373 | { "more numbers with decimal points", | ||
374 | "12345.67890", | ||
375 | PASS, "1 TK_NUMBER = 12345.6789\n", | ||
376 | }, | ||
377 | ------------------------------------------------------------- | ||
378 | { "malformed number with decimal points", | ||
379 | "1.1.", | ||
380 | FAIL, ":1: malformed number near '1.1.'", | ||
381 | }, | ||
382 | ------------------------------------------------------------- | ||
383 | { "double decimal points", | ||
384 | ".1.1", | ||
385 | FAIL, ":1: malformed number near '.1.1'", | ||
386 | }, | ||
387 | ------------------------------------------------------------- | ||
388 | { "double dots within numbers", | ||
389 | "1..1", | ||
390 | FAIL, ":1: malformed number near '1..1'", | ||
391 | }, | ||
392 | ------------------------------------------------------------- | ||
393 | { "incomplete exponential numbers", | ||
394 | "123e", | ||
395 | FAIL, ":1: malformed number near '123e'", | ||
396 | }, | ||
397 | ------------------------------------------------------------- | ||
398 | { "exponential numbers 1", | ||
399 | "1234e5 1234e5.", | ||
400 | PASS, "1 TK_NUMBER = 123400000\n1 TK_NUMBER = 123400000\n1 CHAR = '.'", | ||
401 | }, | ||
402 | ------------------------------------------------------------- | ||
403 | { "exponential numbers 2", | ||
404 | "1234e56 1.23e123", | ||
405 | PASS, "1 TK_NUMBER = 1.234e+59\n1 TK_NUMBER = 1.23e+123\n", | ||
406 | }, | ||
407 | ------------------------------------------------------------- | ||
408 | { "exponential numbers 3", | ||
409 | "12.34e+", | ||
410 | FAIL, ":1: malformed number near '12.34e+'", | ||
411 | }, | ||
412 | ------------------------------------------------------------- | ||
413 | { "exponential numbers 4", | ||
414 | "12.34e+5 123.4e-5 1234.E+5", | ||
415 | PASS, "1 TK_NUMBER = 1234000\n1 TK_NUMBER = 0.001234\n1 TK_NUMBER = 123400000\n", | ||
416 | }, | ||
417 | ------------------------------------------------------------- | ||
418 | { "hexadecimal numbers", | ||
419 | "0x00FF 0X1234 0xDEADBEEF", | ||
420 | PASS, "1 TK_NUMBER = 255\n1 TK_NUMBER = 4660\n1 TK_NUMBER = 3735928559\n", | ||
421 | }, | ||
422 | ------------------------------------------------------------- | ||
423 | { "invalid hexadecimal numbers 1", | ||
424 | "0xFOO", | ||
425 | FAIL, ":1: malformed number near '0xFOO'", | ||
426 | }, | ||
427 | ------------------------------------------------------------- | ||
428 | { "invalid hexadecimal numbers 2", | ||
429 | "0.BAR", | ||
430 | FAIL, ":1: malformed number near '0.BAR'", | ||
431 | }, | ||
432 | ------------------------------------------------------------- | ||
433 | { "invalid hexadecimal numbers 3", | ||
434 | "0BAZ", | ||
435 | FAIL, ":1: malformed number near '0BAZ'", | ||
436 | }, | ||
437 | ------------------------------------------------------------- | ||
438 | { "single character symbols 1", | ||
439 | "= > < ~ #", | ||
440 | PASS, "1 CHAR = '='\n1 CHAR = '>'\n1 CHAR = '<'\n1 CHAR = '~'\n1 CHAR = '#'\n", | ||
441 | }, | ||
442 | ------------------------------------------------------------- | ||
443 | { "double character symbols", | ||
444 | "== >= <= ~=", | ||
445 | PASS, "1 TK_EQ\n1 TK_GE\n1 TK_LE\n1 TK_NE\n", | ||
446 | }, | ||
447 | ------------------------------------------------------------- | ||
448 | { "simple identifiers", | ||
449 | "abc ABC", | ||
450 | PASS, "1 TK_NAME = abc\n1 TK_NAME = ABC\n1 TK_EOS", | ||
451 | }, | ||
452 | ------------------------------------------------------------- | ||
453 | { "more identifiers", | ||
454 | "_abc _ABC", | ||
455 | PASS, "1 TK_NAME = _abc\n1 TK_NAME = _ABC\n1 TK_EOS", | ||
456 | }, | ||
457 | ------------------------------------------------------------- | ||
458 | { "still more identifiers", | ||
459 | "_aB_ _123", | ||
460 | PASS, "1 TK_NAME = _aB_\n1 TK_NAME = _123\n1 TK_EOS", | ||
461 | }, | ||
462 | ------------------------------------------------------------- | ||
463 | -- NOTE: in Lua 5.1.x, this test is no longer performed | ||
464 | ------------------------------------------------------------- | ||
465 | --{ "invalid control character", | ||
466 | -- "\4", | ||
467 | -- FAIL, ":1: invalid control char near 'char(4)'", | ||
468 | --}, | ||
469 | ------------------------------------------------------------- | ||
470 | { "single character symbols 2", | ||
471 | "` ! @ $ %", | ||
472 | PASS, "1 CHAR = '`'\n1 CHAR = '!'\n1 CHAR = '@'\n1 CHAR = '$'\n1 CHAR = '%'\n", | ||
473 | }, | ||
474 | ------------------------------------------------------------- | ||
475 | { "single character symbols 3", | ||
476 | "^ & * ( )", | ||
477 | PASS, "1 CHAR = '^'\n1 CHAR = '&'\n1 CHAR = '*'\n1 CHAR = '('\n1 CHAR = ')'\n", | ||
478 | }, | ||
479 | ------------------------------------------------------------- | ||
480 | { "single character symbols 4", | ||
481 | "_ - + \\ |", | ||
482 | PASS, "1 TK_NAME = _\n1 CHAR = '-'\n1 CHAR = '+'\n1 CHAR = '\\'\n1 CHAR = '|'\n", | ||
483 | }, | ||
484 | ------------------------------------------------------------- | ||
485 | { "single character symbols 5", | ||
486 | "{ } [ ] :", | ||
487 | PASS, "1 CHAR = '{'\n1 CHAR = '}'\n1 CHAR = '['\n1 CHAR = ']'\n1 CHAR = ':'\n", | ||
488 | }, | ||
489 | ------------------------------------------------------------- | ||
490 | { "single character symbols 6", | ||
491 | "; , . / ?", | ||
492 | PASS, "1 CHAR = ';'\n1 CHAR = ','\n1 CHAR = '.'\n1 CHAR = '/'\n1 CHAR = '?'\n", | ||
493 | }, | ||
494 | ------------------------------------------------------------- | ||
495 | } | ||
496 | ------------------------------------------------------------------ | ||
497 | -- perform a test case | ||
498 | ------------------------------------------------------------------ | ||
499 | function do_test_case(count, test_case) | ||
500 | if comment == "" then return end -- skip empty entries | ||
501 | local comment, chunk, outcome, matcher = unpack(test_case) | ||
502 | local result = PASS | ||
503 | local output = "" | ||
504 | -- initialize lexer | ||
505 | local L, LS = {}, {} | ||
506 | local z = luaZ:init(luaZ:make_getS(chunk), nil) | ||
507 | luaX:setinput(L, LS, z, "=test") | ||
508 | -- lexer test loop | ||
509 | repeat | ||
510 | -- protected call | ||
511 | local status, token = pcall(luaX.llex, luaX, LS, LS.t) | ||
512 | LS.t.token = token | ||
513 | output = output..LS.linenumber.." " | ||
514 | if status then | ||
515 | -- successful call | ||
516 | if string.len(token) > 1 then | ||
517 | if token == "TK_NAME" | ||
518 | or token == "TK_NUMBER" | ||
519 | or token == "TK_STRING" then | ||
520 | token = token.." = "..LS.t.seminfo | ||
521 | end | ||
522 | elseif string.byte(token) >= 32 then -- displayable chars | ||
523 | token = "CHAR = '"..token.."'" | ||
524 | else -- control characters | ||
525 | token = "CHAR = (".. string.byte(token)..")" | ||
526 | end | ||
527 | output = output..token.."\n" | ||
528 | else | ||
529 | -- failed call | ||
530 | output = output..token -- token is the error message | ||
531 | result = FAIL | ||
532 | break | ||
533 | end | ||
534 | until LS.t.token == "TK_EOS" | ||
535 | -- decision making and reporting | ||
536 | local head = "Test "..count..": "..comment | ||
537 | if matcher == "" then | ||
538 | -- nothing to check against, display for manual check | ||
539 | print(head.."\nMANUAL please check manually".. | ||
540 | "\n--chunk---------------------------------\n"..chunk.. | ||
541 | "\n--actual--------------------------------\n"..output.. | ||
542 | "\n\n") | ||
543 | return | ||
544 | else | ||
545 | if outcome == PASS then | ||
546 | -- success expected, may be a partial match | ||
547 | if string.find(output, matcher, 1, 1) and result == PASS then | ||
548 | if not BRIEF then print(head.."\nOK expected success\n") end | ||
549 | return | ||
550 | end | ||
551 | else | ||
552 | -- failure expected, may be a partial match | ||
553 | if string.find(output, matcher, 1, 1) and result == FAIL then | ||
554 | if not BRIEF then print(head.."\nOK expected failure\n") end | ||
555 | return | ||
556 | end | ||
557 | end | ||
558 | -- failed because of unmatched string or boolean result | ||
559 | local function passfail(status) | ||
560 | if status == PASS then return "PASS" else return "FAIL" end | ||
561 | end | ||
562 | print(head.." *FAILED*".. | ||
563 | "\noutcome="..passfail(outcome).. | ||
564 | "\nactual= "..passfail(result).. | ||
565 | "\n--chunk---------------------------------\n"..chunk.. | ||
566 | "\n--expected------------------------------\n"..matcher.. | ||
567 | "\n--actual--------------------------------\n"..output.. | ||
568 | "\n\n") | ||
569 | end | ||
570 | end | ||
571 | ------------------------------------------------------------------ | ||
572 | -- perform auto testing | ||
573 | ------------------------------------------------------------------ | ||
574 | for i,test_case in ipairs(test_cases) do | ||
575 | do_test_case(i, test_case) | ||
576 | end | ||
577 | end | ||
578 | |||
579 | auto_test() | ||
580 | --]] | ||
diff --git a/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/test_lparser.lua b/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/test_lparser.lua deleted file mode 100644 index 8c7abf4..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/test_lparser.lua +++ /dev/null | |||
@@ -1,59 +0,0 @@ | |||
1 | --[[-------------------------------------------------------------------- | ||
2 | |||
3 | test_lparser.lua | ||
4 | Test for lparser.lua | ||
5 | This file is part of Yueliang. | ||
6 | |||
7 | Copyright (c) 2005-2006 Kein-Hong Man <khman@users.sf.net> | ||
8 | The COPYRIGHT file describes the conditions | ||
9 | under which this software may be distributed. | ||
10 | |||
11 | See the ChangeLog for more information. | ||
12 | |||
13 | ----------------------------------------------------------------------]] | ||
14 | |||
15 | ------------------------------------------------------------------------ | ||
16 | -- test the whole kaboodle | ||
17 | ------------------------------------------------------------------------ | ||
18 | |||
19 | dofile("../lzio.lua") | ||
20 | dofile("../llex.lua") | ||
21 | dofile("../lopcodes.lua") | ||
22 | dofile("../ldump.lua") | ||
23 | dofile("../lcode.lua") | ||
24 | dofile("../lparser.lua") | ||
25 | |||
26 | function lua_assert(test) | ||
27 | if not test then error("assertion failed!") end | ||
28 | end | ||
29 | |||
30 | luaX:init() | ||
31 | |||
32 | ------------------------------------------------------------------------ | ||
33 | -- try 1 | ||
34 | ------------------------------------------------------------------------ | ||
35 | local zio = luaZ:init(luaZ:make_getS("local a = 1"), nil) | ||
36 | local LuaState = {} | ||
37 | local Func = luaY:parser(LuaState, zio, nil, "=string") | ||
38 | |||
39 | --[[ | ||
40 | for i, v in Func do | ||
41 | if type(v) == "string" or type(v) == "number" then | ||
42 | print(i, v) | ||
43 | elseif type(v) == "table" then | ||
44 | print(i, "TABLE") | ||
45 | end | ||
46 | end | ||
47 | --]] | ||
48 | |||
49 | local Writer, Buff = luaU:make_setF("parse1.out") | ||
50 | luaU:dump(LuaState, Func, Writer, Buff) | ||
51 | |||
52 | ------------------------------------------------------------------------ | ||
53 | -- try 2 | ||
54 | ------------------------------------------------------------------------ | ||
55 | |||
56 | zio = luaZ:init(luaZ:make_getF("sample.lua"), nil) | ||
57 | Func = luaY:parser(LuaState, zio, nil, "@sample.lua") | ||
58 | Writer, Buff = luaU:make_setF("parse2.out") | ||
59 | luaU:dump(LuaState, Func, Writer, Buff) | ||
diff --git a/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/test_lparser2.lua b/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/test_lparser2.lua deleted file mode 100644 index e9fa188..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/test_lparser2.lua +++ /dev/null | |||
@@ -1,202 +0,0 @@ | |||
1 | --[[-------------------------------------------------------------------- | ||
2 | |||
3 | test_lparser2.lua | ||
4 | Test for lparser.lua, using the test case file | ||
5 | This file is part of Yueliang. | ||
6 | |||
7 | Copyright (c) 2006 Kein-Hong Man <khman@users.sf.net> | ||
8 | The COPYRIGHT file describes the conditions | ||
9 | under which this software may be distributed. | ||
10 | |||
11 | See the ChangeLog for more information. | ||
12 | |||
13 | ----------------------------------------------------------------------]] | ||
14 | |||
15 | --[[-------------------------------------------------------------------- | ||
16 | -- Notes: | ||
17 | -- * the test cases are in the test_lua directory (test_parser-5.1.lua) | ||
18 | ----------------------------------------------------------------------]] | ||
19 | |||
20 | -- * true if you want an output of all failure cases in native Lua, | ||
21 | -- for checking whether test cases fail where you intend them to | ||
22 | local DEBUG_FAILS = false | ||
23 | |||
24 | ------------------------------------------------------------------------ | ||
25 | -- test the whole kaboodle | ||
26 | ------------------------------------------------------------------------ | ||
27 | |||
28 | dofile("../lzio.lua") | ||
29 | dofile("../llex.lua") | ||
30 | dofile("../lopcodes.lua") | ||
31 | dofile("../ldump.lua") | ||
32 | dofile("../lcode.lua") | ||
33 | dofile("../lparser.lua") | ||
34 | |||
35 | function lua_assert(test) | ||
36 | if not test then error("assertion failed!") end | ||
37 | end | ||
38 | |||
39 | luaX:init() | ||
40 | |||
41 | ------------------------------------------------------------------------ | ||
42 | -- load test cases | ||
43 | ------------------------------------------------------------------------ | ||
44 | |||
45 | dofile("../../test_lua/test_parser-5.1.lua") | ||
46 | |||
47 | local test, expect, heading = {}, {}, {} | ||
48 | local total, total_pass, total_fail = 0, 0, 0 | ||
49 | |||
50 | for ln in string.gmatch(tests_source, "([^\n]*)\n") do | ||
51 | if string.find(ln, "^%s*%-%-") then | ||
52 | -- comment, ignore | ||
53 | else | ||
54 | local m, _, head = string.find(ln, "^%s*(TESTS:%s*.*)$") | ||
55 | if m then | ||
56 | heading[total + 1] = head -- informational heading | ||
57 | else | ||
58 | total = total + 1 | ||
59 | local n, _, flag = string.find(ln, "%s*%-%-%s*FAIL%s*$") | ||
60 | if n then -- FAIL test case | ||
61 | ln = string.sub(ln, 1, n - 1) -- remove comment | ||
62 | expect[total] = "FAIL" | ||
63 | total_fail = total_fail + 1 | ||
64 | else -- PASS test case | ||
65 | expect[total] = "PASS" | ||
66 | total_pass = total_pass + 1 | ||
67 | end--n | ||
68 | test[total] = ln | ||
69 | end--m | ||
70 | end--ln | ||
71 | end--for | ||
72 | |||
73 | print("Tests loaded: "..total.." (total), " | ||
74 | ..total_pass.." (passes), " | ||
75 | ..total_fail.." (fails)") | ||
76 | |||
77 | ------------------------------------------------------------------------ | ||
78 | -- verify test cases using native Lua | ||
79 | ------------------------------------------------------------------------ | ||
80 | |||
81 | local last_head = "TESTS: no heading yet" | ||
82 | for i = 1, total do | ||
83 | local test_case, expected, head = test[i], expect[i], heading[i] | ||
84 | -- show progress | ||
85 | if head then | ||
86 | last_head = head | ||
87 | if DEBUG_FAILS then print("\n"..head.."\n") end | ||
88 | end | ||
89 | ------------------------------------------------------------------ | ||
90 | -- perform test | ||
91 | local f, err = loadstring(test_case) | ||
92 | -- look at outcome | ||
93 | ------------------------------------------------------------------ | ||
94 | if f then-- actual PASS | ||
95 | if expected == "FAIL" then | ||
96 | print("\nVerified as PASS but expected to FAIL".. | ||
97 | "\n-------------------------------------") | ||
98 | print("Lastest heading: "..last_head) | ||
99 | print("TEST: "..test_case) | ||
100 | os.exit() | ||
101 | end | ||
102 | ------------------------------------------------------------------ | ||
103 | else-- actual FAIL | ||
104 | if expected == "PASS" then | ||
105 | print("\nVerified as FAIL but expected to PASS".. | ||
106 | "\n-------------------------------------") | ||
107 | print("Lastest heading: "..last_head) | ||
108 | print("TEST: "..test_case) | ||
109 | print("ERROR: "..err) | ||
110 | os.exit() | ||
111 | end | ||
112 | if DEBUG_FAILS then | ||
113 | print("TEST: "..test_case) | ||
114 | print("ERROR: "..err.."\n") | ||
115 | end | ||
116 | ------------------------------------------------------------------ | ||
117 | end--f | ||
118 | end--for | ||
119 | |||
120 | print("Test cases verified using native Lua, no anomalies.") | ||
121 | |||
122 | ------------------------------------------------------------------------ | ||
123 | -- dump binary chunks to a file if something goes wrong | ||
124 | ------------------------------------------------------------------------ | ||
125 | local function Dump(data, filename) | ||
126 | h = io.open(filename, "wb") | ||
127 | if not h then error("failed to open "..filename.." for writing") end | ||
128 | h:write(data) | ||
129 | h:close() | ||
130 | end | ||
131 | |||
132 | ------------------------------------------------------------------------ | ||
133 | -- test using Yueliang front end | ||
134 | ------------------------------------------------------------------------ | ||
135 | |||
136 | local last_head = "TESTS: no heading yet" | ||
137 | for i = 1, total do | ||
138 | local test_case, expected, head = test[i], expect[i], heading[i] | ||
139 | -- show progress | ||
140 | if head then last_head = head end | ||
141 | ------------------------------------------------------------------ | ||
142 | -- perform test | ||
143 | local LuaState = {} | ||
144 | local zio = luaZ:init(luaZ:make_getS(test_case), nil) | ||
145 | local status, func = pcall(luaY.parser, luaY, LuaState, zio, nil, "test") | ||
146 | -- look at outcome | ||
147 | ------------------------------------------------------------------ | ||
148 | if status then-- actual PASS | ||
149 | if expected == "PASS" then | ||
150 | -- actual PASS and expected PASS, so check binary chunks | ||
151 | local writer, buff = luaU:make_setS() | ||
152 | luaU:dump(LuaState, func, writer, buff) | ||
153 | local bc1 = buff.data -- Yueliang's output | ||
154 | local f = loadstring(test_case, "test") | ||
155 | local bc2 = string.dump(f) -- Lua's output | ||
156 | local die | ||
157 | -- compare outputs | ||
158 | if #bc1 ~= #bc2 then | ||
159 | Dump(bc1, "bc1.out") | ||
160 | Dump(bc2, "bc2.out") | ||
161 | die = "binary chunk sizes different" | ||
162 | elseif bc1 ~= bc2 then | ||
163 | Dump(bc1, "bc1.out") | ||
164 | Dump(bc2, "bc2.out") | ||
165 | die = "binary chunks different" | ||
166 | else | ||
167 | -- everything checks out! | ||
168 | end | ||
169 | if die then | ||
170 | print("\nTested PASS and expected to PASS, but chunks different".. | ||
171 | "\n------------------------------------------------------") | ||
172 | print("Reason: "..die) | ||
173 | print("Lastest heading: "..last_head) | ||
174 | print("TEST: "..test_case) | ||
175 | os.exit() | ||
176 | end | ||
177 | else-- expected FAIL | ||
178 | print("\nTested as PASS but expected to FAIL".. | ||
179 | "\n-----------------------------------") | ||
180 | print("Lastest heading: "..last_head) | ||
181 | print("TEST: "..test_case) | ||
182 | os.exit() | ||
183 | end | ||
184 | ------------------------------------------------------------------ | ||
185 | else-- actual FAIL | ||
186 | if expected == "PASS" then | ||
187 | print("\nTested as FAIL but expected to PASS".. | ||
188 | "\n-----------------------------------") | ||
189 | print("Lastest heading: "..last_head) | ||
190 | print("TEST: "..test_case) | ||
191 | print("ERROR: "..err) | ||
192 | os.exit() | ||
193 | end | ||
194 | ------------------------------------------------------------------ | ||
195 | end--status | ||
196 | io.stdout:write("\rTesting ["..i.."]...") | ||
197 | end--for | ||
198 | print(" done.") | ||
199 | |||
200 | print("Test cases run on Yueliang, no anomalies.") | ||
201 | |||
202 | -- end | ||
diff --git a/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/test_lzio.lua b/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/test_lzio.lua deleted file mode 100644 index c3879f1..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/test_lzio.lua +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | --[[-------------------------------------------------------------------- | ||
2 | |||
3 | test_lzio.lua | ||
4 | Test for lzio.lua | ||
5 | This file is part of Yueliang. | ||
6 | |||
7 | Copyright (c) 2006 Kein-Hong Man <khman@users.sf.net> | ||
8 | The COPYRIGHT file describes the conditions | ||
9 | under which this software may be distributed. | ||
10 | |||
11 | See the ChangeLog for more information. | ||
12 | |||
13 | ----------------------------------------------------------------------]] | ||
14 | |||
15 | -- manual test for lzio.lua lua-style chunk reader | ||
16 | |||
17 | dofile("../lzio.lua") | ||
18 | |||
19 | local z | ||
20 | function dump(z) | ||
21 | while true do | ||
22 | local c = luaZ:zgetc(z) | ||
23 | io.stdout:write("("..c..")") | ||
24 | if c == "EOZ" then break end | ||
25 | end | ||
26 | io.stdout:write("\n") | ||
27 | end | ||
28 | |||
29 | -- luaZ:make_getS or luaZ:make_getF creates a chunk reader | ||
30 | -- luaZ:init makes a zio stream | ||
31 | |||
32 | -- [[ | ||
33 | z = luaZ:init(luaZ:make_getS("hello, world!"), nil, "=string") | ||
34 | dump(z) | ||
35 | z = luaZ:init(luaZ:make_getS(", world!"), "hello", "=string") | ||
36 | dump(z) | ||
37 | z = luaZ:init(luaZ:make_getS("line1\nline2\n"), "", "=string") | ||
38 | dump(z) | ||
39 | z = luaZ:init(luaZ:make_getF("test_lzio.lua"), nil, "=string") | ||
40 | dump(z) | ||
41 | --]] | ||
diff --git a/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/test_number.lua b/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/test_number.lua deleted file mode 100644 index 2c94f40..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/test_number.lua +++ /dev/null | |||
@@ -1,174 +0,0 @@ | |||
1 | --[[-------------------------------------------------------------------- | ||
2 | |||
3 | test_number.lua | ||
4 | Test for Lua-based number conversion functions in ldump.lua | ||
5 | This file is part of Yueliang. | ||
6 | |||
7 | Copyright (c) 2006 Kein-Hong Man <khman@users.sf.net> | ||
8 | The COPYRIGHT file describes the conditions | ||
9 | under which this software may be distributed. | ||
10 | |||
11 | See the ChangeLog for more information. | ||
12 | |||
13 | ----------------------------------------------------------------------]] | ||
14 | |||
15 | --[[-------------------------------------------------------------------- | ||
16 | -- Notes: | ||
17 | -- * luaU:from_int(value) does not have overflow checks, but this | ||
18 | -- can presumably be put in for debugging purposes. | ||
19 | -- * TODO: double conversion does not support denormals or NaNs | ||
20 | -- * apparently 0/0 == 0/0 is false (Lua 5.0.2 on Win32/Mingw), so | ||
21 | -- can't use to check for NaNs | ||
22 | ----------------------------------------------------------------------]] | ||
23 | |||
24 | dofile("../ldump.lua") | ||
25 | |||
26 | ------------------------------------------------------------------------ | ||
27 | -- convert hex string representation to a byte string | ||
28 | -- * must have an even number of hex digits | ||
29 | ------------------------------------------------------------------------ | ||
30 | local function from_hexstring(s) | ||
31 | local bs = "" | ||
32 | for i = 1, string.len(s), 2 do | ||
33 | local asc = tonumber(string.sub(s, i, i + 1), 16) | ||
34 | bs = bs..string.char(asc) | ||
35 | end | ||
36 | return bs | ||
37 | end | ||
38 | |||
39 | ------------------------------------------------------------------------ | ||
40 | -- convert a byte string to a hex string representation | ||
41 | -- * big-endian, easier to grok | ||
42 | ------------------------------------------------------------------------ | ||
43 | local function to_hexstring(s) | ||
44 | local hs = "" | ||
45 | for i = string.len(s), 1, -1 do | ||
46 | local c = string.byte(string.sub(s, i, i)) | ||
47 | hs = hs..string.format("%02X", c) | ||
48 | end | ||
49 | return hs | ||
50 | end | ||
51 | |||
52 | ------------------------------------------------------------------------ | ||
53 | -- tests for 32-bit signed/unsigned integer | ||
54 | ------------------------------------------------------------------------ | ||
55 | local function test_int(value, expected) | ||
56 | local actual = to_hexstring(luaU:from_int(value)) | ||
57 | if not expected or expected == "" then | ||
58 | print(value..": "..actual) | ||
59 | elseif actual ~= expected then | ||
60 | print(value..": FAILED!\n".. | ||
61 | "Converted: "..actual.."\n".. | ||
62 | "Expected: "..expected) | ||
63 | return true | ||
64 | end | ||
65 | return false | ||
66 | end | ||
67 | |||
68 | local table_int = { | ||
69 | ["0"] = "00000000", | ||
70 | ["1"] = "00000001", | ||
71 | ["256"] = "00000100", | ||
72 | ["-256"] = "FFFFFF00", | ||
73 | ["-1"] = "FFFFFFFF", | ||
74 | ["2147483647"] = "7FFFFFFF", -- LONG_MAX | ||
75 | ["-2147483648"] = "80000000", -- LONG_MIN | ||
76 | ["4294967295"] = "FFFFFFFF", -- ULONG_MAX | ||
77 | --[""] = "", | ||
78 | } | ||
79 | |||
80 | local success = true | ||
81 | print("Testing luaU:from_int():") | ||
82 | for i, v in pairs(table_int) do | ||
83 | local test_value = tonumber(i) | ||
84 | local expected = v | ||
85 | if test_int(test_value, expected) then | ||
86 | success = false | ||
87 | end | ||
88 | end | ||
89 | if success then | ||
90 | print("All test numbers passed okay.\n") | ||
91 | else | ||
92 | print("There were one or more failures.\n") | ||
93 | end | ||
94 | |||
95 | ------------------------------------------------------------------------ | ||
96 | -- tests for IEEE 754 64-bit double | ||
97 | ------------------------------------------------------------------------ | ||
98 | |||
99 | local function test_double(value, expected) | ||
100 | local actual = to_hexstring(luaU:from_double(value)) | ||
101 | if not expected or expected == "" then | ||
102 | print(value..": "..actual) | ||
103 | elseif actual ~= expected then | ||
104 | print(value..": FAILED!\n".. | ||
105 | "Converted: "..actual.."\n".. | ||
106 | "Expected: "..expected) | ||
107 | return true | ||
108 | end | ||
109 | return false | ||
110 | end | ||
111 | |||
112 | -- special values, see testing loop for actual lookup | ||
113 | Infinity = 1/0 | ||
114 | Infinity_neg = -1/0 | ||
115 | |||
116 | -- can't seem to do a comparison test with NaN, so leave them | ||
117 | -- (need to check the IEEE standard on this...) | ||
118 | NaN = 0/0 | ||
119 | NaN_neg = -0/0 | ||
120 | --["NaN"] = "", -- 7FF8000000000000 (djgpp) | ||
121 | --["NaN_neg"] = "", -- FFF8000000000000 (djgpp) | ||
122 | |||
123 | local table_double = { | ||
124 | -- 0 for exponent, 0 for mantissa | ||
125 | ["0"] = "0000000000000000", | ||
126 | -- 3FF is bias of 1023, so (-1)^0 * (1+0) * 2^0 | ||
127 | ["1"] = "3FF0000000000000", | ||
128 | -- BFF has sign bit on, so (-1)^1 * (1+0) * 2^0 | ||
129 | ["-1"] = "BFF0000000000000", | ||
130 | -- 3FC is bias of 1020, so (-1)^0 * (1+0) * 2^-3 | ||
131 | ["0.125"] = "3FC0000000000000", | ||
132 | ["0.250"] = "3FD0000000000000", | ||
133 | ["0.500"] = "3FE0000000000000", | ||
134 | -- 40F is bias of 1039, so (-1)^0 * (1+0) * 2^16 | ||
135 | ["65536"] = "40F0000000000000", | ||
136 | -- 7FF is bias of 2047, 0 for mantissa | ||
137 | ["Infinity"] = "7FF0000000000000", | ||
138 | -- FFF has sign bit on, 0 for mantissa | ||
139 | ["Infinity_neg"] = "FFF0000000000000", | ||
140 | -- DBL_MIN, exponent=001 ( 1), mantissa=0000000000000 | ||
141 | ["2.2250738585072014e-308"] = "0010000000000000", | ||
142 | -- DBL_MAX, exponent=7FE (2046), mantissa=FFFFFFFFFFFFF | ||
143 | ["1.7976931348623157e+308"] = "7FEFFFFFFFFFFFFF", | ||
144 | --[[ | ||
145 | -- * the following is for float numbers only * | ||
146 | -- FLT_MIN, exponent=01 ( 1), mantissa=000000 | ||
147 | -- altervative value for FLT_MIN: 1.17549435e-38F | ||
148 | ["1.1754943508222875081e-38"] = "00800000", | ||
149 | -- FLT_MAX, exponent=FE (254), mantissa=7FFFFF | ||
150 | -- altervative value for FLT_MAX: 3.402823466e+38F | ||
151 | ["3.4028234663852885982e+38"] = "7F7FFFFF", | ||
152 | --]] | ||
153 | --[""] = "", | ||
154 | } | ||
155 | |||
156 | local success = true | ||
157 | print("Testing luaU:from_double():") | ||
158 | for i, v in pairs(table_double) do | ||
159 | local test_value | ||
160 | if not string.find(i, "%d") then | ||
161 | test_value = _G[i] | ||
162 | else | ||
163 | test_value = tonumber(i) | ||
164 | end | ||
165 | local expected = v | ||
166 | if test_double(test_value, expected) then | ||
167 | success = false | ||
168 | end | ||
169 | end | ||
170 | if success then | ||
171 | print("All test numbers passed okay.\n") | ||
172 | else | ||
173 | print("There were one or more failures.\n") | ||
174 | end | ||