Name | Executed | Routines | % | Executed | Lines | % | Unexecuted |
/home/matt/eu/rds/include/std/utils.e | 1 | 1 | 100.00% | 4 | 4 | 100.00% | 0 |
Routine | Executed | Lines | Unexecuted | |
iff() | 4 | 4 | 100.00% | 0 |
# | Executed | |
1 | -- (c) Copyright - See License.txt | |
2 | -- | |
3 | ||
4 | --**** | |
5 | -- == utils | |
6 | -- | |
7 | -- < | |
8 | ||
9 | namespace utils | |
10 | ||
11 | ||
12 | --** | |
13 | -- Used to embed an 'if' test inside an expression. | |
14 | -- | |
15 | -- Parameters: | |
16 | -- # ##test## : an atom, the result of a boolean expression | |
17 | -- # ##ifTrue## : an object, returned if ##test## is **non-zero ** | |
18 | -- # ##ifFalse## : an object, returned if ##test## is zero | |
19 | -- | |
20 | -- Returns: | |
21 | -- An object. Either ##ifTrue## or ##ifFalse## is returned depending on | |
22 | -- the value of ##test##. | |
23 | -- | |
24 | -- Example 1: | |
25 | -- | |
26 | -- msg = sprintf("%s: %s", { | |
27 | -- iff(ErrType = 'E', "Fatal error", "Warning"), | |
28 | -- errortext } ) | |
29 | -- | |
30 | ||
31 | 2 | |
32 | -- returns ifTrue if flag is true, else returns ifFalse | |
33 | 2 | if test then |
34 | 1 | return ifTrue |
35 | end if | |
36 | 1 | return ifFalse |
37 | end function | |
38 |