From 95ec129a7c0418846a26000fd288ea0a6009b953 Mon Sep 17 00:00:00 2001 From: Max Rottenkolber Date: Thu, 28 Aug 2014 16:51:46 +0200 Subject: [PATCH] [core.app] Fix bug in equal where extra keys in table y were ignored. --- src/core/app.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/app.lua b/src/core/app.lua index e0504e81bb..81a1ac7b41 100644 --- a/src/core/app.lua +++ b/src/core/app.lua @@ -49,8 +49,8 @@ function equal (x, y) for k, v in pairs(x) do if not equal(v, y[k]) then return false end end - for k, _ in pairs(x) do - if y[k] == nil then return false end + for k, _ in pairs(y) do + if x[k] == nil then return false end end return true else @@ -277,6 +277,10 @@ function selftest () configure(config.new()) assert(#app_array == 0) assert(#link_array == 0) + print("Testing equal") + assert(true == equal({foo="bar"}, {foo="bar"})) + assert(false == equal({foo="bar"}, {foo="bar", baz="foo"})) + assert(false == equal({foo="bar", baz="foo"}, {foo="bar"})) print("OK") end