Working with sanity checks in Bosque
We have already partially covered this topic in Chapter 3, Bosque Key Features. We talked about the invariant
keyword, and the requires
, requires release
, and ensures
conditions. We also mentioned the assertions and checks. Let's see how we can use them in practice along with the SymTest tool.
Before we get started let’s consider an example program. It’s not going to be rocket science. For the sake of this chapter we will build a simple Bin2Dec converter. It will take the provided binary number and return its decimal representation. We will limit the binary representation to four bits and will require every bit to be passed as a separate argument. It may look a bit inconvenient and it’s true but it will make you understand the SymTest tool better.
At this point you already know the Bosque syntax and most of the rules so I won’t dive deep into the implementation. Have a look at the following code:
namespace...