public void PrintTest2() { string script = @" t = {}; m = {}; function m.__tostring() return 'ciao'; end setmetatable(t, m); print(t, 1); "; string printed = null; Script S = new Script(); DynValue main = S.LoadString(script); S.Options.DebugPrint = s => { printed = s; }; S.Call(main); Assert.AreEqual("ciao\t1", printed); }
public void MetatableCall2() { string script = @" t = { } meta = { } x = 0; function meta.__call(f, y) x = 156 * y; return x; end setmetatable(t, meta); return t; "; Script S = new Script(); DynValue tbl = S.DoString(script); DynValue res = S.Call(tbl, 3); Assert.AreEqual(DataType.Number, res.Type); Assert.AreEqual(468, res.Number); }
public void PrintTest1() { string script = @" print('ciao', 1); "; string printed = null; Script S = new Script(); DynValue main = S.LoadString(script); S.Options.DebugPrint = s => { printed = s; }; S.Call(main); Assert.AreEqual("ciao\t1", printed); }