From cc00d19b3d1302784063d0d63759b0a9fed33782 Mon Sep 17 00:00:00 2001 From: Ashish Mahendra Date: Fri, 6 Sep 2024 15:00:19 +0000 Subject: [PATCH] updated test_language and add walker update code --- jaclang/tests/fixtures/walker_update.jac | 19 +++++++++++++++++++ jaclang/tests/test_language.py | 8 +++----- 2 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 jaclang/tests/fixtures/walker_update.jac diff --git a/jaclang/tests/fixtures/walker_update.jac b/jaclang/tests/fixtures/walker_update.jac new file mode 100644 index 000000000..011454303 --- /dev/null +++ b/jaclang/tests/fixtures/walker_update.jac @@ -0,0 +1,19 @@ +import:jac from bar { bar_walk } +import:py from jaclang.runtimelib.machine { JacMachine } +import:py os; + +can update_bar_walker { + "Updating bar.jac with new behavior." |> print; + (bar_walk_new, ) = JacMachine.get().update_walker( + "bar", + items={'bar_walk': None} + ); + "Running bar_walk after update..." |> print; + root spawn bar_walk_new(); + print(f"bar_walk: {bar_walk_new.__dict__}"); +} + + +with entry { + update_bar_walker(); +} \ No newline at end of file diff --git a/jaclang/tests/test_language.py b/jaclang/tests/test_language.py index ed85b3cd3..7a312c38d 100644 --- a/jaclang/tests/test_language.py +++ b/jaclang/tests/test_language.py @@ -956,6 +956,7 @@ def test_walker_dynamic_update(self) -> None: """Test dynamic update of a walker during runtime.""" session = self.fixture_abs_path("bar_walk.session") bar_file_path = self.fixture_abs_path("bar.jac") + update_file_path = self.fixture_abs_path("walker_update.jac") captured_output = io.StringIO() sys.stdout = captured_output cli.enter( @@ -996,11 +997,8 @@ def test_walker_dynamic_update(self) -> None: sys.stdout = captured_output try: - cli.enter( - filename=bar_file_path, - session=session, - entrypoint="bar_walk", - args=[], + cli.run( + filename=update_file_path, ) sys.stdout = sys.__stdout__ stdout_value = captured_output.getvalue()