Skip to content

Commit

Permalink
Add TypeErrorTest for testing typeErrorMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
Akirathan committed Jun 11, 2024
1 parent 9d005b0 commit 343a2f1
Showing 1 changed file with 61 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package org.enso.interpreter.test;

import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

import java.io.IOException;
import java.util.Set;
import org.enso.pkg.QualifiedName;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;

public class TypeErrorTest extends TestBase {
@Rule public TemporaryFolder tempFolder = new TemporaryFolder();

@Test
public void typeErrorMessageContainsQualifiedNames() throws IOException {
var modSrc = """
type T
Ctor
make_t = T.Ctor
""";
var mainSrc =
"""
from Standard.Base import all
from project.Data.Mod import T
from project.Data.Mod import make_t
type T
method (t:T) = t.baz
main =
t = make_t
p = Panic.catch Any handler=(_.payload) <| method t
p.to_text
""";
var projDir =
createProject(
"Proj",
Set.of(
new SourceModule(QualifiedName.fromString("Main"), mainSrc),
new SourceModule(QualifiedName.fromString("Data.Mod"), modSrc)),
tempFolder);
testProjectRun(
projDir,
res -> {
assertThat(res.isString(), is(true));
assertThat(
res.asString(),
allOf(
containsString("Type error"),
containsString("expected `t` to be"),
containsString("Data.Mod.T"),
containsString("Main.T")));
});
}
}

0 comments on commit 343a2f1

Please sign in to comment.