-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathEqualsSignChainTest.java
116 lines (84 loc) · 2.99 KB
/
EqualsSignChainTest.java
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package com.sap.adt.abapcleaner.rules.syntax;
import org.junit.jupiter.api.Test;
import com.sap.adt.abapcleaner.rulebase.RuleID;
import com.sap.adt.abapcleaner.rulebase.RuleTestBase;
class EqualsSignChainTest extends RuleTestBase {
EqualsSignChainTest() {
super(RuleID.EQUALS_SIGN_CHAIN);
}
@Test
void testNumberLiteral() {
buildSrc(" \" assign a number literal");
buildSrc(" a = b = 42. \" plain and simple");
buildExp(" \" assign a number literal");
buildExp(" b = 42. \" plain and simple");
buildExp(" a = b.");
putAnyMethodAroundSrcAndExp();
testRule();
}
@Test
void testStringLiteral() {
buildSrc(" c = d = e = 'abc'. \" still quite simple");
buildExp(" e = 'abc'. \" still quite simple");
buildExp(" d = e.");
buildExp(" c = d.");
putAnyMethodAroundSrcAndExp();
testRule();
}
@Test
void testSimpleIdentifier() {
buildSrc(" \" assign a simple variable");
buildSrc(" f = g = h = iv_value.");
buildExp(" \" assign a simple variable");
buildExp(" h = iv_value.");
buildExp(" g = h.");
buildExp(" f = g.");
putAnyMethodAroundSrcAndExp();
testRule();
}
@Test
void testFunctionalCall() {
buildSrc(" f = g = h = next_value( ).");
buildExp(" h = next_value( ).");
buildExp(" g = h.");
buildExp(" f = g.");
putAnyMethodAroundSrcAndExp();
testRule();
}
@Test
void testComplexExpression() {
buildSrc(" \" assign a complex expression that should not be repeated");
buildSrc(" i = j = k = l = m = complex_expression( param_1 = 5");
buildSrc(" param_2 = 'abc' \" comment on param_2");
buildSrc(" param_3 = VALUE #( param_4 = 42 \" comment on param_4");
buildSrc(" param_5 = iv_param_5 ) ). \" final comment");
buildExp(" \" assign a complex expression that should not be repeated");
buildExp(" m = complex_expression( param_1 = 5");
buildExp(" param_2 = 'abc' \" comment on param_2");
buildExp(" param_3 = VALUE #( param_4 = 42 \" comment on param_4");
buildExp(" param_5 = iv_param_5 ) ). \" final comment");
buildExp(" l = m.");
buildExp(" k = l.");
buildExp(" j = k.");
buildExp(" i = j.");
putAnyMethodAroundSrcAndExp();
testRule();
}
@Test
void testChainUnchanged() {
// expect commands with chain colon to remain unchanged
buildSrc(" a = b = : next_value( ), next_value( ).");
buildSrc(" c = d = : 1.");
copyExpFromSrc();
putAnyMethodAroundSrcAndExp();
testRule();
}
@Test
void testThreeVariables() {
buildSrc(" a = b = c.");
buildExp(" b = c.");
buildExp(" a = b.");
putAnyMethodAroundSrcAndExp();
testRule();
}
}