Exemplo n.º 1
0
		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);
		}
Exemplo n.º 2
0
		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);

		}
Exemplo n.º 3
0
		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);
		}