Re: assert in EUPHORIA
- Posted by DerekParnell (admin) Apr 22, 2012
- 1387 views
SDPringle said...
For the most part, UDT makes assert obsolete. The type routine verifies the data on each change. Sometimes independent data may have some relationship that is more temporary in this case you just want to check the result of an expression that should return true. I create a type and a public variable called truth like this:
type truth_type(integer x) return x = 1 end type public truth_type truth
Then to check something I assign the expression to truth.
-- buffer should have no more nulls truth = find(0,buffer) = 0
Although this will perform the testing correctly, it misses out on a couple of the useful aspects of the 'assert' concept.
- It always executes the test. The assert is intended to only execute the test during the development phase of the application.
- It's crash message is obscure - type failure - whereas the assert can be given a meaningful message to display.