- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTokenParserTransformTest.java
More file actions
Latest commit
58 lines (48 loc) · 2.19 KB
/
Copy pathTokenParserTransformTest.java
File metadata and controls
58 lines (48 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
importstaticorg.junit.Assert.*;
importorg.junit.*;
publicclassTokenParserTransformTest {
TokenParserparser = newTokenParser();
@Test
publicvoidtransformOfATokenShouldReturnTheToken() {
Tokent = parser.transform("<=");
assertSame("TOKEN should have code 22", t.getCode(), 22);
assertEquals("TOKEN should have value of <=", t.getValue(), "<=");
assertEquals("TOKEN should have type of <=", t.getValue(), "<=");
assertEquals(t.getType(), "<=");
}
@Test
publicvoidtransformOfASpaceShouldReturnTheToken() {
Tokent = parser.transform(" ");
assertSame("SPACE should have code 26", t.getCode(), 26);
assertEquals("SPACE should have value \"\"", t.getValue(), " ");
assertEquals("SPACE should have type SPACE", t.getType(), "SPACE");
}
@Test
publicvoidtransformOfAnEOLShouldReturnTheToken() {
Tokent = parser.transform("\n");
assertSame("EOL should have code 27", t.getCode(), 27);
assertEquals("EOL should have value \\n", t.getValue(), "\n");
assertEquals("EOL should have type EOL", t.getType(), "EOL");
}
@Test
publicvoidtransformOfAStringShouldReturnTheToken() {
Tokent = parser.transform("\"HELLO\"");
assertSame("STRING should have value 3", t.getCode(), 3);
assertEquals("STRING should have value \"HELLO\"", t.getValue(), "\"HELLO\"");
assertEquals("STRING should have type STRING", t.getType(), "STRING");
}
@Test
publicvoidtransformOfANumberShouldReturnTheToken() {
Tokent = parser.transform("10.124");
assertSame("NUMBER should have value 29", t.getCode(), 29);
assertEquals("NUMBER should have value 10.124", t.getValue(), "10.124");
assertEquals("NUMBER should have value NUMBER", t.getType(), "NUMBER");
}
@Test
publicvoidtransformOfAnIdentifierShouldReturnTheToken() {
Tokent = parser.transform("ABC");
assertSame("IDENTIFIER should have value 28", t.getCode(), 28);
assertEquals("IDENTIFIER should have value ABC", t.getValue(), "ABC");
assertEquals("IDENTIFIER should have value IDENTIFIER", t.getType(), "IDENTIFIER");
}
}