Skip to content

Commit

Permalink
Fix Meta.get_qualified_type_name when run as single file (#11401)
Browse files Browse the repository at this point in the history
`Meta.get_qualified_type_name` correctly returns fully qualified type name when running a single file from a project with `enso --run Proj/src/Main.enso`.
  • Loading branch information
Akirathan authored Oct 31, 2024
1 parent aad1107 commit 536a49f
Show file tree
Hide file tree
Showing 11 changed files with 700 additions and 562 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.enso.interpreter.caches;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertTrue;

import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -29,9 +32,13 @@ public void loadingHelloWorldTwiceUsesCaching() throws Exception {
// the second run must read Hello_World from its .ir file!
var secondMsgs = executeOnce(helloWorld);
assertTrue("Contains hello world:\n" + secondMsgs, secondMsgs.contains("Hello World"));
assertTrue(
assertThat(
"Properly deserialized:\n" + secondMsgs,
secondMsgs.contains("Deserializing module Hello_World from IR file: true"));
secondMsgs,
allOf(
containsString("Deserializing module"),
containsString("Hello_World"),
containsString("from IR file: true")));
}

private static String executeOnce(File src) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.enso.interpreter.test.meta;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

import java.io.IOException;
import org.enso.test.utils.ProjectUtils;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;

public class QualifiedNameTest {
@Rule public TemporaryFolder temporaryFolder = new TemporaryFolder();

private static final String mainModSrc =
"""
from Standard.Base import all
type My_Type
Value x
main =
obj = My_Type.Value 42
Meta.get_qualified_type_name obj
""";

@Test
public void qualifiedTypeNameWorks_WhenRunningSingleFile() throws IOException {
var projDir = temporaryFolder.newFolder().toPath();
ProjectUtils.createProject("Proj", mainModSrc, projDir);
ProjectUtils.testProjectRun(
projDir,
(res) -> {
assertThat(res.asString(), is("local.Proj.Main.My_Type"));
});
}
}
Loading

0 comments on commit 536a49f

Please sign in to comment.