本文整理汇总了C#中LuaState.PushNumber方法的典型用法代码示例。如果您正苦于以下问题:C# LuaState.PushNumber方法的具体用法?C# LuaState.PushNumber怎么用?C# LuaState.PushNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LuaState
的用法示例。
在下文中一共展示了LuaState.PushNumber方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestArith
public void TestArith()
{
LuaState L = null;
using (L = new LuaState())
{
L.PushNumber(12.34)
.PushNumber(98.76);
L.Arith(LuaArithOperator.Add);
Assert.Equal(1, L.GetTop());
Assert.Equal(111.1, L.ToNumber(-1), 2);
}
}
示例2: TestAbsIndex
public void TestAbsIndex()
{
LuaState L = null;
using (L = new LuaState())
{
L.PushNumber(1)
.PushNumber(2)
.PushNumber(3);
Assert.Equal(4, L.AbsIndex(0));
Assert.Equal(1, L.AbsIndex(1));
Assert.Equal(2, L.AbsIndex(2));
Assert.Equal(3, L.AbsIndex(3));
Assert.Equal(4, L.AbsIndex(4));
Assert.Equal(3, L.AbsIndex(-1));
Assert.Equal(2, L.AbsIndex(-2));
Assert.Equal(1, L.AbsIndex(-3));
Assert.Equal(0, L.AbsIndex(-4));
}
}
示例3: TestGetUpvalue
public void TestGetUpvalue()
{
LuaState L = null;
using (L = new LuaState())
{
L.PushNumber(23);
L.PushFunction(l => {
Assert.Equal(null, l.GetUpvalue(0, 0));
return 0;
});
L.PCall(0, 0, 0);
}
}
示例4: TestGetTop
public void TestGetTop()
{
LuaState L = null;
using (L = new LuaState())
{
Assert.Equal(0, L.GetTop());
L.PushNumber(1);
Assert.Equal(1, L.GetTop());
L.PushNumber(1);
Assert.Equal(2, L.GetTop());
L.Pop(1);
Assert.Equal(1, L.GetTop());
L.Pop(1);
Assert.Equal(0, L.GetTop());
}
}
示例5: TestGetStack
public void TestGetStack()
{
LuaState L = null;
using (L = new LuaState())
{
L.PushNumber(23);
L.PushFunction(l => {
var ar = new LuaDebug();
Assert.Throws<NotImplementedException>(() => l.GetStack(0, ar));
//Assert.Equal(0, l.GetStack(0, ar));
//Assert.Equal(0, ar.currentline);
return 0;
});
L.PCall(0, 0, 0);
}
}
示例6: TestUpvalueJoin
public void TestUpvalueJoin()
{
LuaState L = null;
using (L = new LuaState())
{
L.PushNumber(23);
L.PushFunction(l => {
//TODO Do test
//l.UpvalueJoin(0, 0, 0, 0);
return 0;
});
L.PCall(0, 0, 0);
}
}
示例7: TestConcat
public void TestConcat()
{
LuaState L = null;
using (L = new LuaState())
{
L.PushString("One");
L.PushNumber(2);
L.PushString("Three");
L.PushNumber(4);
L.Concat(3);
Assert.Equal("2.0Three4.0", L.ToString(-1));
}
}
示例8: TestPop
public void TestPop()
{
LuaState L = null;
using (L = new LuaState())
{
L.PushNumber(1);
L.PushString("Text");
L.PushNumber(2);
L.PushString("Text");
Assert.Equal(4, L.GetTop());
L.Pop(2);
Assert.Equal(2, L.GetTop());
L.Pop(1);
Assert.Equal(1, L.GetTop());
L.Pop(2);
Assert.Equal(-1, L.GetTop());
}
}
示例9: TestSetHook
public void TestSetHook()
{
LuaState L = null;
using (L = new LuaState())
{
LuaHook hook = (ILuaState l, LuaDebug ar) => {
};
Assert.Throws<NotImplementedException>(() => L.SetHook(hook, LuaHookMask.MaskCall | LuaHookMask.MaskLine | LuaHookMask.MaskCount, 1));
L.PushNumber(23);
L.PushFunction(l => {
return 0;
});
L.PCall(0, 0, 0);
}
}
示例10: TestRawEqual
public void TestRawEqual()
{
LuaState L = null;
using (L = new LuaState())
{
L.PushNumber(12.34)
.PushNumber(98.76)
.PushNumber(12.34);
Assert.False(L.RawEqual(1, 2));
Assert.False(L.RawEqual(2, 3));
Assert.True(L.RawEqual(1, 3));
}
}
示例11: TestCompare
public void TestCompare()
{
LuaState L = null;
using (L = new LuaState())
{
L.PushNumber(12.34)
.PushNumber(98.76)
.PushNumber(12.34);
Assert.Equal(false, L.Compare(1, 2, LuaRelOperator.EQ));
Assert.Equal(false, L.Compare(2, 3, LuaRelOperator.EQ));
Assert.Equal(true, L.Compare(1, 3, LuaRelOperator.EQ));
Assert.Equal(true, L.Compare(1, 2, LuaRelOperator.LE));
Assert.Equal(false, L.Compare(2, 3, LuaRelOperator.LE));
Assert.Equal(true, L.Compare(1, 3, LuaRelOperator.LE));
Assert.Equal(true, L.Compare(1, 2, LuaRelOperator.LT));
Assert.Equal(false, L.Compare(2, 3, LuaRelOperator.LT));
Assert.Equal(false, L.Compare(1, 3, LuaRelOperator.LT));
}
}
示例12: TestPushValue
public void TestPushValue()
{
LuaState L = null;
using (L = new LuaState())
{
Assert.Equal(0, L.GetTop());
L.PushNumber(1);
L.PushString("Test");
L.PushNumber(2);
L.PushString("Text");
Assert.Equal(4, L.GetTop());
L.PushValue(-1).PushValue(2);
Assert.Equal(6, L.GetTop());
Assert.Equal(1, L.ToNumber(1));
Assert.Equal("Test", L.ToString(2));
Assert.Equal(2, L.ToNumber(3));
Assert.Equal("Text", L.ToString(4));
Assert.Equal("Text", L.ToString(5));
Assert.Equal("Test", L.ToString(6));
}
}
示例13: TestPushNumber
public void TestPushNumber()
{
LuaState L = null;
using (L = new LuaState())
{
L.PushNumber(1234);
Assert.Equal(1, L.GetTop());
Assert.Equal(LuaType.Number, L.Type(-1));
Assert.Equal(1234, L.ToNumber(-1));
}
}
示例14: TestCallK
public void TestCallK()
{
LuaState L = null;
using (L = new LuaState())
{
L.PushFunction(l => {
var a = L.ToNumber(1);
var b = L.ToNumber(2);
L.PushNumber(a * b);
return 1;
});
L.PushNumber(12);
L.PushNumber(4);
Assert.Throws<NotImplementedException>(() => L.CallK(2, 1, 0, null));
}
}
示例15: TestInsert
public void TestInsert()
{
LuaState L = null;
using (L = new LuaState())
{
Assert.Equal(0, L.GetTop());
L.PushNumber(1);
L.PushString("Test");
L.PushNumber(2);
L.PushString("Text");
L.PushNumber(3);
L.PushString("Toto");
L.PushNumber(4);
Assert.Equal(7, L.GetTop());
L.Insert(2);
Assert.Equal(7, L.GetTop());
Assert.Equal(1, L.ToNumber(1));
Assert.Equal(4, L.ToNumber(2));
Assert.Equal("Test", L.ToString(3));
Assert.Equal(2, L.ToNumber(4));
Assert.Equal("Text", L.ToString(5));
Assert.Equal(3, L.ToNumber(6));
Assert.Equal("Toto", L.ToString(7));
}
}