diff options
author | David Walter Seikel | 2014-04-21 20:59:39 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-04-21 20:59:39 +1000 |
commit | 9621add2918cc4943e6693b74ae85d51dd264fcf (patch) | |
tree | fff1edf2c69d7a08a0e12885eecc9b96ed847a6a /LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_lparser_mk3_2.lua | |
parent | LuaSL_test's window doesn't need to be so huge. (diff) | |
download | SledjHamr-9621add2918cc4943e6693b74ae85d51dd264fcf.zip SledjHamr-9621add2918cc4943e6693b74ae85d51dd264fcf.tar.gz SledjHamr-9621add2918cc4943e6693b74ae85d51dd264fcf.tar.bz2 SledjHamr-9621add2918cc4943e6693b74ae85d51dd264fcf.tar.xz |
We don't need the testlua directory any more.
Diffstat (limited to 'LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_lparser_mk3_2.lua')
-rw-r--r-- | LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_lparser_mk3_2.lua | 158 |
1 files changed, 0 insertions, 158 deletions
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_lparser_mk3_2.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_lparser_mk3_2.lua deleted file mode 100644 index 957ee22..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_lparser_mk3_2.lua +++ /dev/null | |||
@@ -1,158 +0,0 @@ | |||
1 | --[[-------------------------------------------------------------------- | ||
2 | |||
3 | test_lparser_mk3_2.lua | ||
4 | Test for lparser_mk3.lua, using the test case file | ||
5 | This file is part of Yueliang. | ||
6 | |||
7 | Copyright (c) 2006-2008 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 | -- * unlike the equivalent in the orig-5.0.3/ directory, this version | ||
18 | -- tests only parsing, lparser_mk3 cannot generate binary chunks | ||
19 | -- * the test cases are in the test_lua directory (test_parser-5.0.lua) | ||
20 | ----------------------------------------------------------------------]] | ||
21 | |||
22 | -- * true if you want an output of all failure cases in native Lua, | ||
23 | -- for checking whether test cases fail where you intend them to | ||
24 | local DEBUG_FAILS = false | ||
25 | |||
26 | ------------------------------------------------------------------------ | ||
27 | -- test the whole kaboodle | ||
28 | ------------------------------------------------------------------------ | ||
29 | |||
30 | local lex_init = require("../llex_mk3") | ||
31 | local parser_init = require("../lparser_mk3") | ||
32 | |||
33 | ------------------------------------------------------------------------ | ||
34 | -- load test cases | ||
35 | ------------------------------------------------------------------------ | ||
36 | |||
37 | require("../../test_lua/test_parser-5.0") | ||
38 | |||
39 | local test, expect, heading = {}, {}, {} | ||
40 | local total, total_pass, total_fail = 0, 0, 0 | ||
41 | |||
42 | for ln in string.gfind(tests_source, "([^\n]*)\n") do | ||
43 | if string.find(ln, "^%s*%-%-") then | ||
44 | -- comment, ignore | ||
45 | else | ||
46 | local m, _, head = string.find(ln, "^%s*(TESTS:%s*.*)$") | ||
47 | if m then | ||
48 | heading[total + 1] = head -- informational heading | ||
49 | else | ||
50 | total = total + 1 | ||
51 | local n, _, flag = string.find(ln, "%s*%-%-%s*FAIL%s*$") | ||
52 | if n then -- FAIL test case | ||
53 | ln = string.sub(ln, 1, n - 1) -- remove comment | ||
54 | expect[total] = "FAIL" | ||
55 | total_fail = total_fail + 1 | ||
56 | else -- PASS test case | ||
57 | expect[total] = "PASS" | ||
58 | total_pass = total_pass + 1 | ||
59 | end--n | ||
60 | test[total] = ln | ||
61 | end--m | ||
62 | end--ln | ||
63 | end--for | ||
64 | |||
65 | print("Tests loaded: "..total.." (total), " | ||
66 | ..total_pass.." (passes), " | ||
67 | ..total_fail.." (fails)") | ||
68 | |||
69 | ------------------------------------------------------------------------ | ||
70 | -- verify test cases using native Lua | ||
71 | ------------------------------------------------------------------------ | ||
72 | |||
73 | local last_head = "TESTS: no heading yet" | ||
74 | for i = 1, total do | ||
75 | local test_case, expected, head = test[i], expect[i], heading[i] | ||
76 | -- show progress | ||
77 | if head then | ||
78 | last_head = head | ||
79 | if DEBUG_FAILS then print("\n"..head.."\n") end | ||
80 | end | ||
81 | ------------------------------------------------------------------ | ||
82 | -- perform test | ||
83 | local f, err = loadstring(test_case) | ||
84 | -- look at outcome | ||
85 | ------------------------------------------------------------------ | ||
86 | if f then-- actual PASS | ||
87 | if expected == "FAIL" then | ||
88 | print("\nVerified as PASS but expected to FAIL".. | ||
89 | "\n-------------------------------------") | ||
90 | print("Lastest heading: "..last_head) | ||
91 | print("TEST: "..test_case) | ||
92 | os.exit() | ||
93 | end | ||
94 | ------------------------------------------------------------------ | ||
95 | else-- actual FAIL | ||
96 | if expected == "PASS" then | ||
97 | print("\nVerified as FAIL but expected to PASS".. | ||
98 | "\n-------------------------------------") | ||
99 | print("Lastest heading: "..last_head) | ||
100 | print("TEST: "..test_case) | ||
101 | print("ERROR: "..err) | ||
102 | os.exit() | ||
103 | end | ||
104 | if DEBUG_FAILS then | ||
105 | print("TEST: "..test_case) | ||
106 | print("ERROR: "..err.."\n") | ||
107 | end | ||
108 | ------------------------------------------------------------------ | ||
109 | end--f | ||
110 | end--for | ||
111 | |||
112 | print("Test cases verified using native Lua, no anomalies.") | ||
113 | |||
114 | ------------------------------------------------------------------------ | ||
115 | -- test using Yueliang front end | ||
116 | ------------------------------------------------------------------------ | ||
117 | |||
118 | local last_head = "TESTS: no heading yet" | ||
119 | for i = 1, total do | ||
120 | local test_case, expected, head = test[i], expect[i], heading[i] | ||
121 | -- show progress | ||
122 | if head then last_head = head end | ||
123 | ------------------------------------------------------------------ | ||
124 | -- perform test | ||
125 | luaX = lex_init(test_case, "=test_sample") | ||
126 | luaY = parser_init(luaX) | ||
127 | |||
128 | local status, func = pcall(luaY.parser, luaY) | ||
129 | -- look at outcome | ||
130 | ------------------------------------------------------------------ | ||
131 | if status then-- actual PASS | ||
132 | if expected == "FAIL" then | ||
133 | print("\nTested as PASS but expected to FAIL".. | ||
134 | "\n-----------------------------------") | ||
135 | print("Lastest heading: "..last_head) | ||
136 | print("TEST: "..test_case) | ||
137 | os.exit() | ||
138 | end | ||
139 | ------------------------------------------------------------------ | ||
140 | else-- actual FAIL | ||
141 | if expected == "PASS" then | ||
142 | print("\nTested as FAIL but expected to PASS".. | ||
143 | "\n-----------------------------------") | ||
144 | print("Lastest heading: "..last_head) | ||
145 | print("TEST: "..test_case) | ||
146 | os.exit() | ||
147 | else | ||
148 | io.stdout:write("-") | ||
149 | end | ||
150 | ------------------------------------------------------------------ | ||
151 | end--status | ||
152 | io.stdout:write("\rTesting ["..i.."]...") | ||
153 | end--for | ||
154 | print(" done.") | ||
155 | |||
156 | print("Test cases run on Yueliang, no anomalies.") | ||
157 | |||
158 | -- end | ||