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 @@ -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,15 @@

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,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,28 @@
package liquidjava.integration;

import liquidjava.errors.ErrorEmitter;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

/**
* Simple integration test that verifies interaction between the ErrorEmitter class and the simulated error reporting
* process.
*/
public class TesteIntegracao {

@Test
void shouldEmitAndRetrieveErrorInfo() {
ErrorEmitter emitter = new ErrorEmitter();

emitter.addError("Integration test error", "FakeFile.java", 42);

assertTrue(emitter.foundError(), "Emitter should register an error");
assertNotNull(emitter.getFullMessage(), "Full message should not be null");

try {
emitter.getFilePath();
} catch (Exception e) {
fail("getFilePath() should not throw an exception");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package liquidjava.errors;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

public class TestesErrorEmitter {

private ErrorEmitter emitter;

/**
* Initializes a new ErrorEmitter before each test.
*/

@BeforeEach
void setup() {
emitter = new ErrorEmitter();
}

/**
* Tests that all getter methods return non-null values after an error is added.
*/

@Test
void returnNonNullValues() {
emitter.addError("test", "main.java", 1);
assertNotNull(emitter.getFullMessage());
assertNotNull(emitter.getTitleMessage());
assertNotNull(emitter.getErrorStatus());
}

/**
* Tests adding an error and verifying that it is correctly registered and demontrated through the emitter.
*/
@Test
void addError() {
emitter.addError("Test error", "Some message", 1);
assertTrue(emitter.foundError(), "Emitter should report found error");
assertTrue(emitter.getFullMessage().contains("Some message"));
}
}
Loading