-
-
Notifications
You must be signed in to change notification settings - Fork 0
expect
The @{Expect} class implements a unidirectional single path compute graph and can be viewed as a form of assertion definition language. It provides methods that are easy to use and fast to declare as long as the subject has a clearly defined structure.
Assertions can be described as premises that must evaluate to a true state. The outcome of a successive set of test can be viewed as a sequence of statements that are conjoined together with an and
. Because of the logical conjunction, the first falsy in the sequence will then imply that any further assertions can be dismissed. This is the default case.
In some cases it is only necessary that one of a few tests has a true state. Because of the logical disjunction, the first truthy in the sequence will then imply that any further tests can be dismissed. This is what happens when several assertions are run in sequence, and each fail hard.
NOTE: It is not clear how the logical connectives should be set for a logical disjunction of assertions.
This is delayed actions to chose among several argument values. The numbered versions @{Expect:first} to @{Expect:twelfth} will only pick and return a single value among the varargs, but the generalized method @{Expect:pick} can pick and return several. The same holds for @{Expect:filter}, each value is run through the filter callback and if it returns true then the value is kept.
This is delayed actions to somehow transform the provided values. The delayed action will map its transform over each value and return the result. That is the same, but somehow transformed value. The same holds for the generalized @{Expect:map}, each value is run through the map callback and the result is kept.
This is delayed actions to compare the values. The delayed action will compare one or more stored values with the provided values, and then return a boolean value. If the length of the stored values and the provided values does not match, then the shorter is broadcast over the longer. The broadcast algorithm compares two elements, using the true index into the longer one, and using a modulus index for the shorter one. As an optimization it will return false immediately if either length is zero, but if the lengths are equal and non-zero the modulus operation will be skipped.