Such expressions are checked during the code execution and, if a violation is detected, a message is presented. They usually represent pre- or postconditions at some control point in the program. Therefore, defining procedures to interpret oracles which use such a source of information can be challenging.Įmbedded assertion languages 1 allow one to insert expressions of intent within the code to be tested. Such languages are usually not designed with the concern of being automatically interpreted. Oracles based on pure specification are those in which the tester uses a specification language to describe the desired behavior of a system or part of it for later use as a source for the oracle, i.e., as the oracle information. These three oracle contracts differ from each other in the way they are written with respect to the code. Nardi, in Advances in Computers, 2014 3.3.1.1 Specification Locationīaresi and Young present groups of oracles according to certain similarities, among them: oracles of pure specification language, embedded assertion languages, and extrinsic interface contracts. For the moment, you only need to know that we can use the raise statement with a TypeError exception to stop a function's execution and throw an error with a specific text. This and other techniques for controlling errors are explored further in Chapter 10. To prevent this, you can put a check to tell the user the function has not been used properly. If the user inputs a list or a string as one of the input variables, then the function will throw an error or have unexpected results. For example, the function my_adder in the previous chapter expects doubles as input. Sometimes you want to design your function to check the inputs of a function to ensure that your function will be used properly. There are also functions that can tell you information about arrays of logicals like any, which computes to true if any element in an array is true, and false otherwise, and all, which computes to true only if all the elements in an array are true. For example, you can ask if a variable has a certain data type with function isinstance. There are many logical functions that are designed to help you build branching statements.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |