File tree Expand file tree Collapse file tree 6 files changed +135
-0
lines changed
Expand file tree Collapse file tree 6 files changed +135
-0
lines changed Original file line number Diff line number Diff line change 3939 </configuration >
4040 </plugin >
4141 <plugin >
42+ <groupId >org.jacoco</groupId >
43+ <artifactId >jacoco-maven-plugin</artifactId >
44+ <version >0.8.14</version >
45+ <executions >
46+ <execution >
47+ <id >default-prepare-agent</id >
48+ <goals >
49+ <goal >prepare-agent</goal >
50+ </goals >
51+ </execution >
52+ <execution >
53+ <id >default-report</id >
54+ <goals >
55+ <goal >report</goal >
56+ </goals >
57+ </execution >
58+ <execution >
59+ <id >default-check</id >
60+ <goals >
61+ <goal >check</goal >
62+ </goals >
63+ <configuration >
64+ <rules >
65+ <rule >
66+ <element >BUNDLE</element >
67+ <limits >
68+ <limit >
69+ <counter >COMPLEXITY</counter >
70+ <value >COVEREDRATIO</value >
71+ <minimum >0.60</minimum >
72+ </limit >
73+ </limits >
74+ </rule >
75+ </rules >
76+ </configuration >
77+ </execution >
78+ </executions >
79+ </plugin >
80+ <plugin >
4281 <groupId >org.apache.maven.plugins</groupId >
4382 <artifactId >maven-compiler-plugin</artifactId >
4483 <version >${pVersion.compiler} </version >
Original file line number Diff line number Diff line change 1+ import static org .junit .Assert .assertEquals ;
2+
3+ import org .junit .Test ;
4+
5+ import liquidjava .rj_language .ast .BinaryExpression ;
6+ import liquidjava .rj_language .ast .LiteralInt ;
7+ import liquidjava .rj_language .opt .ConstantFolding ;
8+ import liquidjava .rj_language .opt .derivation_node .ValDerivationNode ;
9+
10+ public class TestOptimization {
11+ @ Test
12+ public void testBinaryFold () {
13+ BinaryExpression b = new BinaryExpression (new LiteralInt (1 ), "+" , new LiteralInt (2 ));
14+
15+ ValDerivationNode r = ConstantFolding .fold (new ValDerivationNode (b , null ));
16+ assertEquals (r .getValue (), new LiteralInt (3 ));
17+ }
18+ }
Original file line number Diff line number Diff line change 1+ import static org .junit .Assert .assertEquals ;
2+
3+ import org .junit .Test ;
4+
5+ import liquidjava .rj_language .ast .BinaryExpression ;
6+ import liquidjava .rj_language .ast .LiteralInt ;
7+ import liquidjava .rj_language .opt .ConstantFolding ;
8+ import liquidjava .rj_language .opt .derivation_node .ValDerivationNode ;
9+
10+ public class TestOptimizationInt {
11+ @ Test
12+ public void testIntegerAddFold () {
13+ BinaryExpression b = new BinaryExpression (new LiteralInt (2 ), "+" , new LiteralInt (3 ));
14+
15+ ValDerivationNode r = ConstantFolding .fold (new ValDerivationNode (b , null ));
16+ assertEquals (new LiteralInt (5 ), r .getValue ());
17+ }
18+ }
Original file line number Diff line number Diff line change 1+ package liquidjava .rj_language ;
2+
3+ import static org .junit .Assert .*;
4+ import org .junit .Test ;
5+ import liquidjava .rj_language .ast .LiteralInt ;
6+
7+ public class TestLiteralInt {
8+
9+ @ Test
10+ public void testLiteralIntEquality () {
11+ LiteralInt a = new LiteralInt (10 );
12+ LiteralInt b = new LiteralInt (10 );
13+ assertEquals (a , b );
14+ }
15+
16+ @ Test
17+ public void testLiteralIntHashCodeConsistency () {
18+ LiteralInt a = new LiteralInt (5 );
19+ int firstHash = a .hashCode ();
20+ int secondHash = a .hashCode ();
21+ assertEquals (firstHash , secondHash );
22+
23+ }
24+ }
Original file line number Diff line number Diff line change 1+ package liquidjava .rj_language ;
2+
3+ import static org .junit .Assert .assertNotEquals ;
4+ import org .junit .Test ;
5+ import liquidjava .rj_language .ast .LiteralString ;
6+
7+ public class TestLiteralString {
8+ @ Test
9+ public void testLiteralString () {
10+ LiteralString s1 = new LiteralString ("hello" );
11+ LiteralString s2 = new LiteralString ("world" );
12+ assertNotEquals (s1 .hashCode (), s2 .hashCode ());
13+ }
14+ }
Original file line number Diff line number Diff line change 1+ package liquidjava .rj_language ;
2+
3+ import static org .junit .Assert .*;
4+ import org .junit .Test ;
5+ import liquidjava .rj_language .ast .LiteralString ;
6+
7+ public class TestLiteralStringExtra {
8+
9+ @ Test
10+ public void testEqualStringsHaveEqualHashCodes () {
11+ LiteralString s1 = new LiteralString ("hello" );
12+ LiteralString s2 = new LiteralString ("hello" );
13+ assertEquals (s1 .hashCode (), s2 .hashCode ());
14+ }
15+
16+ @ Test
17+ public void testDifferentStringsAreNotEqual () {
18+ LiteralString s1 = new LiteralString ("hello" );
19+ LiteralString s2 = new LiteralString ("world" );
20+ assertNotEquals (s1 , s2 );
21+ }
22+ }
You can’t perform that action at this time.
0 commit comments