Transformation of Applicative Specifications into Imperative ...
Transformation of Applicative Specifications into Imperative ... Transformation of Applicative Specifications into Imperative ...
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
- Page 86 and 87: CHAPTER 7. CORRECTNESS OF TRANSFORM
- Page 88 and 89: CHAPTER 8. SPECIFICATIONS The rewri
- Page 90 and 91: CHAPTER 8. SPECIFICATIONS RSL speci
- Page 92 and 93: CHAPTER 8. SPECIFICATIONS The FUNC
- Page 94 and 95: CHAPTER 8. SPECIFICATIONS out, that
- Page 96 and 97: CHAPTER 8. SPECIFICATIONS construct
- Page 98 and 99: CHAPTER 8. SPECIFICATIONS 8.4.1 Mor
- Page 100 and 101: CHAPTER 8. SPECIFICATIONS PRECOND_T
- Page 102 and 103: CHAPTER 8. SPECIFICATIONS if length
- Page 104 and 105: CHAPTER 8. SPECIFICATIONS subtypes.
- Page 106 and 107: CHAPTER 8. SPECIFICATIONS 8.5.2 Cha
- Page 108 and 109: CHAPTER 8. SPECIFICATIONS axiom [ m
- Page 110 and 111: CHAPTER 8. SPECIFICATIONS Specifica
- Page 112 and 113: CHAPTER 8. SPECIFICATIONS the lack
- Page 114 and 115: CHAPTER 9. IMPLEMENTATION OF THE TR
- Page 116 and 117: CHAPTER 9. IMPLEMENTATION OF THE TR
- Page 118 and 119: CHAPTER 9. IMPLEMENTATION OF THE TR
- Page 120 and 121: CHAPTER 9. IMPLEMENTATION OF THE TR
- Page 122 and 123: CHAPTER 9. IMPLEMENTATION OF THE TR
- Page 124 and 125: CHAPTER 9. IMPLEMENTATION OF THE TR
- Page 126 and 127: CHAPTER 10. EXAMPLES OF TRANSFORMAT
- Page 128 and 129: CHAPTER 10. EXAMPLES OF TRANSFORMAT
- Page 130 and 131: CHAPTER 10. EXAMPLES OF TRANSFORMAT
- Page 132 and 133: CHAPTER 10. EXAMPLES OF TRANSFORMAT
- Page 134 and 135: CHAPTER 10. EXAMPLES OF TRANSFORMAT
- Page 138 and 139: CHAPTER 11. TEST An overview of the
- Page 140 and 141: CHAPTER 12. POSSIBLE EXTENSIONS OF
- Page 142 and 143: CHAPTER 12. POSSIBLE EXTENSIONS OF
- Page 144 and 145: CHAPTER 12. POSSIBLE EXTENSIONS OF
- Page 146 and 147: CHAPTER 13. CONCLUSION RSL AST and
- Page 148 and 149: CHAPTER 13. CONCLUSION 132
- Page 150 and 151: BIBLIOGRAPHY [ST02] Donald Sannello
- Page 152 and 153: APPENDIX A. USING AND EXTENDING THE
- Page 154 and 155: APPENDIX A. USING AND EXTENDING THE
- Page 156 and 157: APPENDIX B. CONTENTS OF CD-ROM 140
- Page 158 and 159: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 160 and 161: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 162 and 163: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 164 and 165: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 166 and 167: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 168 and 169: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 170 and 171: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 172 and 173: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 174 and 175: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 176 and 177: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 178 and 179: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 180 and 181: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 182 and 183: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 184 and 185: APPENDIX C. FORMAL SPECIFICATIONS O
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