-
Book Overview & Buying
-
Table Of Contents
Learn Bosque Programming
By :
Bosque support statements validation through the reserved assert and check keywords, which are very useful for writing tests; the main difference between them is that the first is available only in debug time, and the second is included in the final build.
A false evaluation is interpreted as an error at debug time. This is provided as a report containing the error line number, an error code, and the call-stack, which are very useful for making corrections. On the other hand, once a build is generated, the errors become generic and indistinguishable.
Let's see an example:
function test_nth_prime_number(x: Int): Bool {
assert nth_prime_number(50) = 229;
assert nth_prime_number(100) = 541;
assert nth_prime_number(1000) = 7919;
return true;
}
In the previous code, we can see how to use the assert function to do an equality validation in order to test...