public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }

            return(table.Equals(((DynamicLuaTable)obj).table));
        }
Exemple #2
0
 [TestMethod] public void Equality()
 {
     using (var lua = new Lua())
     {
         var tables = lua.DoString("return {'one'}, {'two'}, {__eq = function(a,b) return true end}");
         using (tables.DeferDisposeAll())
         {
             LuaTable one = (LuaTable)tables[0], two = (LuaTable)tables[1], friendly_meta = (LuaTable)tables[2];
             Assert.AreEqual("one", one.RawGet(1));
             Assert.AreEqual("two", two.RawGet(1));
             using (var one_ref = one.NewReference())
             {
                 Assert.IsTrue(one == one_ref && one != two && one_ref != two, "lua equality failed");
                 Assert.IsTrue(one.Equals(one_ref) && !one.Equals(two) && !one_ref.Equals(two), "raw equality failed");
                 one.Metatable = friendly_meta;
                 two.Metatable = friendly_meta;
                 Assert.IsTrue(one == one_ref && one == two && one_ref == two, "lua equality failed with metatable");
                 Assert.IsTrue(one.Equals(one_ref) && !one.Equals(two) && !one_ref.Equals(two), "raw equality failed with metatable");
             }
         }
     }
 }