From 02fcc07379c724db836d2298e92d07cbc29fef0d Mon Sep 17 00:00:00 2001 From: Ashish Mahendra Date: Tue, 8 Oct 2024 12:53:45 +0000 Subject: [PATCH] added testcase for relative import --- .../tests/fixtures/arch_create_util.jac | 2 +- jac/jaclang/tests/test_language.py | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/jac/jaclang/tests/fixtures/arch_create_util.jac b/jac/jaclang/tests/fixtures/arch_create_util.jac index a20283637..6df4fdee9 100644 --- a/jac/jaclang/tests/fixtures/arch_create_util.jac +++ b/jac/jaclang/tests/fixtures/arch_create_util.jac @@ -1,6 +1,6 @@ node UtilityNode { has data: int; - + can display_data with entry { print("UtilityNode Data:", f'{self.data}'); } diff --git a/jac/jaclang/tests/test_language.py b/jac/jaclang/tests/test_language.py index f59e374b5..4ae5ca141 100644 --- a/jac/jaclang/tests/test_language.py +++ b/jac/jaclang/tests/test_language.py @@ -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")) @@ -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()