Child pages
  • Language tests language
Skip to end of metadata
Go to start of metadata

Language test language


Language test language provides useful interface for making test for languages. It lets describe nodes properties using annotations.

Tests creation

In order to create tests LanguageTest aspect should be created. In popup menu of language chose New->New LanguageTest Aspect.

Then create NodesTestCase concept in model languageTest.

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.

Simple tests

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:

 assert <node1,node2, ...> match <node1,node2, ...>

compares two lists of nodes.

Example of test:

Type tests

In order to check type of node following instruction can be used.

 assert node has type t

It checks that node has type t.

In order to check node and in descendants for errors following operation is used.

check node type errors;

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:

Instead of 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.

check node dataflow

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.

Tests running

Model should be generated before running tests. To start tests shortcut (Ctrl + Shift + F10) or pop-up menu item.

Previous Next

  • No labels