Re: assert in EUPHORIA

new topic     » goto parent     » topic index » view thread      » older message » newer message
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.

  1. It always executes the test. The assert is intended to only execute the test during the development phase of the application.
  2. It's crash message is obscure - type failure - whereas the assert can be given a meaningful message to display.
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu