Skip to content

Commit

Permalink
added testcase for relative import
Browse files Browse the repository at this point in the history
  • Loading branch information
AshishMahendra committed Oct 8, 2024
1 parent 1d9358a commit 02fcc07
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion jac/jaclang/tests/fixtures/arch_create_util.jac
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
node UtilityNode {
has data: int;

can display_data with entry {
print("UtilityNode Data:", f'{self.data}');
}
Expand Down
18 changes: 17 additions & 1 deletion jac/jaclang/tests/test_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ def test_dynamic_spawn_architype(self) -> None:
)

def test_dynamic_architype_creation(self) -> None:
"""Test that the walker and node can be spawned and behaves as expected."""
"""Test that the walker and node can be created dynamically."""
captured_output = io.StringIO()
sys.stdout = captured_output
cli.run(self.fixture_abs_path("create_dynamic_architype.jac"))
Expand All @@ -1074,6 +1074,22 @@ def test_dynamic_architype_creation(self) -> None:
f"Expected '{expected_spawned_walker}' in output.",
)

def test_dynamic_architype_creation_rel_import(self) -> None:
"""Test that the walker and node can be created dynamically, with relative import."""
captured_output = io.StringIO()
sys.stdout = captured_output
cli.run(self.fixture_abs_path("arch_rel_import_creation.jac"))

output = captured_output.getvalue().strip().splitlines()
# Expected outputs for spawned entities
expected_values = ["DynamicWalker Started", "UtilityNode Data: 42"]
for val in expected_values:
# Check for the spawned messages
self.assertTrue(
val in output,
f"Expected '{val}' in output.",
)

def test_object_ref_interface(self) -> None:
"""Test class method output."""
captured_output = io.StringIO()
Expand Down

0 comments on commit 02fcc07

Please sign in to comment.