Ejemplo n.º 1
0
        public void CreateThread_Disposed_ThrowsObjectDisposedException()
        {
            var lua      = new Lua();
            var function = lua.CreateFunction("return 0");

            lua.Dispose();

            Assert.Throws <ObjectDisposedException>(() => lua.CreateThread(function));
        }
Ejemplo n.º 2
0
        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));
                }
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
 public void CreateThread_NullFunction_ThrowsArgumentNullException()
 {
     using (var lua = new Lua()) {
         Assert.Throws <ArgumentNullException>(() => lua.CreateThread(null));
     }
 }