public void TestToCFunction() { LuaState L = null; using (L = new LuaState()) { LuaFunction f = l => 0; L.PushNil() .PushNumber(123.45) .PushInteger(987) .PushString("Test") .PushString("5.6") .PushString("5D") .PushString("5z") .PushBoolean(true) .PushCClosure(f, 0) //.PushLightUserData(DateTime.Now) .PushGlobalTable() ; Assert.Equal(null, L.ToCFunction(1)); Assert.Equal(null, L.ToCFunction(2)); Assert.Equal(null, L.ToCFunction(3)); Assert.Equal(null, L.ToCFunction(4)); Assert.Equal(null, L.ToCFunction(5)); Assert.Equal(null, L.ToCFunction(6)); Assert.Equal(null, L.ToCFunction(7)); Assert.Equal(null, L.ToCFunction(8)); Assert.Same(f, L.ToCFunction(9)); Assert.Equal(null, L.ToCFunction(10)); Assert.Equal(null, L.ToCFunction(11)); Assert.Equal(null, L.ToCFunction(12)); } }
public void TestPushCClosure() { LuaState L = null; using (L = new LuaState()) { LuaFunction f = l => 0; L.PushCClosure(f, 0); Assert.Equal(1, L.GetTop()); Assert.Equal(LuaType.Function, L.Type(-1)); Assert.Same(f, L.ToCFunction(-1)); } }