-
Notifications
You must be signed in to change notification settings - Fork 1
RALF Language Unit Tests
lunkpeter edited this page Jun 29, 2015
·
7 revisions
#RALF Language Unit Tests
At this point the following two main test case categories are defined:
- Validator test cases: These unit tests check if the validator component properly detects invalid code segments.
- Parser test cases: These unit tests check is the parser creates the correct AST, which represents the input code. Typically both test case categories are aiming at covering all the possible input combinations of the expression or statement under test.
The following primitive literals types are defined in rALF: Integer, String, Real, Boolean. These test cases check if these literals can be properly defined. These test cases can be found here
| Test case name | Input code | Description |
|---|---|---|
| booleanLiteralExpressionTrue() | true; | Checks if a boolean literal with the value of true can be defined |
| booleanLiteralExpressionFalse() | false; | Checks if a boolean literal with the value of false can be defined |
| naturalLiteralExpressionDecimal() | 123; | Checks if a well-formed decimal integer literal can be defined |
| naturalLiteralExpressionBinary() | 0b010101010101; | Checks if a well-formed binary integer literal can be defined |
| naturalLiteralExpressionHex() | 0xAE10; | Checks if a well-formed hexadecimal integer literal can be defined |
| naturalLiteralExpressionUnderscore() | 123_456; | Checks if a well-formed integer literal with underscore can be defined |
| stringLiteralExpression() | "ABC"; | Checks if a well-formed String literal can be defined |
| stringLiteralExpressionBreak() | "AB\C"; | Checks if a well-formed String literal with breaked / can be defined |
The following test cases check if parentheses and unary operators are properly validated. These test cases can be found here
| Test case name | Input code | Description |
|---|---|---|
| parenthesisInteger() | (1); | Checks if an integer literal can be written in parentheses |
| parenthesisBoolean() | (true); | Checks if a boolean literal can be written in parentheses |
| parenthesisString() | ("String"); | Checks if a string literal can be written in parentheses |
| parenthesisReal() | (1.1); | Checks if a real literal can be written in parentheses |
| parenthesisAdditive() | (1+2); | Checks if an addition expression can be written in parentheses |
| parenthesisAdditive() | (1+2); | Checks if an addition expression can be written in parentheses |
| parenthesisAdditive() | (1+2); | Checks if an addition expression can be written in parentheses |
| parenthesisAdditive() | (1+2); | Checks if an addition expression can be written in parentheses |
| parenthesisAdditive() | (1+2); | Checks if an addition expression can be written in parentheses |
The parser will be tested, once the language itself has reached a solid state. At this point test cases, which check the contents of the parsed AST, would be immensely hard to maintain.