public void Call_TooManyArgs_ThrowsLuaException() { using (var lua = new Lua()) { var function = lua.CreateFunction(""); Assert.Throws <LuaException>(() => function.Call(new object[10000000])); } }
public void CreateFunctionString_Disposed_ThrowsObjectDisposedException() { var lua = new Lua(); lua.Dispose(); Assert.Throws <ObjectDisposedException>(() => lua.CreateFunction("")); }
public void Call_NullArgs_ThrowsArgumentNullException() { using (var lua = new Lua()) { var function = lua.CreateFunction(""); Assert.Throws <ArgumentNullException>(() => function.Call(null)); } }
public void CreateFunctionDelegate_NullDelegate_ThrowsArgumentNullException() { var lua = new Lua(); lua.Dispose(); Assert.Throws <ArgumentNullException>(() => lua.CreateFunction((Delegate)null)); }
public void CreateFunctionDelegate_Disposed_ThrowsObjectDispossedException() { var lua = new Lua(); lua.Dispose(); Assert.Throws <ObjectDisposedException>(() => lua.CreateFunction(new Action(() => lua.Dispose()))); }
public void Call_RuntimeError_ThrowsLuaException(string s) { using (var lua = new Lua()) { var function = lua.CreateFunction(s); Assert.Throws <LuaException>(() => function.Call()); } }
public void CreateThread_FunctionWrongLuaEnvironment_ThrowsArgumentNullException() { using (var lua = new Lua()) using (var lua2 = new Lua()) { var function = lua2.CreateFunction(""); Assert.Throws <ArgumentException>(() => lua.CreateThread(function)); } }
public void CreateThread_Disposed_ThrowsObjectDisposedException() { var lua = new Lua(); var function = lua.CreateFunction("return 0"); lua.Dispose(); Assert.Throws <ObjectDisposedException>(() => lua.CreateThread(function)); }
public void Call_ArgWrongLuaEnvironment_ThrowsArgumentException() { using (var lua = new Lua()) using (var lua2 = new Lua()) { var function = lua.CreateFunction(""); var table = lua2.CreateTable(); Assert.Throws <ArgumentException>(() => function.Call(table)); } }
public void Call_NoResults() { using (var lua = new Lua()) { var function = lua.CreateFunction("return"); var results = function.Call(); Assert.Empty(results); } }
public void CreateFunctionDelegate() { using (var lua = new Lua()) { var function = lua.CreateFunction(new Func <int, int>(x => x * x)); var results = function.Call(10); Assert.Single(results); Assert.Equal(100L, results[0]); } }
public void CallDynamic() { using (var lua = new Lua()) { dynamic function = lua.CreateFunction("return 6"); dynamic results = function(); Assert.Single(results); Assert.Equal(6L, results[0]); } }
public void Call_NoArgs() { using (var lua = new Lua()) { var function = lua.CreateFunction("return 1979"); var results = function.Call(); Assert.Single(results); Assert.Equal(1979L, results[0]); } }
public void GetSet_Function() { using (var lua = new Lua()) { var table = lua.CreateTable(); var function = lua.CreateFunction("return 0"); table["test"] = function; Assert.Same(function, table["test"]); } }
public void Call_OneArg() { using (var lua = new Lua()) { var function = lua.CreateFunction("return ..."); var results = function.Call("test"); Assert.Single(results); Assert.Equal("test", results[0]); } }
public void SetProperty(int n) { using (var lua = new Lua()) { lua["test"] = new TestClass(); var function = lua.CreateFunction("test.TestProperty = 0"); for (var i = 0; i < n; ++i) { function.Call(); } } }
public void CallMethod_Args(int n) { using (var lua = new Lua()) { lua["test"] = new TestClass(); var function = lua.CreateFunction("test:TestMethod2(0, 0)"); for (var i = 0; i < n; ++i) { function.Call(); } } }
public void CallGenericMethod(int n) { using (var lua = new Lua()) { lua.ImportType(typeof(int)); lua["test"] = new TestClass(); var function = lua.CreateFunction("test:TestMethod(Int32)()"); for (var i = 0; i < n; ++i) { function.Call(); } } }
public void Test() { using (var lua = new Lua()) { var indexFunction = lua.CreateFunction("return 1"); var metatable = lua.CreateTable(); metatable["__index"] = indexFunction; lua.DoString("table = {}"); var table = (LuaTable)lua["table"]; table.Metatable = metatable; lua.DoString(TestString); } }
public void Call_ManyResults() { using (var lua = new Lua()) { var function = lua.CreateFunction("return 0, 1, 4, 9, 16"); var results = function.Call("test"); Assert.Equal(5, results.Length); Assert.Equal(0L, results[0]); Assert.Equal(1L, results[1]); Assert.Equal(4L, results[2]); Assert.Equal(9L, results[3]); Assert.Equal(16L, results[4]); } }
public void Call_ManyArgs() { using (var lua = new Lua()) { var function = lua.CreateFunction(@" result = 0 for _, val in ipairs({...}) do result = result + val end return result"); var results = function.Call(6, 51, 29, -51, -29, 12); Assert.Single(results); Assert.Equal(18L, results[0]); } }
public void LotsOfReferencesCleanedUp(int n) { using (var lua = new Lua()) { var function = lua.CreateFunction("x = 0 + 0"); for (var i = 0; i < n; ++i) { lua.CreateTable(); lua.CreateTable(); lua.CreateTable(); for (var j = 0; j < 1000; ++j) { function.Call(); } } } }
public void Test() { using (var lua = new Lua()) { var function = lua.CreateFunction(TestString); var thread = lua.CreateThread(function); Assert.True(thread.CanResume); for (var i = 1; i <= 10; ++i) { var results = thread.Resume(); Assert.Single(results); Assert.Equal((long)i, results[0]); Assert.Equal((long)i, lua["x"]); Assert.True(thread.CanResume); } var results2 = thread.Resume(); Assert.Single(results2); Assert.Equal(-1L, results2[0]); Assert.False(thread.CanResume); } }
public void CreateFunctionString_NullS_ThrowsArgumentNullException() { using (var lua = new Lua()) { Assert.Throws <ArgumentNullException>(() => lua.CreateFunction((string)null)); } }
public void LoadString_SyntaxError_ThrowsLuaException(string s) { using (var lua = new Lua()) { Assert.Throws <LuaException>(() => lua.CreateFunction(s)); } }