当前位置: 首页>>代码示例>>C#>>正文


C# LuaState.PushNumber方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:ygrenier,项目名称:LuaN,代码行数:12,代码来源:LuaStateTest.cs

示例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));

            }
        }
开发者ID:ygrenier,项目名称:LuaN,代码行数:21,代码来源:LuaStateTest.cs

示例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);
     }
 }
开发者ID:ygrenier,项目名称:LuaN,代码行数:13,代码来源:LuaStateTest.cs

示例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());
            }
        }
开发者ID:ygrenier,项目名称:LuaN,代码行数:17,代码来源:LuaStateTest.cs

示例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);
     }
 }
开发者ID:ygrenier,项目名称:LuaN,代码行数:16,代码来源:LuaStateTest.cs

示例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);
     }
 }
开发者ID:ygrenier,项目名称:LuaN,代码行数:14,代码来源:LuaStateTest.cs

示例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));
     }
 }
开发者ID:ygrenier,项目名称:LuaN,代码行数:13,代码来源:LuaStateTest.cs

示例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());
     }
 }
开发者ID:ygrenier,项目名称:LuaN,代码行数:18,代码来源:LuaStateTest.cs

示例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);
            }
        }
开发者ID:ygrenier,项目名称:LuaN,代码行数:16,代码来源:LuaStateTest.cs

示例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));
     }
 }
开发者ID:ygrenier,项目名称:LuaN,代码行数:13,代码来源:LuaStateTest.cs

示例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));
     }
 }
开发者ID:ygrenier,项目名称:LuaN,代码行数:19,代码来源:LuaStateTest.cs

示例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));

            }
        }
开发者ID:ygrenier,项目名称:LuaN,代码行数:24,代码来源:LuaStateTest.cs

示例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));
     }
 }
开发者ID:ygrenier,项目名称:LuaN,代码行数:11,代码来源:LuaStateTest.cs

示例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));
     }
 }
开发者ID:ygrenier,项目名称:LuaN,代码行数:16,代码来源:LuaStateTest.cs

示例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));
            }
        }
开发者ID:ygrenier,项目名称:LuaN,代码行数:27,代码来源:LuaStateTest.cs


注:本文中的LuaState.PushNumber方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。