Beispiel #1
0
        public async void RunWithPrimitiveGlobalVariables_Succeed()
        {
            var code = @"
a = '1'; 
a = a + t; 
if a ~= '12' then
    error()
end";

            var container = new Container();

            container.Register("2", "t");

            var runner = new LuaCodeRunner(code, container);

            await runner.RunAsync();
        }
Beispiel #2
0
        public async void ExternalFuncWillCall()
        {
            var code = "f(2)";
            int cnt  = 0;

            var container = new Container();

            container.Register <Action <int> >((int x) =>
            {
                cnt += x;
            }, "f");

            var runner = new LuaCodeRunner(code, container);

            await runner.RunAsync();

            Assert.Equal(2, cnt);
        }
Beispiel #3
0
        public async void RunWithGlobalVariables_Succeed()
        {
            var code = @"
a = 1; 
a = a + t.x; 
if a ~= 2 then
    error()
end";

            var obj = new HelperObject {
                x = 1
            };

            var container = new Container();

            container.Register(obj, "t");

            var runner = new LuaCodeRunner(code, container);

            await runner.RunAsync();
        }
Beispiel #4
0
 public async void Run()
 {
     var code   = "a = 1;";
     var runner = new LuaCodeRunner(code, new Container());
     await runner.RunAsync();
 }