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
46 changes: 43 additions & 3 deletions liquidjava-verifier/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>

<groupId>liquidjava-verifier
</groupId>
</groupId>
<artifactId>liquidjava-verifier</artifactId>
<version>5.2-SNAPSHOT</version>
<name>liquidjava-verifier</name>
Expand Down Expand Up @@ -77,7 +77,8 @@
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>liquidjava.api.CommandLineLauncher</mainClass>
</transformer>
</transformers>
Expand All @@ -95,6 +96,45 @@
</execution>
</executions>
</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.50</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -206,4 +246,4 @@
</dependency>
</dependencies>
</dependencyManagement>
</project>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package liquidjava.rj_language.ast.opt;

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,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());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package liquidjava.rj_language.ast.typing;

import static org.junit.Assert.*;
import org.junit.Test;
import liquidjava.rj_language.ast.*;
import liquidjava.processor.context.Context;
import spoon.Launcher;
import spoon.reflect.factory.Factory;
import java.util.Optional;
import spoon.reflect.reference.CtTypeReference;

public class TestBinaryTypeIntegration {

@Test
public void testBinaryIntExpressionType() {
Launcher launcher = new Launcher();
Factory factory = launcher.getFactory();
Context ctx = null;

BinaryExpression expr = new BinaryExpression(new LiteralInt(1), "+", new LiteralInt(2));
Optional<CtTypeReference<?>> result = TypeInfer.getType(ctx, factory, expr);
assertTrue(result.isPresent());
assertEquals("int", result.get().getSimpleName().toLowerCase());
}

@Test
public void testBinaryBooleanExpressionType() {
Launcher launcher = new Launcher();
Factory factory = launcher.getFactory();
Context ctx = null;

BinaryExpression expr = new BinaryExpression(new LiteralBoolean(true), "&&", new LiteralBoolean(false));
Optional<CtTypeReference<?>> result = TypeInfer.getType(ctx, factory, expr);
assertTrue(result.isPresent());
assertEquals("boolean", result.get().getSimpleName().toLowerCase());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package liquidjava.rj_language.ast.typing;

import static org.junit.Assert.*;
import org.junit.Test;
import spoon.Launcher;
import spoon.reflect.factory.Factory;
import liquidjava.processor.context.Context;
import liquidjava.rj_language.ast.*;
import java.util.Optional;
import spoon.reflect.reference.CtTypeReference;

public class TestBoolType {

@Test
public void testBooleanLiteralType() {
Launcher launcher = new Launcher();
Factory factory = launcher.getFactory();
Context ctx = null;

LiteralBoolean boolExpr = new LiteralBoolean(true);
Optional<CtTypeReference<?>> result = TypeInfer.getType(ctx, factory, boolExpr);

assertTrue(result.isPresent());
assertEquals("boolean", result.get().getSimpleName().toLowerCase());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package liquidjava.rj_language.ast.typing;

import static org.junit.Assert.*;
import org.junit.Test;
import liquidjava.rj_language.ast.*;
import liquidjava.processor.context.Context;
import spoon.Launcher;
import spoon.reflect.factory.Factory;

public class TestCheckCompatibleType {

@Test
public void testCompatibleLiterals() {
Launcher launcher = new Launcher();
Factory factory = launcher.getFactory();
Context ctx = null;

LiteralInt a = new LiteralInt(3);
LiteralInt b = new LiteralInt(4);

assertTrue(TypeInfer.checkCompatibleType(a, b, ctx, factory));
}

@Test
public void testIncompatibleLiterals() {
Launcher launcher = new Launcher();
Factory factory = launcher.getFactory();
Context ctx = null;

LiteralInt a = new LiteralInt(3);
LiteralString s = new LiteralString("abc");

assertFalse(TypeInfer.checkCompatibleType(a, s, ctx, factory));
}
}