Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -399,17 +399,15 @@ public static SourceLocation forCurrentSpan(IonReader source)
public void display(Appendable out)
throws IOException
{
SourceName name = getSourceName();
long line = getLine();
long column = getColumn();

if (line < 1)
{
out.append("unknown location");
if (name != null)
if (!myResource.isUnknown())
{
out.append(" in ");
out.append(name.display());
out.append(" in ").append(myResource.display());
}
}
else
Expand All @@ -424,10 +422,21 @@ public void display(Appendable out)
out.append(" column");
}

if (name != null)
if (!myResource.isUnknown())
{
out.append(" of ");
out.append(name.display());
ModuleIdentity module = getModuleIdentity();
if (module != null)
{
out.append(module.absolutePath())
.append(" (at ")
.append(myResource.display())
.append(')');
}
else
{
out.append(myResource.display());
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static class ModuleSourceName

ModuleSourceName(ResourceIdentifier rsrc, ModuleIdentity id)
{
super(id + " (at " + rsrc.toString() + ")", rsrc);
super(rsrc);
myId = id;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
import static dev.ionfusion.fusion.StandardReader.openIonReader;
import static dev.ionfusion.testing.ProjectLayout.PROJECT_DIRECTORY;
import static dev.ionfusion.testing.ProjectLayout.testRepositoryDirectory;
import static java.nio.file.Files.isRegularFile;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.not;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand All @@ -17,7 +22,6 @@
import dev.ionfusion.runtime.base.SourceName;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.nio.file.Path;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -49,7 +53,7 @@ private void checkActualModule(ModuleRepository repo)
assertNotNull(loc.toString());

SourceName name = loc.sourceName();
assertTrue(name.display().contains("/ftst/symbol.fusion"));
assertThat(name.display(), endsWith("/ftst/symbol.fusion"));

Evaluator eval = evaluator();
IonReader ionReader = openIonReader(eval, name.getResourceId());
Expand Down Expand Up @@ -77,10 +81,10 @@ public void loadModuleFromDirectory()
Path dir = testRepositoryDirectory();

URL url = dir.toUri().toURL();
assert url.getProtocol().equals("file");
assertEquals("file", url.getProtocol());

// Precondition for URLClassLoader to treat the URL as a directory:
assert url.getFile().endsWith("/");
assertThat(url.getFile(), endsWith("/"));

checkRepository(url, ".");
}
Expand All @@ -96,12 +100,12 @@ public void loadModuleFromJar()
Path jar = PROJECT_DIRECTORY.resolve("build")
.resolve("libs")
.resolve("ftst-repo.jar");
assert Files.isRegularFile(jar);
assertTrue(isRegularFile(jar), "regular file");

URL url = jar.toUri().toURL();

// Precondition for URLClassLoader to treat the URL as a JAR file:
assert ! url.getFile().endsWith("/");
assertThat(url.getFile(), not(endsWith("/")));

checkRepository(url, "FUSION-REPO");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
package dev.ionfusion.fusion;

import static dev.ionfusion.fusion.FusionStruct.unsafeStructSize;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.amazon.ion.IonReader;
import org.junit.jupiter.api.Test;

Expand All @@ -23,7 +27,9 @@ public void testIonSyntaxError()
Throwable e =
assertEvalThrows(FusionErrorException.class,
"(require '''/malformed/ion_syntax_error''')");
assertTrue(e.getMessage().contains("Error reading /malformed/ion_syntax_error"));
assertThat(e.getMessage(),
allOf(startsWith("Error reading "),
containsString("/malformed/ion_syntax_error.fusion")));
}

@Test
Expand Down
Loading