Transformation of Applicative Specifications into Imperative ...

Transformation of Applicative Specifications into Imperative ... Transformation of Applicative Specifications into Imperative ...

26.09.2013 Views

CHAPTER 11. TEST 11.1.1 Lexer and Parser The code of the lexer and parser is generated automatically from the grammar file using the ANTLR tool. The grammar file used originates from the RSL2Java tool as described in Chapter 9, but it is extended in order to comply with RSLA. Furthermore, a few changes have been necessary. The automatically generated code from the original grammar file is tested in the project described in [Hja04]. Furthermore, as the code is automatically generated a black box test or a grey box test is the most obvious choice. 11.1.2 RSL AST The many classes forming the RSL AST are generated automatically from the specification of the RSL AST using the RSL2Java tool. The only exception is the abstract class RSLElement.java. The RSL AST specification used originates from the RSL2Java tool as described in Chapter 9, but it is extended in order to comply with RSLI and furthermore, a few necessary changes have been implemented. As the code is automatically generated and as the most of the functionality has been tested in the RSL2Java tool project, a black box test would be appropriate. 11.1.3 Visitors The visitors are implemented by hand, but this implementation is straight forward when the RSL AST is specified. The visitors used originate from the RSL2Java tool as described in Chapter 9, but they are extended in order to comply with the new RSL AST. As the visitors are implemented by hand a white box test can be performed, but as the implementation of the visitors follows a straight forward pattern, a white box test should not be necessary. 11.1.4 Transformer The classes forming the transformer are generated automatically from the specification of the transformer in RSL1 using the RSL2Java tool. As the transformer is automatically generated a white box test is very complicated, especially considering the amount of code generated. A black box test would not suffice considering the complexity of the transformer. The obvious choice is a grey box test. 11.1.5 Control Module The control module RSLRunner.java is implemented by hand and the functionality is crucial to the transformer program. 120

11.2. CHOICE OF TESTS This means that a black box test should be performed to test the functionality, both for correct and incorrect input. A white box test could be performed in order to test the program structure but as the logic of the program is very straight forward and because many of the branches in the program structure can only be reached through system errors a black box test of the control module is to prefer. 11.2 Choice of Tests The considerations discussed above leads to the following tests of the transformer: 1. A grey box test of the program as a whole. In this way all parts of the program will be tested. 2. A black box test of the control module. The decision that the system should be tested as a whole is made for several reasons. Parts of the lexer, parser, RSL AST and the visitors are already tested in the RSL2Java tool project. By making a thorough test of the whole system, all parts of these components will be used. Furthermore, the possibility that e.g. an error in the parser would be balanced out later in the process of the transformer is negligible. 11.2.1 Grey Box Test of the Program The grey box test of the program was performed by transforming different applicative RSL specifications, both transformable and not transformable specifications, and by introducing one or more types of interest. The results of the transformation were then compared with the transformation rules of Chapter 6 if transformable, and with the conditions for transformability if not transformable. If transformable, the result of the transformation was also type checked using the RSL type checker. The test specifications are chosen such that all corners of RSLA are reached. That way all parts of the lexer and parser, the visitor modules, the RSL AST code and the transformer module itself are tested. Furthermore, specifications that could lead to problems are tested. These are chosen based on knowledge of the inner working of the program. An example is that the expected type of a value expression has to be carried on the right way through the transformation. For example, when transforming the product expression (x, (y, z)) of expected type Int × ( Bool × Text), then x should have the expected type Int and (y, z) should have the expected type Bool × Text. But then again it is not necessary to test whether y has expected type Bool and z has expected type Text during the transformation due to the recursive structure of the transformer module. 121

11.2. CHOICE OF TESTS<br />

This means that a black box test should be performed to test the functionality,<br />

both for correct and incorrect input. A white box test could be<br />

performed in order to test the program structure but as the logic <strong>of</strong> the<br />

program is very straight forward and because many <strong>of</strong> the branches in the<br />

program structure can only be reached through system errors a black box<br />

test <strong>of</strong> the control module is to prefer.<br />

11.2 Choice <strong>of</strong> Tests<br />

The considerations discussed above leads to the following tests <strong>of</strong> the transformer:<br />

1. A grey box test <strong>of</strong> the program as a whole. In this way all parts <strong>of</strong> the<br />

program will be tested.<br />

2. A black box test <strong>of</strong> the control module.<br />

The decision that the system should be tested as a whole is made for<br />

several reasons. Parts <strong>of</strong> the lexer, parser, RSL AST and the visitors are<br />

already tested in the RSL2Java tool project. By making a thorough test <strong>of</strong><br />

the whole system, all parts <strong>of</strong> these components will be used. Furthermore,<br />

the possibility that e.g. an error in the parser would be balanced out later<br />

in the process <strong>of</strong> the transformer is negligible.<br />

11.2.1 Grey Box Test <strong>of</strong> the Program<br />

The grey box test <strong>of</strong> the program was performed by transforming different<br />

applicative RSL specifications, both transformable and not transformable<br />

specifications, and by introducing one or more types <strong>of</strong> interest. The results<br />

<strong>of</strong> the transformation were then compared with the transformation rules <strong>of</strong><br />

Chapter 6 if transformable, and with the conditions for transformability if<br />

not transformable. If transformable, the result <strong>of</strong> the transformation was<br />

also type checked using the RSL type checker.<br />

The test specifications are chosen such that all corners <strong>of</strong> RSLA are<br />

reached. That way all parts <strong>of</strong> the lexer and parser, the visitor modules,<br />

the RSL AST code and the transformer module itself are tested.<br />

Furthermore, specifications that could lead to problems are tested. These<br />

are chosen based on knowledge <strong>of</strong> the inner working <strong>of</strong> the program. An<br />

example is that the expected type <strong>of</strong> a value expression has to be carried on<br />

the right way through the transformation. For example, when transforming<br />

the product expression (x, (y, z)) <strong>of</strong> expected type Int × ( Bool × Text),<br />

then x should have the expected type Int and (y, z) should have the expected<br />

type Bool × Text. But then again it is not necessary to test whether y has<br />

expected type Bool and z has expected type Text during the transformation<br />

due to the recursive structure <strong>of</strong> the transformer module.<br />

121

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!