![]() |
![]() |
![]() |
![]() |
![]() |
The keyword is used to specify user-defined structured types, subtypes or behavior types ( function type, altstep type or testcase type).
Related keyword:
type ( record | union | set | record of | set of | enumerated | port | component ) identifier { body }; |
The type keyword introduces the type definition.
record denotes an ordered structured type.
union is a structure which can take one and only one of a finite number of known types.
set denotes an unordered structured type.
record of denotes a record the elements of which are all of the same type.
set of denotes a set the elements of which are all of the same type.
enumerated stands for a type that take only a distinct named set of values.
port defines the messages or procedures allowed to pass the port in question.
component defines which ports are associated with a component.
identifier is the name used to refer to the structured type. Must begin with a letter, may contain letters, numbers and underscore characters.
body contains the type definition itself. Its content differs from type to type.
Another use of the keyword is the subtype definition.
type parent_identifier ( identifier | address) [ array_def] [ ( list )] [length] [ ; ] |
The type keyword introduces the type definition.
parent_identifier is the name used to refer to the parent type. Must begin with a letter, may contain letters, numbers and underscore characters.
identifier is the name used to refer to the sub-type. Must begin with a letter, may contain letters, numbers and underscore characters.
address is a user defined type to allow addressing specific entities inside the System Under Test.
array_def restricts the indices of the parent type.
list is a comma-separated enumeration of the allowed values out of the values defined for the parent type.
length can be used with set of and record
of types to limit the number of the elements of the structured type in question.
When the parent type is a basic string type, the keyword constraints the length of the string.
Example 1:
type enumerated Example {tisdag, fredag, onsdag};
The enumerated type called Example containing three elements is defined.
Example 2:
type Ex_subt Example (tisdag, onsdag);
The sub-type, called Ex_subt, may contain only two elements of the parent type (called Example).
Another use of the keyword is the behavior type definition.
It introduces a function type, an altstep type or a testcase type.
A function, altstep or testcase has the given type if its formal parameter list, runs on type and returned value type is the same as given in the type definition.
type function Function_type_name ( formal_parameter_list ) [ runs on component_type_ref ] [return returned_type ] [;] |
The type function keywords introduce the type definition.
Function_type_name is the name used to refer to the function type. Must begin with a letter, may contain letters, numbers and underscore characters.
formal_parameter_list is the list of the formal parameters (arguments). See the definion of function.
component_type_ref  See the definion of function.
returned_type See the definion of function.
Example 3:
type function F_type(in integer pl_i) runs on CT returns charstring; // line 1
function f(in integer pl_ii) runs on CT returns charstring { log(pl_ii);return "Hello" }; // line 2
var F_type v_f := refers(f); // line 3
var CT v_comp := CT.create; // line 4
v_comp.start(derefers(v_f)(1));// line 5
v_f.apply(2); // line 6
Line 1: Function type "F_type" is defined. Its parameter is type of integer and it is an "in" parameter. It runs on CT and its return value a charstring.
Line 2: The function f defined here has type of F_type.
Line 3: The function reference variable v_f has a type of function (reference) type F_type and its value is defined here as a reference to function f. This definition is valid because v_f refers to the same type as f.
Line 5: The behavior function referenced by v_f is started on component v_comp.
Line 6: The function referenced by v_f is called. It is the same as calling f(2).
type altstep altstep_identifier ( [ altstep_parameter ... ] ) runs on component_type_ref [ ;] |
The type altstep keywords introduce the altstep type definition.
Details can be found in altstep.
Example 4:
type component CT {}
type altstep As_type() runs on CT
altstep as_1() runs on CT {
[else] {}
}
testcase tc() runs on CT {
var As_type v_as := refers(as_1);
v_as.apply(); //same as "as_1();"
};
type testcase testcase_identifier ( [ testcase_parameters ... ] ) runs on component_type_ref [ system system_component_type_ref ] [ ; ] |
The type testcase keywords introduce the test case type definition.
Details can be found in testcase.
BNF definition of type