Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions liquidjava-verifier/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,45 @@
<build>
<finalName>${jar.finalName}</finalName>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.14</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>default-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<limit>
<counter>COMPLEXITY</counter>
<value>COVEREDRATIO</value>
<minimum>0.60</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package liquidjava.rj_language;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import org.junit.Test;

import liquidjava.rj_language.ast.LiteralString;

public class TestLiteralString {
@Test
public void testLiteralString() {
LiteralString s1 = new LiteralString("hello");
LiteralString s2 = new LiteralString("world");
assertNotEquals(s1.hashCode(), s2.hashCode());
}

@Test
public void testToString() {
LiteralString string = new LiteralString("hello world");

String result = string.toString();

assertEquals("hello world", result);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import static org.junit.Assert.assertEquals;
import org.junit.Test;

import liquidjava.rj_language.ast.BinaryExpression;
import liquidjava.rj_language.ast.LiteralInt;
import liquidjava.rj_language.opt.ConstantFolding;
import liquidjava.rj_language.opt.derivation_node.ValDerivationNode;

public class TestOptimization {
@Test
public void testBinaryFold() {
BinaryExpression b = new BinaryExpression(new LiteralInt(1), "+", new LiteralInt(2));

ValDerivationNode r = ConstantFolding.fold(new ValDerivationNode(b, null));
assertEquals(r.getValue(), new LiteralInt(3));
}

@Test
public void testBinaryExpressionWithLiteralInt() {
LiteralInt num1 = new LiteralInt(40);
LiteralInt num2 = new LiteralInt(60);

BinaryExpression expression = new BinaryExpression(num1, "+", num2);

String result = expression.toString();

assertEquals("40 + 60", result);
}

@Test
public void testIntegrationNestedAddition() {
// Create integer literals
LiteralInt num1 = new LiteralInt(5);
LiteralInt num2 = new LiteralInt(10);
LiteralInt num3 = new LiteralInt(20);

// Create nested binary expressions
BinaryExpression firstSum = new BinaryExpression(num1, "+", num2); // 5 + 10
BinaryExpression nestedSum = new BinaryExpression(firstSum, "+", num3); // (5 + 10) + 20

// Convert to string
String result = nestedSum.toString();

// Expected output: "(5 + 10) + 20"
assertEquals("5 + 10 + 20", result);
}

}
Loading