lunarmodules / luassert

Assertion library for Lua
MIT License
202 stars 77 forks source link

Support for recursive tables #109

Closed o-lim closed 9 years ago

o-lim commented 9 years ago

Adds support for copying and comparing recursive tables, and disables deep copies for spies.

Fixes issues #54, and olivine-labs/busted#425

mpeterv commented 9 years ago

The fix for recursive table comparison is incorrect. E.g. this assertion passes:

local luassert = require "luassert"
local t1 = {}
local t2 = {}
local a = {}
local b = {}
local c = {}
local d = {}
t1.k1 = a
t2.k1 = b
a.k1 = c
b.k1 = d
c.k2 = a
d.k2 = d
luassert.is_table(t1.k1.k1.k2.k1)
luassert.is_nil(t2.k1.k1.k2.k1)
luassert.are_same(t1, t2)