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
3 changes: 3 additions & 0 deletions liquidjava-verifier/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "interactive"
}
40 changes: 40 additions & 0 deletions liquidjava-verifier/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,46 @@
</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.60</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package liquidjava.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,22 @@
package liquidjava.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 TestOptimizationIntegration {
@Test
public void testBinaryFoldNested() {
BinaryExpression inner = new BinaryExpression(new LiteralInt(2), "+", new LiteralInt(3));
BinaryExpression outer = new BinaryExpression(new LiteralInt(1), "+", inner);
ValDerivationNode r = ConstantFolding.fold(new ValDerivationNode(outer, null));
assertEquals(new LiteralInt(6), r.getValue());
}
}

// António Rebelo - 58530
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

package liquidjava.rj_language;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;

import org.junit.Test;
import liquidjava.rj_language.ast.LiteralString;

public class TestLiteralString {
// Teste fornecido
@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,33 @@
package liquidjava.rj_language;

import static org.junit.Assert.*;
import org.junit.Test;
import liquidjava.rj_language.ast.LiteralString;

public class TestLiteralStringEquals {
@Test
public void testBothValuesNull() {
LiteralString a = new LiteralString(null);
LiteralString b = new LiteralString(null);
assertTrue(a.equals(b));
assertTrue(b.equals(a));
assertTrue(a.equals(a));
assertEquals(a.hashCode(), b.hashCode());
}

@Test
public void testThisValueNullOtherNotNull() {
LiteralString a = new LiteralString(null);
LiteralString b = new LiteralString("hello");
assertFalse(a.equals(b));
assertFalse(b.equals(a));
}

@Test
public void testOtherValueNullThisNotNull() {
LiteralString a = new LiteralString("hello");
LiteralString b = new LiteralString(null);
assertFalse(a.equals(b));
assertFalse(b.equals(a));
}
}
Loading