本文介绍了浅谈和断言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试一些闲聊+ TDD +好的做法"我遇到了一个丑陋的障碍:
Tryng out some smalltalk + TDD + "good practices" I've run into a kinda ugly block:
如何在GNU Smalltalk中进行断言?
How do I do an assertion in GNU Smalltalk?
我只是在寻找一种简单的ifFalse: [Die]
东西
I'm just looking for a simple ifFalse: [Die]
kind of thing
推荐答案
这是用于声明的代码:来自 Squeak (我建议您使用它而不是GNU):
This is the code for assert: from Squeak (which I recommend you use rather than GNU):
assert: aBlock
"Throw an assertion error if aBlock does not evaluates to true."
aBlock value
ifFalse: [AssertionFailure signal: 'Assertion failed']
这篇关于浅谈和断言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!