From 9621add2918cc4943e6693b74ae85d51dd264fcf Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Mon, 21 Apr 2014 20:59:39 +1000 Subject: We don't need the testlua directory any more. --- .../yueliang-0.4.1/orig-5.0.3/test/bench_llex.lua | 99 ---- .../yueliang-0.4.1/orig-5.0.3/test/sample.lua | 3 - .../yueliang-0.4.1/orig-5.0.3/test/test_ldump.lua | 98 ---- .../yueliang-0.4.1/orig-5.0.3/test/test_llex.lua | 504 --------------------- .../orig-5.0.3/test/test_lparser.lua | 60 --- .../orig-5.0.3/test/test_lparser2.lua | 202 --------- .../yueliang-0.4.1/orig-5.0.3/test/test_lzio.lua | 55 --- .../yueliang-0.4.1/orig-5.0.3/test/test_number.lua | 174 ------- 8 files changed, 1195 deletions(-) delete mode 100644 LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/bench_llex.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/sample.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_ldump.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_llex.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_lparser.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_lparser2.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_lzio.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_number.lua (limited to 'LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test') diff --git a/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/bench_llex.lua b/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/bench_llex.lua deleted file mode 100644 index 0c9403e..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/bench_llex.lua +++ /dev/null @@ -1,99 +0,0 @@ ---[[-------------------------------------------------------------------- - - bench_llex.lua - Benchmark test for llex.lua - This file is part of Yueliang. - - Copyright (c) 2006 Kein-Hong Man - The COPYRIGHT file describes the conditions - under which this software may be distributed. - - See the ChangeLog for more information. - -----------------------------------------------------------------------]] - -require("../lzio") -require("../llex") -luaX:init() - ------------------------------------------------------------------------- --- load in a standard set of sample files --- * file set is 5.0.3 front end set sans luac.lua ------------------------------------------------------------------------- - -local fileset, totalsize = {}, 0 -for fn in string.gfind([[ -../lcode.lua -../ldump.lua -../llex.lua -../lopcodes.lua -../lparser.lua -../lzio.lua -]], "%S+") do - table.insert(fileset, fn) -end - -for i = 1, table.getn(fileset) do - local fn = fileset[i] - local inf = io.open(fn, "rb") - if not inf then - error("failed to open "..fn.." for reading") - end - local data = inf:read("*a") - local data_sz = string.len(data) - inf:close() - if not data or data_sz == 0 then - error("failed to read data from "..fn.." or file is zero-length") - end - totalsize = totalsize + data_sz - fileset[i] = data -end - ------------------------------------------------------------------------- --- benchmark tester ------------------------------------------------------------------------- - -local DURATION = 5 -- how long the benchmark should run - -local L = {} -- LuaState -local LS = {} -- LexState - -local time = os.time -local lexedsize = 0 -local tnow, elapsed = time(), 0 - -while time() == tnow do end -- wait for second to click over -tnow = time() - -while true do - for i = 1, table.getn(fileset) do - ------------------------------------------------------------ - local chunk = fileset[i] - local z = luaZ:init(luaZ:make_getS(chunk), nil, "=string") - luaX:setinput(L, LS, z, z.name) - while true do - LS.t.token = luaX:lex(LS, LS.t) - local tok, seminfo = LS.t.token, LS.t.seminfo - if tok == "TK_EOS" then break end - end - ------------------------------------------------------------ - lexedsize = lexedsize + string.len(chunk) - if time() > tnow then - tnow = time() - elapsed = elapsed + 1 - if elapsed >= DURATION then - -- report performance of lexer - lexedsize = lexedsize / 1024 - local speed = lexedsize / DURATION - print("Lexer performance:") - print("Size of data lexed (KB): "..string.format("%.1f", lexedsize)) - print("Speed of lexer (KB/s): "..string.format("%.1f", speed)) - -- repeat until user breaks program - elapsed = 0 - end - end - ------------------------------------------------------------ - end--for -end--while - --- end of script diff --git a/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/sample.lua b/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/sample.lua deleted file mode 100644 index dc6eaee..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/sample.lua +++ /dev/null @@ -1,3 +0,0 @@ -local a = 47 -local b = "hello, world!" -print(a, b) diff --git a/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_ldump.lua b/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_ldump.lua deleted file mode 100644 index d867688..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_ldump.lua +++ /dev/null @@ -1,98 +0,0 @@ ---[[-------------------------------------------------------------------- - - test_ldump.lua - Test for ldump.lua - This file is part of Yueliang. - - Copyright (c) 2005 Kein-Hong Man - The COPYRIGHT file describes the conditions - under which this software may be distributed. - - See the ChangeLog for more information. - -----------------------------------------------------------------------]] - ------------------------------------------------------------------------- --- test dump chunkwriter style ------------------------------------------------------------------------- - -require("../lopcodes") -require("../ldump") - --- Original typedef: ---int (*lua_Chunkwriter) (lua_State *L, const void* p, size_t sz, void* ud); - -local MyWriter, MyBuff = luaU:make_setS() -if not MyWriter then - error("failed to initialize using make_setS") -end -MyWriter("hello, ", MyBuff) -MyWriter("world!", MyBuff) -print(MyBuff.data) - -local MyWriter, MyBuff = luaU:make_setF("try.txt") -if not MyWriter then - error("failed to initialize using make_setF") -end -MyWriter("hello, ", MyBuff) -MyWriter("world!", MyBuff) -MyWriter(nil, MyBuff) - ------------------------------------------------------------------------- --- test output of a function prototype --- * data can be copied from a ChunkSpy listing output ------------------------------------------------------------------------- --- local a = 47 --- local b = "hello, world!" --- print(a, b) ------------------------------------------------------------------------- - -local F = {} -F.source = "sample.lua" -F.lineDefined = 0 -F.nups = 0 -F.numparams = 0 -F.is_vararg = 0 -F.maxstacksize = 5 -F.sizelineinfo = 7 -F.lineinfo = {} -F.lineinfo[0] = 1 -F.lineinfo[1] = 2 -F.lineinfo[2] = 3 -F.lineinfo[3] = 3 -F.lineinfo[4] = 3 -F.lineinfo[5] = 3 -F.lineinfo[6] = 3 -F.sizelocvars = 2 -F.locvars = {} -F.locvars[0] = { varname = "a", startpc = 1, endpc = 6 } -F.locvars[1] = { varname = "b", startpc = 2, endpc = 6 } -F.sizeupvalues = 0 -F.upvalues = {} -F.sizek = 3 -F.k = {} -F.k[0] = { value = 47 } -F.k[1] = { value = "hello, world!" } -F.k[2] = { value = "print" } -F.sizep = 0 -F.p = {} -F.sizecode = 7 -F.code = {} -F.code[0] = { OP = 1, A = 0, Bx = 0 } -F.code[1] = { OP = 1, A = 1, Bx = 1 } -F.code[2] = { OP = 5, A = 2, Bx = 2 } -F.code[3] = { OP = 0, A = 3, B = 0, C = 0 } -F.code[4] = { OP = 0, A = 4, B = 1, C = 0 } -F.code[5] = { OP = 25, A = 2, B = 3, C = 1 } -F.code[6] = { OP = 27, A = 0, B = 1, C = 0 } - -local L = {} ---[[ -local Writer, Buff = luaU:make_setS() -luaU:dump(L, F, Writer, Buff) -for i = 1, string.len(Buff.data) do - io.stdout:write(string.byte(string.sub(Buff.data, i, i)).." ") -end ---]] -local Writer, Buff = luaU:make_setF("try.out") -luaU:dump(L, F, Writer, Buff) diff --git a/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_llex.lua b/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_llex.lua deleted file mode 100644 index 6bc834d..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_llex.lua +++ /dev/null @@ -1,504 +0,0 @@ ---[[-------------------------------------------------------------------- - - test_llex.lua - Test for llex.lua - This file is part of Yueliang. - - Copyright (c) 2005-2006 Kein-Hong Man - The COPYRIGHT file describes the conditions - under which this software may be distributed. - - See the ChangeLog for more information. - -----------------------------------------------------------------------]] - ------------------------------------------------------------------------- --- if BRIEF is not set to false, auto-test will silently succeed ------------------------------------------------------------------------- -BRIEF = true -- if set to true, messages are less verbose - -require("../lzio") -require("../llex") -luaX:init() - ------------------------------------------------------------------------- --- simple manual tests ------------------------------------------------------------------------- - ---[[ -local L = {} -- LuaState -local LS = {} -- LexState - -local function dump(z) - luaX:setinput(L, LS, z, z.name) - while true do - LS.t.token = luaX:lex(LS, LS.t) - local tok, seminfo = LS.t.token, LS.t.seminfo - if tok == "TK_NAME" then - seminfo = " "..seminfo - elseif tok == "TK_NUMBER" then - seminfo = " "..seminfo - elseif tok == "TK_STRING" then - seminfo = " '"..seminfo.."'" - else - seminfo = "" - end - io.stdout:write(tok..seminfo.."\n") - if tok == "TK_EOS" then break end - end -end - -local function try_string(chunk) - dump(luaZ:init(luaZ:make_getS(chunk), nil, "=string")) -end -local function try_file(filename) - dump(luaZ:init(luaZ:make_getF(filename), nil, filename)) -end - -z = try_string("local c = luaZ:zgetc(z)") -z = try_file("test_lzio.lua") -z = try_file("test_llex.lua") -os.exit() ---]] - ------------------------------------------------------------------------- --- auto-testing of simple test cases to validate lexer behaviour: --- * NOTE coverage has not been checked; not comprehensive --- * only test cases with non-empty comments are processed --- * if no result, then the output is displayed for manual decision --- (output may be used to set expected success or fail text) --- * cases expected to be successful may be a partial match --- * cases expected to fail may also be a partial match ------------------------------------------------------------------------- - --- [[ -local function auto_test() - local PASS, FAIL = true, false - ------------------------------------------------------------------ - -- table of test cases - ------------------------------------------------------------------ - local test_cases = - { - ------------------------------------------------------------- - --{ "comment", -- comment about the test - -- "chunk", -- chunk to test - -- PASS, -- PASS or FAIL outcome - -- "output", -- output to compare against - --}, - ------------------------------------------------------------- - { "empty chunk string, test EOS", - "", - PASS, "1 TK_EOS", - }, - ------------------------------------------------------------- - { "line number counting", - "\n\n\r\n", - PASS, "4 TK_EOS", - }, - ------------------------------------------------------------- - { "various whitespaces", - " \n\t\t\n \t \t \n\n", - PASS, "5 TK_EOS", - }, - ------------------------------------------------------------- - { "short comment ending in EOS", - "-- moo moo", - PASS, "1 TK_EOS", - }, - ------------------------------------------------------------- - { "short comment ending in newline", - "-- moo moo\n", - PASS, "2 TK_EOS", - }, - ------------------------------------------------------------- - { "several lines of short comments", - "--moo\n-- moo moo\n\n--\tmoo\n", - PASS, "5 TK_EOS", - }, - ------------------------------------------------------------- - { "basic block comment", - "--[[bovine]]", - PASS, "1 TK_EOS", - }, - ------------------------------------------------------------- - { "unterminated block comment 1", - "--[[bovine", - FAIL, ":1: unfinished long comment near `'", - }, - ------------------------------------------------------------- - { "unterminated block comment 2", - "--[[bovine]", - FAIL, ":1: unfinished long comment near `'", - }, - ------------------------------------------------------------- - { "unterminated block comment 3", - "--[[bovine\nmoo moo\nwoof", - FAIL, ":3: unfinished long comment near `'", - }, - ------------------------------------------------------------- - { "basic long string", - "\n[[bovine]]\n", - PASS, "2 TK_STRING = bovine\n3 TK_EOS", - }, - ------------------------------------------------------------- - { "first newline consumed in long string", - "[[\nmoo]]", - PASS, "2 TK_STRING = moo\n2 TK_EOS", - }, - ------------------------------------------------------------- - { "multiline long string", - "[[moo\nmoo moo\n]]", - PASS, "3 TK_STRING = moo\nmoo moo\n\n3 TK_EOS", - }, - ------------------------------------------------------------- - { "unterminated long string 1", - "\n[[\nbovine", - FAIL, ":3: unfinished long string near `'", - }, - ------------------------------------------------------------- - { "unterminated long string 2", - "[[bovine]", - FAIL, ":1: unfinished long string near `'", - }, - ------------------------------------------------------------- - { "unterminated long string 3", - "[[[[ \n", - FAIL, ":2: unfinished long string near `'", - }, - ------------------------------------------------------------- - { "nested long string 1", - "[[moo[[moo]]moo]]", - PASS, "moo[[moo]]moo", - }, - ------------------------------------------------------------- - { "nested long string 2", - "[[moo[[moo[[[[]]]]moo]]moo]]", - PASS, "moo[[moo[[[[]]]]moo]]moo", - }, - ------------------------------------------------------------- - { "nested long string 3", - "[[[[[[]]]][[[[]]]]]]", - PASS, "[[[[]]]][[[[]]]]", - }, - ------------------------------------------------------------- - { "brackets in long strings 1", - "[[moo[moo]]", - PASS, "moo[moo", - }, - ------------------------------------------------------------- - { "brackets in long strings 2", - "[[moo[[moo]moo]]moo]]", - PASS, "moo[[moo]moo]]moo", - }, - ------------------------------------------------------------- - { "unprocessed escapes in long strings", - [[ [[\a\b\f\n\r\t\v\123]] ]], - PASS, [[\a\b\f\n\r\t\v\123]], - }, - ------------------------------------------------------------- - { "unbalanced long string", - "[[moo]]moo]]", - PASS, "1 TK_STRING = moo\n1 TK_NAME = moo\n1 CHAR = ']'\n1 CHAR = ']'\n1 TK_EOS", - }, - ------------------------------------------------------------- - { "keywords 1", - "and break do else", - PASS, "1 TK_AND\n1 TK_BREAK\n1 TK_DO\n1 TK_ELSE\n1 TK_EOS", - }, - ------------------------------------------------------------- - { "keywords 2", - "elseif end false for", - PASS, "1 TK_ELSEIF\n1 TK_END\n1 TK_FALSE\n1 TK_FOR\n1 TK_EOS", - }, - ------------------------------------------------------------- - { "keywords 3", - "function if in local nil", - PASS, "1 TK_FUNCTION\n1 TK_IF\n1 TK_IN\n1 TK_LOCAL\n1 TK_NIL\n1 TK_EOS", - }, - ------------------------------------------------------------- - { "keywords 4", - "not or repeat return", - PASS, "1 TK_NOT\n1 TK_OR\n1 TK_REPEAT\n1 TK_RETURN\n1 TK_EOS", - }, - ------------------------------------------------------------- - { "keywords 5", - "then true until while", - PASS, "1 TK_THEN\n1 TK_TRUE\n1 TK_UNTIL\n1 TK_WHILE\n1 TK_EOS", - }, - ------------------------------------------------------------- - { "concat and dots", - ".. ...", - PASS, "1 TK_CONCAT\n1 TK_DOTS\n1 TK_EOS", - }, - ------------------------------------------------------------- - { "shbang handling 1", - "#blahblah", - PASS, "1 TK_EOS", - }, - ------------------------------------------------------------- - { "shbang handling 2", - "#blahblah\nmoo moo\n", - PASS, "2 TK_NAME = moo\n2 TK_NAME = moo\n3 TK_EOS", - }, - ------------------------------------------------------------- - { "empty string", - [['']], - PASS, "1 TK_STRING = \n1 TK_EOS", - }, - ------------------------------------------------------------- - { "single-quoted string", - [['bovine']], - PASS, "1 TK_STRING = bovine\n1 TK_EOS", - }, - ------------------------------------------------------------- - { "double-quoted string", - [["bovine"]], - PASS, "1 TK_STRING = bovine\n1 TK_EOS", - }, - ------------------------------------------------------------- - { "unterminated string 1", - [['moo ]], - FAIL, ":1: unfinished string near `'", - }, - ------------------------------------------------------------- - { "unterminated string 2", - [["moo \n]], - FAIL, ":1: unfinished string near `'", - }, - ------------------------------------------------------------- - { "escaped newline in string, line number counted", - "\"moo\\\nmoo\\\nmoo\"", - PASS, "3 TK_STRING = moo\nmoo\nmoo\n3 TK_EOS", - }, - ------------------------------------------------------------- - { "escaped characters in string 1", - [["moo\amoo"]], - PASS, "1 TK_STRING = moo\amoo", - }, - ------------------------------------------------------------- - { "escaped characters in string 2", - [["moo\bmoo"]], - PASS, "1 TK_STRING = moo\bmoo", - }, - ------------------------------------------------------------- - { "escaped characters in string 3", - [["moo\f\n\r\t\vmoo"]], - PASS, "1 TK_STRING = moo\f\n\r\t\vmoo", - }, - ------------------------------------------------------------- - { "escaped characters in string 4", - [["\\ \" \' \? \[ \]"]], - PASS, "1 TK_STRING = \\ \" \' \? \[ \]", - }, - ------------------------------------------------------------- - { "escaped characters in string 5", - [["\z \k \: \;"]], - PASS, "1 TK_STRING = z k : ;", - }, - ------------------------------------------------------------- - { "escaped characters in string 6", - [["\8 \65 \160 \180K \097097"]], - PASS, "1 TK_STRING = \8 \65 \160 \180K \097097\n", - }, - ------------------------------------------------------------- - { "escaped characters in string 7", - [["\666"]], - FAIL, ":1: escape sequence too large near `\"'", - }, - ------------------------------------------------------------- - { "simple numbers", - "123 123+", - PASS, "1 TK_NUMBER = 123\n1 TK_NUMBER = 123\n1 CHAR = '+'\n1 TK_EOS", - }, - ------------------------------------------------------------- - { "longer numbers", - "1234567890 12345678901234567890", - PASS, "1 TK_NUMBER = 1234567890\n1 TK_NUMBER = 1.2345678901235e+19\n", - }, - ------------------------------------------------------------- - { "fractional numbers", - ".123 .12345678901234567890", - PASS, "1 TK_NUMBER = 0.123\n1 TK_NUMBER = 0.12345678901235\n", - }, - ------------------------------------------------------------- - { "more numbers with decimal points", - "12345.67890 1.1.", - PASS, "1 TK_NUMBER = 12345.6789\n1 TK_NUMBER = 1.1\n1 CHAR = '.'\n", - }, - ------------------------------------------------------------- - { "double decimal points", - ".1.1", - FAIL, ":1: malformed number near `.1.1'", - }, - ------------------------------------------------------------- - { "double dots within numbers", - "1..1", - FAIL, ":1: ambiguous syntax (decimal point x string concatenation) near `1..'", - }, - ------------------------------------------------------------- - { "incomplete exponential numbers", - "123e", - FAIL, ":1: malformed number near `123e'", - }, - ------------------------------------------------------------- - { "exponential numbers 1", - "1234e5 1234e5.", - PASS, "1 TK_NUMBER = 123400000\n1 TK_NUMBER = 123400000\n1 CHAR = '.'", - }, - ------------------------------------------------------------- - { "exponential numbers 2", - "1234e56 1.23e123", - PASS, "1 TK_NUMBER = 1.234e+59\n1 TK_NUMBER = 1.23e+123\n", - }, - ------------------------------------------------------------- - { "exponential numbers 3", - "12.34e+", - FAIL, ":1: malformed number near `12.34e+'", - }, - ------------------------------------------------------------- - { "exponential numbers 4", - "12.34e+5 123.4e-5 1234.E+5", - PASS, "1 TK_NUMBER = 1234000\n1 TK_NUMBER = 0.001234\n1 TK_NUMBER = 123400000\n", - }, - ------------------------------------------------------------- - { "single character symbols 1", - "= > < ~", - PASS, "1 CHAR = '='\n1 CHAR = '>'\n1 CHAR = '<'\n1 CHAR = '~'\n", - }, - ------------------------------------------------------------- - { "double character symbols", - "== >= <= ~=", - PASS, "1 TK_EQ\n1 TK_GE\n1 TK_LE\n1 TK_NE\n", - }, - ------------------------------------------------------------- - { "simple identifiers", - "abc ABC", - PASS, "1 TK_NAME = abc\n1 TK_NAME = ABC\n1 TK_EOS", - }, - ------------------------------------------------------------- - { "more identifiers", - "_abc _ABC", - PASS, "1 TK_NAME = _abc\n1 TK_NAME = _ABC\n1 TK_EOS", - }, - ------------------------------------------------------------- - { "still more identifiers", - "_aB_ _123", - PASS, "1 TK_NAME = _aB_\n1 TK_NAME = _123\n1 TK_EOS", - }, - ------------------------------------------------------------- - { "invalid control character", - "\4", - FAIL, ":1: invalid control char near `char(4)'", - }, - ------------------------------------------------------------- - { "single character symbols 2", - "` ! @ $ %", - PASS, "1 CHAR = '`'\n1 CHAR = '!'\n1 CHAR = '@'\n1 CHAR = '$'\n1 CHAR = '%'\n", - }, - ------------------------------------------------------------- - { "single character symbols 3", - "^ & * ( )", - PASS, "1 CHAR = '^'\n1 CHAR = '&'\n1 CHAR = '*'\n1 CHAR = '('\n1 CHAR = ')'\n", - }, - ------------------------------------------------------------- - { "single character symbols 4", - "_ - + \\ |", - PASS, "1 TK_NAME = _\n1 CHAR = '-'\n1 CHAR = '+'\n1 CHAR = '\\'\n1 CHAR = '|'\n", - }, - ------------------------------------------------------------- - { "single character symbols 5", - "{ } [ ] :", - PASS, "1 CHAR = '{'\n1 CHAR = '}'\n1 CHAR = '['\n1 CHAR = ']'\n1 CHAR = ':'\n", - }, - ------------------------------------------------------------- - { "single character symbols 6", - "; , . / ?", - PASS, "1 CHAR = ';'\n1 CHAR = ','\n1 CHAR = '.'\n1 CHAR = '/'\n1 CHAR = '?'\n", - }, - ------------------------------------------------------------- - } - ------------------------------------------------------------------ - -- perform a test case - ------------------------------------------------------------------ - function do_test_case(count, test_case) - if comment == "" then return end -- skip empty entries - local comment, chunk, outcome, matcher = unpack(test_case) - local result = PASS - local output = "" - -- initialize lexer - local L, LS = {}, {} - local z = luaZ:init(luaZ:make_getS(chunk), nil, "=test") - luaX:setinput(L, LS, z, z.name) - -- lexer test loop - repeat - -- protected call - local status, token = pcall(luaX.lex, luaX, LS, LS.t) - LS.t.token = token - output = output..LS.linenumber.." " - if status then - -- successful call - if string.len(token) > 1 then - if token == "TK_NAME" - or token == "TK_NUMBER" - or token == "TK_STRING" then - token = token.." = "..LS.t.seminfo - end - elseif string.byte(token) >= 32 then -- displayable chars - token = "CHAR = '"..token.."'" - else -- control characters - token = "CHAR = (".. string.byte(token)..")" - end - output = output..token.."\n" - else - -- failed call - output = output..token -- token is the error message - result = FAIL - break - end - until LS.t.token == "TK_EOS" - -- decision making and reporting - local head = "Test "..count..": "..comment - if matcher == "" then - -- nothing to check against, display for manual check - print(head.."\nMANUAL please check manually".. - "\n--chunk---------------------------------\n"..chunk.. - "\n--actual--------------------------------\n"..output.. - "\n\n") - return - else - if outcome == PASS then - -- success expected, may be a partial match - if string.find(output, matcher, 1, 1) and result == PASS then - if not BRIEF then print(head.."\nOK expected success\n") end - return - end - else - -- failure expected, may be a partial match - if string.find(output, matcher, 1, 1) and result == FAIL then - if not BRIEF then print(head.."\nOK expected failure\n") end - return - end - end - -- failed because of unmatched string or boolean result - local function passfail(status) - if status == PASS then return "PASS" else return "FAIL" end - end - print(head.." *FAILED*".. - "\noutcome="..passfail(outcome).. - "\nactual= "..passfail(result).. - "\n--chunk---------------------------------\n"..chunk.. - "\n--expected------------------------------\n"..matcher.. - "\n--actual--------------------------------\n"..output.. - "\n\n") - end - end - ------------------------------------------------------------------ - -- perform auto testing - ------------------------------------------------------------------ - for i,test_case in ipairs(test_cases) do - do_test_case(i, test_case) - end -end - -auto_test() ---]] diff --git a/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_lparser.lua b/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_lparser.lua deleted file mode 100644 index b9400cc..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_lparser.lua +++ /dev/null @@ -1,60 +0,0 @@ ---[[-------------------------------------------------------------------- - - test_lparser.lua - Test for lparser.lua - This file is part of Yueliang. - - Copyright (c) 2005 Kein-Hong Man - The COPYRIGHT file describes the conditions - under which this software may be distributed. - - See the ChangeLog for more information. - -----------------------------------------------------------------------]] - ------------------------------------------------------------------------- --- test the whole kaboodle ------------------------------------------------------------------------- - -require("../lzio") -require("../llex") -require("../lopcodes") -require("../ldump") -require("../lcode") -require("../lparser") - -function lua_assert(test) - if not test then error("assertion failed!") end -end - -luaX:init() - ------------------------------------------------------------------------- --- try 1 ------------------------------------------------------------------------- - -local zio = luaZ:init(luaZ:make_getS("local a = 1"), nil, "=string") -local LuaState = {} -local Func = luaY:parser(LuaState, zio, nil) - ---[[ -for i, v in Func do - if type(v) == "string" or type(v) == "number" then - print(i, v) - elseif type(v) == "table" then - print(i, "TABLE") - end -end ---]] - -local Writer, Buff = luaU:make_setF("parse1.out") -luaU:dump(LuaState, Func, Writer, Buff) - ------------------------------------------------------------------------- --- try 2 ------------------------------------------------------------------------- - -zio = luaZ:init(luaZ:make_getF("sample.lua"), nil, "@sample.lua") -Func = luaY:parser(LuaState, zio, nil) -Writer, Buff = luaU:make_setF("parse2.out") -luaU:dump(LuaState, Func, Writer, Buff) diff --git a/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_lparser2.lua b/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_lparser2.lua deleted file mode 100644 index b912e68..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_lparser2.lua +++ /dev/null @@ -1,202 +0,0 @@ ---[[-------------------------------------------------------------------- - - test_lparser2.lua - Test for lparser.lua, using the test case file - This file is part of Yueliang. - - Copyright (c) 2006 Kein-Hong Man - The COPYRIGHT file describes the conditions - under which this software may be distributed. - - See the ChangeLog for more information. - -----------------------------------------------------------------------]] - ---[[-------------------------------------------------------------------- --- Notes: --- * the test cases are in the test_lua directory (test_parser-5.0.lua) -----------------------------------------------------------------------]] - --- * true if you want an output of all failure cases in native Lua, --- for checking whether test cases fail where you intend them to -local DEBUG_FAILS = false - ------------------------------------------------------------------------- --- test the whole kaboodle ------------------------------------------------------------------------- - -require("../lzio") -require("../llex") -require("../lopcodes") -require("../ldump") -require("../lcode") -require("../lparser") - -function lua_assert(test) - if not test then error("assertion failed!") end -end - -luaX:init() - ------------------------------------------------------------------------- --- load test cases ------------------------------------------------------------------------- - -require("../../test_lua/test_parser-5.0") - -local test, expect, heading = {}, {}, {} -local total, total_pass, total_fail = 0, 0, 0 - -for ln in string.gfind(tests_source, "([^\n]*)\n") do - if string.find(ln, "^%s*%-%-") then - -- comment, ignore - else - local m, _, head = string.find(ln, "^%s*(TESTS:%s*.*)$") - if m then - heading[total + 1] = head -- informational heading - else - total = total + 1 - local n, _, flag = string.find(ln, "%s*%-%-%s*FAIL%s*$") - if n then -- FAIL test case - ln = string.sub(ln, 1, n - 1) -- remove comment - expect[total] = "FAIL" - total_fail = total_fail + 1 - else -- PASS test case - expect[total] = "PASS" - total_pass = total_pass + 1 - end--n - test[total] = ln - end--m - end--ln -end--for - -print("Tests loaded: "..total.." (total), " - ..total_pass.." (passes), " - ..total_fail.." (fails)") - ------------------------------------------------------------------------- --- verify test cases using native Lua ------------------------------------------------------------------------- - -local last_head = "TESTS: no heading yet" -for i = 1, total do - local test_case, expected, head = test[i], expect[i], heading[i] - -- show progress - if head then - last_head = head - if DEBUG_FAILS then print("\n"..head.."\n") end - end - ------------------------------------------------------------------ - -- perform test - local f, err = loadstring(test_case) - -- look at outcome - ------------------------------------------------------------------ - if f then-- actual PASS - if expected == "FAIL" then - print("\nVerified as PASS but expected to FAIL".. - "\n-------------------------------------") - print("Lastest heading: "..last_head) - print("TEST: "..test_case) - os.exit() - end - ------------------------------------------------------------------ - else-- actual FAIL - if expected == "PASS" then - print("\nVerified as FAIL but expected to PASS".. - "\n-------------------------------------") - print("Lastest heading: "..last_head) - print("TEST: "..test_case) - print("ERROR: "..err) - os.exit() - end - if DEBUG_FAILS then - print("TEST: "..test_case) - print("ERROR: "..err.."\n") - end - ------------------------------------------------------------------ - end--f -end--for - -print("Test cases verified using native Lua, no anomalies.") - ------------------------------------------------------------------------- --- dump binary chunks to a file if something goes wrong ------------------------------------------------------------------------- -local function Dump(data, filename) - h = io.open(filename, "wb") - if not h then error("failed to open "..filename.." for writing") end - h:write(data) - h:close() -end - ------------------------------------------------------------------------- --- test using Yueliang front end ------------------------------------------------------------------------- - -local last_head = "TESTS: no heading yet" -for i = 1, total do - local test_case, expected, head = test[i], expect[i], heading[i] - -- show progress - if head then last_head = head end - ------------------------------------------------------------------ - -- perform test - local LuaState = {} - local zio = luaZ:init(luaZ:make_getS(test_case), nil, "test") - local status, func = pcall(luaY.parser, luaY, LuaState, zio, nil) - -- look at outcome - ------------------------------------------------------------------ - if status then-- actual PASS - if expected == "PASS" then - -- actual PASS and expected PASS, so check binary chunks - local writer, buff = luaU:make_setS() - luaU:dump(LuaState, func, writer, buff) - local bc1 = buff.data -- Yueliang's output - local f = loadstring(test_case, "test") - local bc2 = string.dump(f) -- Lua's output - local die - -- compare outputs - if string.len(bc1) ~= string.len(bc2) then - Dump(bc1, "bc1.out") - Dump(bc2, "bc2.out") - die = "binary chunk sizes different" - elseif bc1 ~= bc2 then - Dump(bc1, "bc1.out") - Dump(bc2, "bc2.out") - die = "binary chunks different" - else - -- everything checks out! - end - if die then - print("\nTested PASS and expected to PASS, but chunks different".. - "\n------------------------------------------------------") - print("Reason: "..die) - print("Lastest heading: "..last_head) - print("TEST: "..test_case) - os.exit() - end - else-- expected FAIL - print("\nTested as PASS but expected to FAIL".. - "\n-----------------------------------") - print("Lastest heading: "..last_head) - print("TEST: "..test_case) - os.exit() - end - ------------------------------------------------------------------ - else-- actual FAIL - if expected == "PASS" then - print("\nTested as FAIL but expected to PASS".. - "\n-----------------------------------") - print("Lastest heading: "..last_head) - print("TEST: "..test_case) - print("ERROR: "..err) - os.exit() - end - ------------------------------------------------------------------ - end--status - io.stdout:write("\rTesting ["..i.."]...") -end--for -print(" done.") - -print("Test cases run on Yueliang, no anomalies.") - --- end diff --git a/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_lzio.lua b/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_lzio.lua deleted file mode 100644 index cfd3f4b..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_lzio.lua +++ /dev/null @@ -1,55 +0,0 @@ ---[[-------------------------------------------------------------------- - - test_lzio.lua - Test for lzio.lua - This file is part of Yueliang. - - Copyright (c) 2005 Kein-Hong Man - The COPYRIGHT file describes the conditions - under which this software may be distributed. - - See the ChangeLog for more information. - -----------------------------------------------------------------------]] - --- manual test for lzio.lua lua-style chunk reader - -require("../lzio") - -local z -function dump(z) - while true do - local c = luaZ:zgetc(z) - io.stdout:write("("..c..")") - if c == "EOZ" then break end - end - io.stdout:write("\n") -end - --- luaZ:make_getS or luaZ:make_getF creates a chunk reader --- luaZ:init makes a zio stream - --- [[ -z = luaZ:init(luaZ:make_getS("hello, world!"), nil, "=string") -dump(z) -z = luaZ:init(luaZ:make_getS(", world!"), "hello", "=string") -dump(z) -z = luaZ:init(luaZ:make_getS("line1\nline2\n"), "", "=string") -dump(z) -z = luaZ:init(luaZ:make_getF("test_lzio.lua"), nil, "=string") -dump(z) ---]] - --- test read beyond end of file --- bug reported by Adam429 ---[[ -z = luaZ:init(luaZ:make_getF("test_lzio.lua"), nil, "=string") -while true do - local c = luaZ:zgetc(z) - io.stdout:write("("..c..")") - if c == "EOZ" then break end -end -print(luaZ:zgetc(z)) -print(luaZ:zgetc(z)) -io.stdout:write("\n") ---]] diff --git a/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_number.lua b/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_number.lua deleted file mode 100644 index eeabecb..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_number.lua +++ /dev/null @@ -1,174 +0,0 @@ ---[[-------------------------------------------------------------------- - - test_number.lua - Test for Lua-based number conversion functions in ldump.lua - This file is part of Yueliang. - - Copyright (c) 2005-2006 Kein-Hong Man - The COPYRIGHT file describes the conditions - under which this software may be distributed. - - See the ChangeLog for more information. - -----------------------------------------------------------------------]] - ---[[-------------------------------------------------------------------- --- Notes: --- * luaU:from_int(value) does not have overflow checks, but this --- can presumably be put in for debugging purposes. --- * TODO: double conversion does not support denormals or NaNs --- * apparently 0/0 == 0/0 is false (Lua 5.0.2 on Win32/Mingw), so --- can't use to check for NaNs -----------------------------------------------------------------------]] - -require("../ldump") - ------------------------------------------------------------------------- --- convert hex string representation to a byte string --- * must have an even number of hex digits ------------------------------------------------------------------------- -local function from_hexstring(s) - local bs = "" - for i = 1, string.len(s), 2 do - local asc = tonumber(string.sub(s, i, i + 1), 16) - bs = bs..string.char(asc) - end - return bs -end - ------------------------------------------------------------------------- --- convert a byte string to a hex string representation --- * big-endian, easier to grok ------------------------------------------------------------------------- -local function to_hexstring(s) - local hs = "" - for i = string.len(s), 1, -1 do - local c = string.byte(string.sub(s, i, i)) - hs = hs..string.format("%02X", c) - end - return hs -end - ------------------------------------------------------------------------- --- tests for 32-bit signed/unsigned integer ------------------------------------------------------------------------- -local function test_int(value, expected) - local actual = to_hexstring(luaU:from_int(value)) - if not expected or expected == "" then - print(value..": "..actual) - elseif actual ~= expected then - print(value..": FAILED!\n".. - "Converted: "..actual.."\n".. - "Expected: "..expected) - return true - end - return false -end - -local table_int = { - ["0"] = "00000000", - ["1"] = "00000001", - ["256"] = "00000100", - ["-256"] = "FFFFFF00", - ["-1"] = "FFFFFFFF", - ["2147483647"] = "7FFFFFFF", -- LONG_MAX - ["-2147483648"] = "80000000", -- LONG_MIN - ["4294967295"] = "FFFFFFFF", -- ULONG_MAX - --[""] = "", -} - -local success = true -print("Testing luaU:from_int():") -for i, v in pairs(table_int) do - local test_value = tonumber(i) - local expected = v - if test_int(test_value, expected) then - success = false - end -end -if success then - print("All test numbers passed okay.\n") -else - print("There were one or more failures.\n") -end - ------------------------------------------------------------------------- --- tests for IEEE 754 64-bit double ------------------------------------------------------------------------- - -local function test_double(value, expected) - local actual = to_hexstring(luaU:from_double(value)) - if not expected or expected == "" then - print(value..": "..actual) - elseif actual ~= expected then - print(value..": FAILED!\n".. - "Converted: "..actual.."\n".. - "Expected: "..expected) - return true - end - return false -end - --- special values, see testing loop for actual lookup -Infinity = 1/0 -Infinity_neg = -1/0 - --- can't seem to do a comparison test with NaN, so leave them --- (need to check the IEEE standard on this...) -NaN = 0/0 -NaN_neg = -0/0 ---["NaN"] = "", -- 7FF8000000000000 (djgpp) ---["NaN_neg"] = "", -- FFF8000000000000 (djgpp) - -local table_double = { - -- 0 for exponent, 0 for mantissa - ["0"] = "0000000000000000", - -- 3FF is bias of 1023, so (-1)^0 * (1+0) * 2^0 - ["1"] = "3FF0000000000000", - -- BFF has sign bit on, so (-1)^1 * (1+0) * 2^0 - ["-1"] = "BFF0000000000000", - -- 3FC is bias of 1020, so (-1)^0 * (1+0) * 2^-3 - ["0.125"] = "3FC0000000000000", - ["0.250"] = "3FD0000000000000", - ["0.500"] = "3FE0000000000000", - -- 40F is bias of 1039, so (-1)^0 * (1+0) * 2^16 - ["65536"] = "40F0000000000000", - -- 7FF is bias of 2047, 0 for mantissa - ["Infinity"] = "7FF0000000000000", - -- FFF has sign bit on, 0 for mantissa - ["Infinity_neg"] = "FFF0000000000000", - -- DBL_MIN, exponent=001 ( 1), mantissa=0000000000000 - ["2.2250738585072014e-308"] = "0010000000000000", - -- DBL_MAX, exponent=7FE (2046), mantissa=FFFFFFFFFFFFF - ["1.7976931348623157e+308"] = "7FEFFFFFFFFFFFFF", ---[[ - -- * the following is for float numbers only * - -- FLT_MIN, exponent=01 ( 1), mantissa=000000 - -- altervative value for FLT_MIN: 1.17549435e-38F - ["1.1754943508222875081e-38"] = "00800000", - -- FLT_MAX, exponent=FE (254), mantissa=7FFFFF - -- altervative value for FLT_MAX: 3.402823466e+38F - ["3.4028234663852885982e+38"] = "7F7FFFFF", ---]] - --[""] = "", -} - -local success = true -print("Testing luaU:from_double():") -for i, v in pairs(table_double) do - local test_value - if not string.find(i, "%d") then - test_value = _G[i] - else - test_value = tonumber(i) - end - local expected = v - if test_double(test_value, expected) then - success = false - end -end -if success then - print("All test numbers passed okay.\n") -else - print("There were one or more failures.\n") -end -- cgit v1.1