I wanna check if two tables have the same value in Lua, but didn\'t find the way.
I use the operator ==
, it seems just to check the same objects, but no
if you just want to compare 2 small tables, you may (ab)use inspect.
local ins = require 'inspect'
local assert_equal = require 'luassert' .equal
assert_equal(ins({ 1 , b = 30 }), ins({ b = 30, 1 }))
This approach takes advantage of that inspect
sorts table elements when serializing an object. while cjson doesn't, which makes it unusable in this case.