tests: Add support for checking the consumed part of the input

Sun, 21 Jun 2009 23:19:56 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Sun, 21 Jun 2009 23:19:56 +0100
changeset 18
d6f0c12c152a
parent 17
3a7672943895
child 19
0cdb35f96cb6

tests: Add support for checking the consumed part of the input

tests.lua file | annotate | diff | comparison | revisions
--- a/tests.lua	Sun Jun 21 23:12:23 2009 +0100
+++ b/tests.lua	Sun Jun 21 23:19:56 2009 +0100
@@ -6,12 +6,16 @@
 
 local all_ok = true;
 
-local function check(input, output)
-	local ret = when(input, 0);
+local function check(input, output, e_start, e_finish)
+	local ret, start, finish = when(input, 0);
 	if ret ~= output then
 		print("FAIL: "..input.." [produces "..ret.."/"..os.date("!%c", ret).."]");
 		all_ok = false;
 		return false;
+	elseif (e_start and e_finish) and (start ~= e_start or finish ~= e_finish) then
+		print("FAIL: "..input.." [uses "..start..","..finish.." instead of "..e_start..","..e_finish.."]");
+		all_ok = false;
+		return false;
 	end
 end
 

mercurial