Skip to content
Open
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 @@ -39,6 +39,45 @@
</configuration>
</plugin>
<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>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${pVersion.compiler}</version>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import static org.junit.Assert.*;

import org.junit.Test;

import liquidjava.rj_language.ast.LiteralBoolean;

public class TestLiteralBooleanSmall {

@Test
public void fromStringConstructor() {
assertFalse(new LiteralBoolean("false").isBooleanTrue());
}

@Test
public void cloneEquals() {
LiteralBoolean lb = new LiteralBoolean(true);
assertEquals(lb, lb.clone());
}
}
23 changes: 23 additions & 0 deletions liquidjava-verifier/src/test/java/liquidjava/TestLiterals.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import static org.junit.Assert.*;

import org.junit.Test;

import liquidjava.rj_language.ast.LiteralInt;
import liquidjava.rj_language.ast.LiteralString;

public class TestLiterals {

@Test
public void literalIntFromStringAndClone() {
LiteralInt li = new LiteralInt("7");
assertEquals(7, li.getValue());
assertEquals(li, li.clone());
}

@Test
public void literalStringToStringAndEquals() {
LiteralString ls = new LiteralString("hello");
assertEquals("hello", ls.toString());
assertEquals(ls, ls.clone());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

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;
import liquidjava.rj_language.ast.Var;

public class TestOptimizationInt {
@Test
public void testIntegerAddFold() {
BinaryExpression b = new BinaryExpression(new LiteralInt(2), "+", new LiteralInt(3));

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

@Test
public void testNoFoldWhenNonLiteral() {
BinaryExpression b = new BinaryExpression(new LiteralInt(1), "+", new Var("x"));
ValDerivationNode r = ConstantFolding.fold(new ValDerivationNode(b, null));
assertNotNull(r);
}

@Test
public void testIntegerSubFold() {
BinaryExpression b = new BinaryExpression(new LiteralInt(5), "-", new LiteralInt(2));
ValDerivationNode r = ConstantFolding.fold(new ValDerivationNode(b, null));
assertEquals(new LiteralInt(3), r.getValue());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package liquidjava.rj_language;

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());
}
}
Loading