Language test language
Language test language provides useful interface for making test for languages. It lets describe nodes properties using annotations.
In order to create tests
LanguageTest aspect should be created. In popup menu of language chose
New->New LanguageTest Aspect.
NodesTestCase concept in model
Language test consists of three sections:
- List of nodes to test. This nodes are not generated into code and remain as is. This nodes can be referenced by adding adding annotations.
- Methods witch performs testing.
- Utility methods, than can be used to avoid code duplicates.
In order to check node operations reference to node is created at first. To refer to node
TestAnnotation is used. Annotation is added to node by intention, clicking or pressing (
Alt + Enter).
Each annotation has name and can be referenced by this name from code.
Then test code should be written in this code is performing operations with nodes. In order to write assertions of Unit test language assertion are used. To compare nodes new assertion added:
compares two lists of nodes.
Example of test:
In order to check type of node following instruction can be used.
It checks that
node has type
In order to check node and in descendants for errors following operation is used.
Properties, witch should be checked are specified by annotations, witch can be added by intention
Add node properties annotation.
Node can have following properties:
- Node has error;
- Node has warning;
- Node has specified type.
If node hasn't any annotation it checked for absence of errors and warnings.
There is example of type checking:
check ... type errors statement, operation annotation can be used. It can be added by
Add test operation annotation intention.
Data flow tests
To check data flow following statement should be added.
It calculates dataflow for node, and check properties specified by annotations. Following properties can be checked.
reachable- this node reachable;
unreachable- this node unreachable;
variable initialized- variable initialized in this node;
variable live- variable live in this node.
Instead if using
check node dataflow check dataflow operation can be added.
Model should be generated before running tests. To start tests shortcut
(Ctrl + Shift + F10) or pop-up menu item.