如何在 VBScript 脚本中断言?
What is a good way to use asserts in VBScript scripts?
Is there built-in functionality for it or will it have to be emulated? What is best practice?
One application is to test for objects being Nothing
during development.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一个可操作的答案(对于其他可能需要它的人)是定义这个函数,来自 Rosetta Code:
调用:
输出:
An operational answer (for others that may need it) is to define this function, from Rosetta Code:
Invocation:
Output:
遗憾的是,我不相信 VBScript 有任何内置的东西。您需要定义自己的
Assert
方法,并可能在构建脚本的发布副本时使用预处理器构建脚本或其他方法来删除它们。 (实际上,删除 - 至少注释掉 -Assert
调用是最好的,而不是仅仅使Assert
的主体在发布的代码中不执行任何操作。)Sadly, I don't believe VBScript has anything built-in. You'll need to define your own
Assert
method and probably use a pre-processor build script or something to remove them when building a release copy of your script. (Actually removing -- at least commenting out -- theAssert
call is best, rather than just making the body of theAssert
not do anything in the released code.)