测试 tolua 例子 TestErrorStack

(金庆的专栏 2020.9)

Error1

  1. 点击 “Error1” 按钮
  2. c# showStack.PCall()
  3. lua ShowStack()
  4. c# Test1()
  5. c# try { show.PCall() }
  6. lua Show() error(‘this is error’)
LuaException: TestErrorStack:2: this is error
stack traceback:[C]: in function 'error'TestErrorStack:2: in function <TestErrorStack:1>[C]: in function 'Test1'TestErrorStack:6: in function <TestErrorStack:5>
LuaInterface.LuaState:PCall(Int32, Int32) (at Assets/ToLua/Core/LuaState.cs:758)
LuaInterface.LuaFunction:PCall() (at Assets/ToLua/Core/LuaFunction.cs:96)
TestLuaStack:Test1(IntPtr) (at Assets/ToLua/Examples/TestErrorStack/TestLuaStack.cs:27)
LuaInterface.LuaDLL:lua_pcall(IntPtr, Int32, Int32, Int32)
LuaInterface.LuaState:PCall(Int32, Int32) (at Assets/ToLua/Core/LuaState.cs:755)
LuaInterface.LuaFunction:PCall() (at Assets/ToLua/Core/LuaFunction.cs:96)
TestLuaStack:OnGUI() (at Assets/ToLua/Examples/TestErrorStack/TestLuaStack.cs:375)

lua Show() 中抛 error, 在 C# 中 try-catch 得到,
通过 toluaL_exception() 返回 Lua 调用者 ShowStack(),
ShowStack() 中止执行,传递异常到 c# 调用者 OnGUI(),
OnGUI()中断执行,打印错误信息。

Instantiate Error

  1. “Instantiate Error”
  2. c# GetFunction(“Instantiate”).PCall()
  3. lua Instantiate()
  4. c# UnityEngine.Object.Instantiate(obj)
  5. c# TestInstantiate.Awake()
  6. c# try { GetFunction(“Show”).PCall() }
  7. lua Show()
  8. c# state.ThrowLuaException(e)
LuaException: TestErrorStack:2: this is error
stack traceback:[C]: in function 'error'TestErrorStack:2: in function <TestErrorStack:1>[C]: in function 'Instantiate'TestErrorStack:12: in function <TestErrorStack:11>
LuaInterface.LuaState:PCall(Int32, Int32) (at Assets/ToLua/Core/LuaState.cs:758)
LuaInterface.LuaFunction:PCall() (at Assets/ToLua/Core/LuaFunction.cs:96)
TestInstantiate:Awake() (at Assets/ToLua/Examples/TestErrorStack/TestInstantiate.cs:15)
UnityEngine.Object:Instantiate(Object)
UnityEngine_ObjectWrap:Instantiate(IntPtr) (at Assets/ToLua/BaseType/UnityEngine_ObjectWrap.cs:203)
LuaInterface.LuaDLL:lua_pcall(IntPtr, Int32, Int32, Int32)
LuaInterface.LuaState:PCall(Int32, Int32) (at Assets/ToLua/Core/LuaState.cs:755)
LuaInterface.LuaFunction:PCall() (at Assets/ToLua/Core/LuaFunction.cs:96)
TestLuaStack:OnGUI() (at Assets/ToLua/Examples/TestErrorStack/TestLuaStack.cs:391)

在 lua 中实例化对象,Awake() 中向lua抛异常:state.ThrowLuaException(e)。
中止了 lua 调用和 OnGUI(), 但是新对象的 Start() 成功调用了。
因为 Awake() 中 catch 了异常,按执行成功处理。
如果 Awake() 中不 catch, Awake() 执行异常,也不会有 Start() 调用,但是lua Instantiate() 执行会成功,打印出对象名。

Check Error

  1. “Check Error”
  2. c# GetFunction(“TestRay”).PCall()
  3. lua TestRay() return Vector3.zero
  4. c# CheckRay(); //返回值出错
LuaException: bad argument #2 (Ray expected, got Vector3)
LuaInterface.LuaDLL:luaL_argerror(IntPtr, Int32, String) (at Assets/ToLua/Core/LuaDLL.cs:692)
LuaInterface.LuaDLL:luaL_typerror(IntPtr, Int32, String, String) (at Assets/ToLua/Core/LuaDLL.cs:706)
LuaInterface.LuaStatePtr:LuaTypeError(Int32, String, String) (at Assets/ToLua/Core/LuaStatePtr.cs:534)
LuaInterface.LuaState:CheckRay(Int32) (at Assets/ToLua/Core/LuaState.cs:1505)
LuaInterface.LuaFunction:CheckRay() (at Assets/ToLua/Core/LuaFunction.cs:781)
TestLuaStack:OnGUI() (at Assets/ToLua/Examples/TestErrorStack/TestLuaStack.cs:403)

Push Error

  1. “Push Error”
  2. c# func.Push(Instance);
14:04:31.371-157: Type TestLuaStack not wrap to lua, push as UnityEngine.MonoBehaviour, the warning is only raised once
UnityEngine.Debug:LogWarning(Object)
LuaInterface.Debugger:LogWarning(String)
LuaInterface.Debugger:LogWarning(String, Object, Object)
LuaInterface.LuaState:GetMissMetaReference(Type) (at Assets/ToLua/Core/LuaState.cs:1917)
LuaInterface.LuaStatic:GetMissMetaReference(IntPtr, Type) (at Assets/ToLua/Core/LuaStatic.cs:39)
LuaInterface.ToLua:LoadPreType(IntPtr, Type) (at Assets/ToLua/Core/ToLua.cs:2608)
LuaInterface.ToLua:PushUserObject(IntPtr, Object) (at Assets/ToLua/Core/ToLua.cs:2622)
LuaInterface.ToLua:Push(IntPtr, Object) (at Assets/ToLua/Core/ToLua.cs:2636)
LuaInterface.LuaState:Push(Object) (at Assets/ToLua/Core/LuaState.cs:1378)
LuaInterface.LuaFunction:Push(Object) (at Assets/ToLua/Core/LuaFunction.cs:465)
TestLuaStack:OnGUI() (at Assets/ToLua/Examples/TestErrorStack/TestLuaStack.cs:412)

LuaPushError

  1. “LuaPushError”
  2. c# GetFunction(“PushLuaError”).PCall()
  3. lua PushLuaError()
  4. lua TestStack.PushLuaError()
  5. c# PushLuaError()
  6. c# try { testRay.Push(Instance); }

仅是警告,没有异常

Check Error

  1. “Check Error”
  2. c# GetFunction(“Test5”).PCall()
  3. lua Test5()
  4. lua TestStack.Test5()
  5. c# Test5()
  6. c# GetFunction(“Test4”).PCall()
  7. lua TestStack.Test4()
  8. c# Test4()
  9. c# try { show.PCall() }
LuaException: TestErrorStack:2: this is error
stack traceback:[C]: in function 'error'TestErrorStack:2: in function <TestErrorStack:1>[C]: in function 'Test4'TestErrorStack:30: in function <TestErrorStack:29>[C]: in function 'Test5'TestErrorStack:34: in function <TestErrorStack:33>
LuaInterface.LuaState:PCall(Int32, Int32) (at Assets/ToLua/Core/LuaState.cs:758)
LuaInterface.LuaFunction:PCall() (at Assets/ToLua/Core/LuaFunction.cs:96)
TestLuaStack:Test4(IntPtr) (at Assets/ToLua/Examples/TestErrorStack/TestLuaStack.cs:85)
LuaInterface.LuaDLL:lua_pcall(IntPtr, Int32, Int32, Int32)
LuaInterface.LuaState:PCall(Int32, Int32) (at Assets/ToLua/Core/LuaState.cs:755)
LuaInterface.LuaFunction:PCall() (at Assets/ToLua/Core/LuaFunction.cs:96)
TestLuaStack:Test5(IntPtr) (at Assets/ToLua/Examples/TestErrorStack/TestLuaStack.cs:102)
LuaInterface.LuaDLL:lua_pcall(IntPtr, Int32, Int32, Int32)
LuaInterface.LuaState:PCall(Int32, Int32) (at Assets/ToLua/Core/LuaState.cs:755)
LuaInterface.LuaFunction:PCall() (at Assets/ToLua/Core/LuaFunction.cs:96)
TestLuaStack:OnGUI() (at Assets/ToLua/Examples/TestErrorStack/TestLuaStack.cs:434)

Test Resume

  1. “Test Resume”
  2. c# GetFunction(“Test6”).PCall()
  3. lua Test6()
  4. lua 协程中调用 TestStack.Test6(go)
  5. c# toluaL_exception()

lua coroutine resume() 返回 false, 不会有错误。

out of bound

  1. “out of bound”
  2. c# GetFunction(“TestOutOfBound”).PCall()
  3. c# TestOutOfBound()
  4. c# toluaL_exception(L, e)
LuaException: Transform child out of bounds
stack traceback:[C]: at 0x613c2af0
TestLuaStack:TestOutOfBound(IntPtr) (at Assets/ToLua/Examples/TestErrorStack/TestLuaStack.cs:136)
LuaInterface.LuaDLL:lua_pcall(IntPtr, Int32, Int32, Int32)
LuaInterface.LuaState:PCall(Int32, Int32) (at Assets/ToLua/Core/LuaState.cs:755)
LuaInterface.LuaFunction:PCall() (at Assets/ToLua/Core/LuaFunction.cs:96)
TestLuaStack:OnGUI() (at Assets/ToLua/Examples/TestErrorStack/TestLuaStack.cs:454)

TestArgError

  1. “TestArgError”
  2. c# GetFunction(“Test8”).PCall()
  3. lua Test8()
  4. lua TestArgError()
  5. c# TestArgError()
  6. c# toluaL_exception(L, e)
LuaException: TestErrorStack:69: bad argument #1 to 'TestArgError' (number expected, got string)
stack traceback:[C]: in function 'TestArgError'TestErrorStack:69: in function <TestErrorStack:68>
LuaInterface.LuaDLL:luaL_argerror(IntPtr, Int32, String) (at Assets/ToLua/Core/LuaDLL.cs:692)
LuaInterface.LuaDLL:luaL_typerror(IntPtr, Int32, String, String) (at Assets/ToLua/Core/LuaDLL.cs:706)
TestLuaStack:TestArgError(IntPtr) (at Assets/ToLua/Examples/TestErrorStack/TestLuaStack.cs:151)
LuaInterface.LuaDLL:lua_pcall(IntPtr, Int32, Int32, Int32)
LuaInterface.LuaState:PCall(Int32, Int32) (at Assets/ToLua/Core/LuaState.cs:755)
LuaInterface.LuaFunction:PCall() (at Assets/ToLua/Core/LuaFunction.cs:96)
TestLuaStack:OnGUI() (at Assets/ToLua/Examples/TestErrorStack/TestLuaStack.cs:463)

TestFuncDispose

  1. “TestFuncDispose”
  2. c# func.Dispose();
  3. c# func.PCall();
LuaException: LuaFunction has been disposed
LuaInterface.LuaFunction:BeginPCall() (at Assets/ToLua/Core/LuaFunction.cs:73)
TestLuaStack:OnGUI() (at Assets/ToLua/Examples/TestErrorStack/TestLuaStack.cs:473)

SendMessage

  1. “SendMessage”
  2. c# gameObject.SendMessage(“OnSendMsg”);
  3. c# OnSendMsg()
  4. c# try { GetFunction(“TestStack.Test6”).PCall() }
  5. c# Test6()
  6. c# toluaL_exception(L, e);
LuaException: this a lua exception
stack traceback:[C]: at 0x613c2af0[C]: in function 'TestArgError'TestErrorStack:69: in function <TestErrorStack:68>
TestLuaStack:Test6(IntPtr) (at Assets/ToLua/Examples/TestErrorStack/TestLuaStack.cs:122)
LuaInterface.LuaDLL:lua_pcall(IntPtr, Int32, Int32, Int32)
LuaInterface.LuaState:PCall(Int32, Int32) (at Assets/ToLua/Core/LuaState.cs:755)
LuaInterface.LuaFunction:PCall() (at Assets/ToLua/Core/LuaFunction.cs:96)
TestLuaStack:OnSendMsg() (at Assets/ToLua/Examples/TestErrorStack/TestLuaStack.cs:277)
UnityEngine.GameObject:SendMessage(String)
TestLuaStack:OnGUI() (at Assets/ToLua/Examples/TestErrorStack/TestLuaStack.cs:481)

SendMessage() 等效于直接调用?

SendMessageInLua

  1. “SendMessageInLua”
  2. c# GetFunction(“SendMsgError”).PCall()
  3. lua SendMsgError(go)
  4. lua go:SendMessage(“OnSendMsg”);
LuaException: this a lua exception
stack traceback:[C]: at 0x613c2af0[C]: in function 'SendMessage'TestErrorStack:38: in function <TestErrorStack:37>[C]: in function 'TestArgError'TestErrorStack:69: in function <TestErrorStack:68>
TestLuaStack:Test6(IntPtr) (at Assets/ToLua/Examples/TestErrorStack/TestLuaStack.cs:122)
LuaInterface.LuaDLL:lua_pcall(IntPtr, Int32, Int32, Int32)
LuaInterface.LuaState:PCall(Int32, Int32) (at Assets/ToLua/Core/LuaState.cs:755)
LuaInterface.LuaFunction:PCall() (at Assets/ToLua/Core/LuaFunction.cs:96)
TestLuaStack:OnSendMsg() (at Assets/ToLua/Examples/TestErrorStack/TestLuaStack.cs:277)
UnityEngine.GameObject:SendMessage(String)
UnityEngine_GameObjectWrap:SendMessage(IntPtr) (at Assets/Source/Generate/UnityEngine_GameObjectWrap.cs:657)
LuaInterface.LuaDLL:lua_pcall(IntPtr, Int32, Int32, Int32)
LuaInterface.LuaState:PCall(Int32, Int32) (at Assets/ToLua/Core/LuaState.cs:755)
LuaInterface.LuaFunction:PCall() (at Assets/ToLua/Core/LuaFunction.cs:96)
TestLuaStack:OnGUI() (at Assets/ToLua/Examples/TestErrorStack/TestLuaStack.cs:488)

和 “SendMessage” 差不多一样。

AddComponent

  1. “AddComponent”
  2. c# GetFunction(“TestAddComponent”).PCall()
  3. c# TestAddComponent()
  4. c# try { go.AddComponent(); }
  5. c# TestInstantiate2.Awake()
  6. c# state.ThrowLuaException(e);
Exception: Instantiate exception 2
LuaInterface.LuaStatePtr.ThrowLuaException (System.Exception e) (at Assets/ToLua/Core/LuaStatePtr.cs:607)
TestInstantiate2.Awake () (at Assets/ToLua/Examples/TestErrorStack/TestInstantiate2.cs:16)
UnityEngine.GameObject:AddComponent()
TestLuaStack:TestAddComponent(IntPtr) (at Assets/ToLua/Examples/TestErrorStack/TestLuaStack.cs:237)
LuaInterface.LuaDLL:lua_pcall(IntPtr, Int32, Int32, Int32)
LuaInterface.LuaState:PCall(Int32, Int32) (at Assets/ToLua/Core/LuaState.cs:755)
LuaInterface.LuaFunction:PCall() (at Assets/ToLua/Core/LuaFunction.cs:96)
TestLuaStack:OnGUI() (at Assets/ToLua/Examples/TestErrorStack/TestLuaStack.cs:498)

TableGetSet

  1. “TableGetSet”

TestTableInCo

  1. “TestTableInCo”
  2. c# GetFunction(“TestCoTable”).PCall()
  3. lua TestCoTable()
  4. lua 运行协程 TestCo(…)
  5. lua TestTableInCo(…)
  6. c# TestTableInCo()

Instantiate2 Error

  1. “Instantiate2 Error”
  2. c# GetFunction(“Instantiate”).PCall() with go2
  3. lua Instantiate()
  4. lua UnityEngine.Object.Instantiate(obj)
  5. c# TestInstantiate2:Awake()
LuaException: Instantiate exception 2
stack traceback:[C]: in function 'Instantiate'TestErrorStack:13: in function <TestErrorStack:11>[C]: in function 'TestArgError'TestErrorStack:69: in function <TestErrorStack:68>
TestInstantiate2:Awake() (at Assets/ToLua/Examples/TestErrorStack/TestInstantiate2.cs:11)
UnityEngine.Object:Instantiate(Object)
UnityEngine_ObjectWrap:Instantiate(IntPtr) (at Assets/ToLua/BaseType/UnityEngine_ObjectWrap.cs:203)
LuaInterface.LuaDLL:lua_pcall(IntPtr, Int32, Int32, Int32)
LuaInterface.LuaState:PCall(Int32, Int32) (at Assets/ToLua/Core/LuaState.cs:755)
LuaInterface.LuaFunction:PCall() (at Assets/ToLua/Core/LuaFunction.cs:96)
TestLuaStack:OnGUI() (at Assets/ToLua/Examples/TestErrorStack/TestLuaStack.cs:573)

Instantiate3 Error

  1. “Instantiate3 Error”
  2. c# UnityEngine.Object.Instantiate(go2);
  3. c# TestInstantiate2.Awake()
Exception: Instantiate exception 2
LuaInterface.LuaStatePtr.ThrowLuaException (System.Exception e) (at Assets/ToLua/Core/LuaStatePtr.cs:607)
TestInstantiate2.Awake () (at Assets/ToLua/Examples/TestErrorStack/TestInstantiate2.cs:16)
UnityEngine.Object:Instantiate(GameObject)
TestLuaStack:OnGUI() (at Assets/ToLua/Examples/TestErrorStack/TestLuaStack.cs:580)

TestCycle

  1. “TestCycle”
  2. c# GetFunction(“TestCycle”).PCall()
  3. c# TestCycle()

测试递归调用 luaFunction

TestNull

  1. “TestNull”
  2. c# StartCoroutine(TestCo(action));

c# 中创建协程

TestMulti

  1. “TestMulti”
  2. c# GetFunction(“TestMulStack”).PCall()
  3. c# TestMulStack()
  4. c# try { TestMul0(); }
  5. c# TestMul1()
  6. throw

测试 tolua 例子 TestErrorStack相关推荐

  1. python基础教程:python实现PID算法及测试的例子

    今天小编就为大家分享一篇python实现PID算法及测试的例子,具有很好的参考价值,希望对大家有所帮助.一起跟随小编过来看看吧 PID算法实现 import timeclass PID:def __i ...

  2. Windows下安装谷歌测试框架Googletest并测试小例子

    一.下载 https://github.com/google/googletest/tree/master 下载并解压 新建一个build文件夹用于生成工程文件. 二.cmake 也可以使用cmake ...

  3. 关于read的例子和条件测试

    1.关于read比较两个的大小 #!/bin/sh read -t 10 -p "please input two num:" a b if [ $a -gt $b ]; then ...

  4. jmeter登录压力测试完整的例子

    今天记录一个完整的简单压力测试的例子. 1.badboy录制后台管理系统, 2.导入到jmeter,然后进行脚本修改,把js,jpg什么的都禁用掉 3.然后进行参数化:如图 4.然后进行场景设置: 5 ...

  5. A/B测试中我们都会犯的十个常见错误

    2019-11-29 20:51:46 作者:Romain AYRES 编译:ronghuaiyang 导读 这篇博客文章的目的不是告诉你在运行A/B测试时应该做什么,而是告诉你不应该做什么. &qu ...

  6. android cts测试二

    转宋立新大牛的博客 Android CTS 测试研究 宋立新 , Android , 博客 , CTS , 研究 Android CTS 测试研究 前言¶ 从各种渠道了解到 Android CTS 测 ...

  7. 编写 Solidity 测试脚本

    编写 Solidity 测试脚本 与 JavaScript 编写的测试脚本一样,基本特性也一直,支持净室环境,可以访问任意不说过的合约. Truffle的可靠性测试框架是基于以下想法构建的: Soli ...

  8. golang mysql 超时_golang中mysql建立连接超时时间timeout 测试

    本文测试连接mysql的超时时间. 这里的"连接"是建立连接的意思. 连接mysql的超时时间是通过参数timeout设置的. 1.建立连接超时测试 下面例子中,设置连接超时时间为 ...

  9. 《移动App测试实战》——2.2 App UI层面的自动化

    本节书摘来自华章出版社<移动App测试实战>一 书中的第2章,第2.2节,作者:邱鹏 陈吉 潘晓明,更多章节内容可以访问云栖社区"华章计算机"公众号查看. 2.2 Ap ...

  10. 说说初用 Mock 工具测试碰到的坑

    说说初用 Mock 工具测试碰到的坑 我是一个在校实习生,作为一个程序猿,是个菜鸟中战斗机!对于测试,只写过一点点简单到不能再简单了的 Junit 单元测试的例子(因为当时这足以应付学校课程的内容与要 ...

最新文章

  1. Linux slab 分配器剖析
  2. er图转为数据流程图_draw.io for Mac(流程图绘制工具)
  3. 小技巧之chm文件无法显示
  4. css3中的BFC,IFC,GFC和FFC(转载)
  5. jzoj6287-扭动的树【区间dp】
  6. C++工作笔记-仿大佬“容器”风格
  7. 凸优化与非线性优化基础(3)-- 二次规划Quadratic Programming
  8. 猎豹网校梁兴珍老师的python课程很不错
  9. STEAM无法打开创意工坊或成就页面
  10. Ring of Elysium 游戏汉化
  11. linux嗅探网站结构,Linux下的Dsniff嗅探浅析
  12. php --enable-maintainer-zts,我的PHP编译日志
  13. python输出被五整除的数_Python程序打印给定数字的所有被3和5整除的数字
  14. 车载网络结构(车内)-基础概念
  15. 电脑显示请检查映像服务器,该任务映像已损坏或已篡改的解决方法
  16. 【Qt】一文总结Qt5.15的在线安装
  17. python建立数据库连接时出错_python连接数据库
  18. 【JS基础】利用函数实现:用户输入一个数,判断是否是素数
  19. 继续教育计算机专业能学到东西吗,继续教育个人学习心得体会
  20. 用c语言编写研究生录取程序,C语言_课程设计---研究生初试录取管理系统.doc

热门文章

  1. Stuck Stack成过去时,OpenStack升级还可以这样玩?!
  2. android循环按键精灵,大神求解按键精灵固定时间循环
  3. 7.详解第三代移动通信系统——WCDMA、TD-SCDMA、CDMA2000
  4. 因果法制体系轮回框架的崛起
  5. 联想微型计算机m8000u配置,联想的产品介绍-20210412075714.pdf-原创力文档
  6. The RSpec Book笔记《四》Describing Code with RSpec用RSpec描述代码
  7. [信息论与编码理论专题-6]:物理层信道编码
  8. Xposed框架详解
  9. LayaBox---背景拖动
  10. 实验一 Linux基本操作