Changeset

7503:1810f1a4ff05

test_util_stanza: wrap individual test blocks in do-end [luacheck]
author Anton Shestakov <av6@dwimlabs.net>
date Thu, 14 Jul 2016 18:54:17 +0800
parents 7502:021d2b844c51
children 7504:b43cbbbb806f
files tests/test_util_stanza.lua
diffstat 1 files changed, 64 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test_util_stanza.lua	Thu Jul 14 18:51:22 2016 +0800
+++ b/tests/test_util_stanza.lua	Thu Jul 14 18:54:17 2016 +0800
@@ -80,63 +80,73 @@
 end
 
 function reply(reply, _M)
-	-- Test stanza
-	local s = _M.stanza("s", { to = "touser", from = "fromuser", id = "123" })
-		:tag("child1");
-	-- Make reply stanza
-	local r = reply(s);
-	assert_equal(r.name, s.name);
-	assert_equal(r.id, s.id);
-	assert_equal(r.attr.to, s.attr.from);
-	assert_equal(r.attr.from, s.attr.to);
-	assert_equal(#r.tags, 0, "A reply should not include children of the original stanza");
+	do
+		-- Test stanza
+		local s = _M.stanza("s", { to = "touser", from = "fromuser", id = "123" })
+			:tag("child1");
+		-- Make reply stanza
+		local r = reply(s);
+		assert_equal(r.name, s.name);
+		assert_equal(r.id, s.id);
+		assert_equal(r.attr.to, s.attr.from);
+		assert_equal(r.attr.from, s.attr.to);
+		assert_equal(#r.tags, 0, "A reply should not include children of the original stanza");
+	end
 
-	-- Test stanza
-	local s = _M.stanza("iq", { to = "touser", from = "fromuser", id = "123", type = "get" })
-		:tag("child1");
-	-- Make reply stanza
-	local r = reply(s);
-	assert_equal(r.name, s.name);
-	assert_equal(r.id, s.id);
-	assert_equal(r.attr.to, s.attr.from);
-	assert_equal(r.attr.from, s.attr.to);
-	assert_equal(r.attr.type, "result");
-	assert_equal(#r.tags, 0, "A reply should not include children of the original stanza");
+	do
+		-- Test stanza
+		local s = _M.stanza("iq", { to = "touser", from = "fromuser", id = "123", type = "get" })
+			:tag("child1");
+		-- Make reply stanza
+		local r = reply(s);
+		assert_equal(r.name, s.name);
+		assert_equal(r.id, s.id);
+		assert_equal(r.attr.to, s.attr.from);
+		assert_equal(r.attr.from, s.attr.to);
+		assert_equal(r.attr.type, "result");
+		assert_equal(#r.tags, 0, "A reply should not include children of the original stanza");
+	end
 
-	-- Test stanza
-	local s = _M.stanza("iq", { to = "touser", from = "fromuser", id = "123", type = "set" })
-		:tag("child1");
-	-- Make reply stanza
-	local r = reply(s);
-	assert_equal(r.name, s.name);
-	assert_equal(r.id, s.id);
-	assert_equal(r.attr.to, s.attr.from);
-	assert_equal(r.attr.from, s.attr.to);
-	assert_equal(r.attr.type, "result");
-	assert_equal(#r.tags, 0, "A reply should not include children of the original stanza");
+	do
+		-- Test stanza
+		local s = _M.stanza("iq", { to = "touser", from = "fromuser", id = "123", type = "set" })
+			:tag("child1");
+		-- Make reply stanza
+		local r = reply(s);
+		assert_equal(r.name, s.name);
+		assert_equal(r.id, s.id);
+		assert_equal(r.attr.to, s.attr.from);
+		assert_equal(r.attr.from, s.attr.to);
+		assert_equal(r.attr.type, "result");
+		assert_equal(#r.tags, 0, "A reply should not include children of the original stanza");
+	end
 end
 
 function error_reply(error_reply, _M)
-	-- Test stanza
-	local s = _M.stanza("s", { to = "touser", from = "fromuser", id = "123" })
-		:tag("child1");
-	-- Make reply stanza
-	local r = error_reply(s);
-	assert_equal(r.name, s.name);
-	assert_equal(r.id, s.id);
-	assert_equal(r.attr.to, s.attr.from);
-	assert_equal(r.attr.from, s.attr.to);
-	assert_equal(#r.tags, 1);
-	
-	-- Test stanza
-	local s = _M.stanza("iq", { to = "touser", from = "fromuser", id = "123", type = "get" })
-		:tag("child1");
-	-- Make reply stanza
-	local r = error_reply(s);
-	assert_equal(r.name, s.name);
-	assert_equal(r.id, s.id);
-	assert_equal(r.attr.to, s.attr.from);
-	assert_equal(r.attr.from, s.attr.to);
-	assert_equal(r.attr.type, "error");
-	assert_equal(#r.tags, 1);
+	do
+		-- Test stanza
+		local s = _M.stanza("s", { to = "touser", from = "fromuser", id = "123" })
+			:tag("child1");
+		-- Make reply stanza
+		local r = error_reply(s);
+		assert_equal(r.name, s.name);
+		assert_equal(r.id, s.id);
+		assert_equal(r.attr.to, s.attr.from);
+		assert_equal(r.attr.from, s.attr.to);
+		assert_equal(#r.tags, 1);
+	end
+
+	do
+		-- Test stanza
+		local s = _M.stanza("iq", { to = "touser", from = "fromuser", id = "123", type = "get" })
+			:tag("child1");
+		-- Make reply stanza
+		local r = error_reply(s);
+		assert_equal(r.name, s.name);
+		assert_equal(r.id, s.id);
+		assert_equal(r.attr.to, s.attr.from);
+		assert_equal(r.attr.from, s.attr.to);
+		assert_equal(r.attr.type, "error");
+		assert_equal(#r.tags, 1);
+	end
 end