-
Notifications
You must be signed in to change notification settings - Fork 2
IDL Language
This language is in inspirited from the input format of the combinatorial testing tool Pairwise Interdependent Combinatorial Testing (PICT) by Microsoft, where constraints among inputs parameters can be defined using invariants, conditional definitions (if/then/else) logical operators and relational operates.
The key elements of the language are terms and predicates. Both of them can evaluate to true or false. A term is an atomic element of the language and can be represented by:
Model:
Dependency*;
Dependency:
RelationalDependency | ArithmeticDependency |
ConditionalDependency | PredefinedDependency;
RelationalDependency:
Param RelationalOperator Param;
ArithmeticDependency:
Operation RelationalOperator DOUBLE;
Operation:
Param OperationContinuation |
'(' Operation ')' OperationContinuation?;
OperationContinuation:
ArithmeticOperator (Param | Operation);
ConditionalDependency:
'IF' Predicate 'THEN' Predicate;
Predicate:
Clause ClauseContinuation?;
Clause:
(Term | RelationalDependency | ArithmeticDependency
| PredefinedDependency) | 'NOT'? '(' Predicate ')';
Term:
'NOT'? (Param | ParamValueRelation);
Param:
ID | '[' ID ']';
ParamValueRelation:
Param '==' STRING('|'STRING)* |
Param 'LIKE' PATTERN_STRING | Param '==' BOOLEAN |
Param RelationalOperator DOUBLE;
ClauseContinuation:
('AND' | 'OR') Predicate;
PredefinedDependency:
'NOT'? ('Or' | 'OnlyOne' | 'AllOrNone' |
'ZeroOrOne') '(' Clause (',' Clause)+ ')';
RelationalOperator:
'<' | '>' | '<=' | '>=' | '==' | '!=';
ArithmeticOperator:
'+' | '-' | '*' | '/';
A parameter's name (e.g., p1) being evaluated as true if the parameter is set (regardless of the value), of false otherwise; or a parameter-value relation, evaluated as true if the parameter is selected and satisfies the relation. This relation can be defined using a standard relation operators (e.g, p1>=100) or a wild card match (using the operator LIKE), if the parameter is a string, with ' * ' meaning zero or more characters and '?' meaning one character (e.g, p3 LIKE 'test_*'). A predicate is a combination of one or more terms and dependencies joins by the logical operators NOT, AND, and OR. Parentheses are allowed in order to specify the operator priority. In what follows, we describe the IDL notation of each type of dependency:
This type of dependency is expressed as "IF predicate THEN predicate;", where the first predicate is the condition and the second is the consequence. The following listing shows two examples. Dependency in line 2, for instance, indicates that invocations including the parameters p1 and p2 should not include p3 nor p4, otherwise the call would be invalid:
1. IF p1 THEN p2=='A';
2. IF p1 AND p2 THEN NOT (p3 OR p4);
This type of dependency is expressed using the keyword "Or" followed by a list of two or more predicates placed inside parentheses: "Or(predicate, predicate [, ...]);". The dependency is satisfied if at least one of the predicates evaluates to true. Two examples follow. Dependency in line 1, for instance, specifies that valid invocations should include at least one of the parameters p1, p2 or p3
1. Or(p1, p2, p3);
2. Or(p1, p3 AND p5, p6=='B');
These dependencies are specified using the keyword "OnlyOne" followed by a list of two or more predicates placed inside parentheses: "OnlyOne(predicate, predicate[, ...]);". The dependency is satisfied if one, and only one of the predicates values is true. Examples of this dependency are shown below. The dependency in line 1, for example, indicates that valid invocations should be included either the parameter p1 or the parameter p2 with value 'B', but not booth at the same time.
1. OnlyOne(p1, p2=='B');
2. OnlyOne(p1 Or p2, p3 AND (p4 OR p5);
This type of dependency is specified using the keyword "AllOrNone" followed by a list of two or more predicates placed inside parentheses: "AllOrNone(predicate, predicate [, ...]);". The dependency is satisfied if either all the predicates evaluate to true, or all of them evaluate to false. The dependency in line 1 below, for instance, indicates that valid calls are those including either the parameter p1 and p2 with value true, or conversely, those not including the parameter p1 and p2 with value true, or conversely, those not including the parameter p1 and not in including p2 with value true.
1. AllOrNone(p1, p2==true);
2. AllOrNone(p1 AND p2, p3 LIKE 'test_*' OR p4<10);
These dependencies are specified using the keyword “ZeroOrOne” followed by a list of two or more predicates placed inside parentheses: “ZeroOrOne(predicate, predicate [, ...]);”. The dependency is satisfied if none or at most one of the predicates evaluates to true. Two examples follow. Line 2, for instance, specifies that valid invocations must meet zero or one (but not both) of the two conditions between parentheses: (1) including the parameter p1, or (2) including.
1. ZeroOrOne(p1, p2, p3, p4);
2. ZeroOrOne(p1, p2<=100);
Relational dependencies are specified as pairs of parameters joined by any of the following relational operators: ==, !=, <=, <, >= or > (see examples in lines 1 and 2 below). Arithmetic dependencies relate two or more parameters using the operators +, - , *, / followed by a final comparison using a relational operator. Lines 3 and 4 of the following listing show examples of arithmetic dependencies.
1. p1 < p2;
2. p1 != p2;
3. p1 + p2 - p3 * p4 == 100;
4. p1 * p2 / ((p3 - p4) * p5) < 176.89;
These dependencies are specified as a combination of the previous ones since, as previously mentioned, predicates can contain other dependencies. As an exception to this rule, predicates cannot include Requires dependencies to avoid over-complicated specifications (such dependencies can be expressed in simpler ways). The following listing shows some examples of complex dependencies. Dependency in line 1 combines four different types of dependencies: Requires, ZeroOrOne, OnlyOne and Relational.
1. IF p1 THEN ZeroOrOne(p2, OnlyOne(p3, p4>p5));
2. AllOrNone(p1+p2<100, Or(p3=='A', Or(p4, p5>p6));
AllOrNone(p1+p2<100, Or(p3=='A', Or(p4, p5>p6)); It is worth making a few general clarifications about the language regarding dependencies Or, OnlyOne, AllOrNone and ZeroOrOne. These are not strictly necessary, as they could be translated to several Requires dependencies. However, they are provided as syntactic sugar to make specifications succinct and self-explanatory. An example is given in the following IDL excerpt (lines 1-3). Secondly, they cannot contain negated elements within their parentheses, since such constraints can be expressed in simpler ways (lines 5- 6). Finally, they can optionally be preceded by the keyword “NOT” to negate the meaning of the constraint (see line 8 below for an example).
1. AllOrNone(p1, p2); // Equivalent to 1) and 2):
2. IF p1 THEN p2; // 1)
3. IF p2 THEN p1; // 2)
4.
5. Or(p1, NOT p2); // Invalid dependency
6. IF p2 THEN p1; // Equivalent to line 5
7.
8. NOT OnlyOne(p1, p2); // Valid negated dependency
Listing 2 depicts the IDL specification of the Google Maps Places API [18]. It comprises seven operations, four of which have dependencies. The API has eight dependencies in total, including six out of the seven types of dependencies supported in IDL (all of them except the complex ones), namely:
- Line 2: If the parameter radius is used, then rankby cannot be set to ‘distance’, and vice versa.
- Line 3: If the parameter rankby is set to ‘distance’, then at least one of the following parameters must be present: keyword, name or type.
- Line 4: The parameter maxprice must be greater than or equal to minprice.
- Line 7: Either both location and radius are used, or none of them.
- Line 8: query and type are both optional parameters, but at least one of them must be used.
- Line 9: Equal to line 4.
- Line 12: One, and only one of the parameters maxheight and maxwidth must be used.
- Line 15: If the parameter strictbounds is used, then both location and radius must be used as well.
1. // Operation: Search for places within specified area:
2. ZeroOrOne(radius, rankby=='distance');
3. IF rankby=='distance' THEN keyword OR name OR type;
4. maxprice >= minprice;
5.
6. // Operation: Query information about places:
7. AllOrNone(location, radius);
8. Or(query, type);
9. maxprice >= minprice;
10.
11. // Operation: Get photo of place:
12. OnlyOne(maxheight, maxwidth);
13.
14. // Operation: Automcomplete place name:
15. IF strictbounds THEN location AND radius;