From 4c5778e2d0adacdd71e10696b4aa31ea34f1be66 Mon Sep 17 00:00:00 2001 From: Tomas Guisasola Date: Wed, 8 Jun 2005 17:22:46 +0000 Subject: Enhancing error message when there is no connection. Better output. --- lualdap/tests/test.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lualdap/tests/test.lua b/lualdap/tests/test.lua index 034e7c9..299ed8e 100755 --- a/lualdap/tests/test.lua +++ b/lualdap/tests/test.lua @@ -6,7 +6,7 @@ -- renamed and deleted at the end. -- -- See Copyright Notice in license.html --- $Id: test.lua,v 1.13 2005-06-07 17:06:30 tomas Exp $ +-- $Id: test.lua,v 1.14 2005-06-08 17:22:46 tomas Exp $ --------------------------------------------------------------------- -- @@ -53,15 +53,16 @@ end -- checks for a value and throw an error if it is not the expected. --------------------------------------------------------------------- function assert2 (expected, value, msg) -io.write('.') if not msg then msg = '' else msg = tostring(msg)..'\n' end - return assert (value == expected, + local ret = assert (value == expected, msg.."wrong value (["..tostring(value).."] instead of ".. tostring(expected)..")") + io.write('.') + return ret end --------------------------------------------------------------------- @@ -84,7 +85,10 @@ function test_object (obj, objmethods) return obj end -CONN_OK = function (obj) +CONN_OK = function (obj, err) + if obj == nil then + error (err, 2) + end return test_object (obj, { "close", "add", "compare", "delete", "modify", "rename", "search", }) end @@ -124,11 +128,11 @@ end -- checks return value which should be a function AND also its return value. --------------------------------------------------------------------- function check_future (ret, method, ...) -io.write('.') local ok, f = pcall (method, unpack (arg)) assert (ok, f) assert2 ("function", type(f)) assert2 (ret, f()) + io.write('.') end -- cgit v1.2.3-59-g8ed1b