From fb1e30513235f2bbc0ebdedbce07348caf0d593e Mon Sep 17 00:00:00 2001 From: "Edward A. Lee" Date: Tue, 25 Jun 2024 11:05:40 -0700 Subject: [PATCH 1/2] Added test and aligned to reactor-c --- core/src/main/resources/lib/c/reactor-c | 2 +- test/Python/src/PythonPaths.lf | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 test/Python/src/PythonPaths.lf diff --git a/core/src/main/resources/lib/c/reactor-c b/core/src/main/resources/lib/c/reactor-c index 38294a303c..8fe0436ebf 160000 --- a/core/src/main/resources/lib/c/reactor-c +++ b/core/src/main/resources/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit 38294a303cfe2e3efd2cbc94d690ef4756514cb5 +Subproject commit 8fe0436ebf8bffb53dfc3373c093c0a80e88a6a2 diff --git a/test/Python/src/PythonPaths.lf b/test/Python/src/PythonPaths.lf new file mode 100644 index 0000000000..043b47624c --- /dev/null +++ b/test/Python/src/PythonPaths.lf @@ -0,0 +1,24 @@ +/** + * This tests the functions lf.source_directory() and lf.package_directory(). Success is just + * compiling and running without error. The test prints the contents of this file twice. + */ +target Python + +preamble {= + import os +=} + +main reactor { + state source_path = {= os.path.join(lf.source_directory(), "PythonPaths.lf") =} + state package_path = {= os.path.join(lf.package_directory(), "src", "PythonPaths.lf") =} + + reaction(startup) {= + file = open(self.source_path, "r"); + print(file.read()); + file.close(); + print("----------------"); + file = open(self.package_path, "r"); + print(file.read()); + file.close(); + =} +} From 235cc9786ab5e9c7f6f2e8b6dae8da411c1b7c95 Mon Sep 17 00:00:00 2001 From: "Edward A. Lee" Date: Tue, 2 Jul 2024 13:49:42 -0400 Subject: [PATCH 2/2] Respond to code review and update reactor-c --- test/Python/src/PythonPaths.lf | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/test/Python/src/PythonPaths.lf b/test/Python/src/PythonPaths.lf index 043b47624c..7bdb1767e1 100644 --- a/test/Python/src/PythonPaths.lf +++ b/test/Python/src/PythonPaths.lf @@ -13,12 +13,10 @@ main reactor { state package_path = {= os.path.join(lf.package_directory(), "src", "PythonPaths.lf") =} reaction(startup) {= - file = open(self.source_path, "r"); - print(file.read()); - file.close(); + with open(self.source_path, "r") as file: + print(file.read()); print("----------------"); - file = open(self.package_path, "r"); - print(file.read()); - file.close(); + with open(self.package_path, "r") as file: + print(file.read()); =} }