Interesting idea!
Consider that a property is a simple thing that either exists or not. It's not meaningful to think of defining complex properties.
But you can also think of a property P as a boolean expression that means "test case has property P". That's the meaning of a property name when it is used as a condition, i.e. in when, whenNot, or <When>. And it is certainly helpful to think of defining complex conditions.
Below is an example of how it might look. What do you think?
Named conditions can be defined inside a <Define> element. Conditions can be defined for a <System>, in which case they apply to all functions, or for a single <Function> only. A <Condition> definition can have either of the two usual forms.
- either a combination of "when" and/or "whenNot" attributes (see line 4)
- or the same kind of boolean expression elements used in a <When> element (see line 10)
Afterward, the name of a <Condition> can be used like a property name in any conditions, i.e. when, whenNot, or <When> (see line 20 and line 23). But it would be an error for a <Condition> name to appear in a property assertion (see line 28) -- a property is a condition, but a condition is not a property!
1 <System name="Examples">
2 <Define>
3 <!-- Conditions defined here are visible to all functions -->
4 <Condition name="c1" when="p, q, r" whenNot="x, y, z"/>
5 </Define>
6
7 <Function name="WithDefines">
8 <Define>
9 <!-- Conditions defined here are visible only to this function -->
10 <Condition name="c2">
11 <AllOf>
12 <Not property="p"/>
13 <AnyOf property="q, r"/>
14 </AllOf>
15 </Condition>
16 </Define>
17
18 <Input>
19 <Var name="V">
20 <Value name="A" when="c1" whenNot="c2"/>
21 <Value name="B">
22 <When>
23 <AnyOf property="c1, c2"/>
24 </When>
25 </Value>
26
27 <!-- No! Can't use a condition name here. A <Condition> is not a property. -->
28 <Value name="C" property="c1"/>
29 </Var>
30 </Input>
31 </Function>
32 </System>