diff --git a/buildingspy/CHANGES.txt b/buildingspy/CHANGES.txt index 5ae70327..6797b918 100644 --- a/buildingspy/CHANGES.txt +++ b/buildingspy/CHANGES.txt @@ -1,6 +1,14 @@ BuildingsPy Changelog --------------------- + +Version 5.2.1, ... +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- In buildingspy/development/regressiontest.py, added test for OpenModelica and + OPTIMICA CI testing that issues an error if a pure function calls an impure function. + (https://github.com/lbl-srg/BuildingsPy/issues/607) + Version 5.2.0, March 14, 2025 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/buildingspy/VERSION b/buildingspy/VERSION index 91ff5727..26d99a28 100644 --- a/buildingspy/VERSION +++ b/buildingspy/VERSION @@ -1 +1 @@ -5.2.0 +5.2.1 diff --git a/buildingspy/development/error_dictionary_openmodelica.py b/buildingspy/development/error_dictionary_openmodelica.py index 8f74f5ab..d82f0a00 100644 --- a/buildingspy/development/error_dictionary_openmodelica.py +++ b/buildingspy/development/error_dictionary_openmodelica.py @@ -39,3 +39,8 @@ def __init__(self): 'tool_message': "Non-array modification", 'counter': 0, 'summary_message': "Number of models with missing 'each' : {}\n"} + + self._error_dict["pure calling impure function"] = { + 'tool_message': "call to impure function", + 'counter': 0, + 'summary_message': "Number of models in which pure function calls impure function: {}\n"} \ No newline at end of file diff --git a/buildingspy/development/error_dictionary_optimica.py b/buildingspy/development/error_dictionary_optimica.py index ac81a5d7..48f5ab8e 100644 --- a/buildingspy/development/error_dictionary_optimica.py +++ b/buildingspy/development/error_dictionary_optimica.py @@ -78,3 +78,9 @@ def __init__(self): 'tool_message': "Integer, using Real instead", 'counter': 0, 'summary_message': "Number of models with too large Integers : {}\n"} + + # Check for pure function calling impure function + self._error_dict["pure calling impure function"] = { + 'tool_message': "Call to impure function", + 'counter': 0, + 'summary_message': "Number of models in which pure function calls impure function: {}\n"} \ No newline at end of file diff --git a/buildingspy/tests/test_development_regressiontest_openmodelica.py b/buildingspy/tests/test_development_regressiontest_openmodelica.py index 7a96e71c..34edfe6c 100644 --- a/buildingspy/tests/test_development_regressiontest_openmodelica.py +++ b/buildingspy/tests/test_development_regressiontest_openmodelica.py @@ -319,7 +319,16 @@ def test_regressiontest_diagnostics(self): 'mo_content': """Real x(start=0); equation Modelica.Math.exp(x)=-1;""", - 'description': "Model that has no solution."} + 'description': "Model that has no solution."}, + {'ret_val': 1, + 'mo_content': """ + function aPureFunction + algorithm + Modelica.Utilities.Streams.print("Hello"); + end aPureFunction; +equation + aPureFunction();""", + 'description': "Model in which a pure function calls an impure function."} ] # Run all test cases for test in tests: diff --git a/buildingspy/tests/test_development_regressiontest_optimica.py b/buildingspy/tests/test_development_regressiontest_optimica.py index 5a596a3f..388ae057 100644 --- a/buildingspy/tests/test_development_regressiontest_optimica.py +++ b/buildingspy/tests/test_development_regressiontest_optimica.py @@ -143,7 +143,16 @@ def test_regressiontest_diagnostics(self): 'mo_content': """Real x(start=0); equation Modelica.Math.exp(x)=-1;""", - 'description': "Model that has no solution."} + 'description': "Model that has no solution."}, + {'ret_val': 1, + 'mo_content': """ + function aPureFunction + algorithm + Modelica.Utilities.Streams.print("Hello"); + end aPureFunction; +equation + aPureFunction();""", + 'description': "Model in which a pure function calls an impure function."} ] # Run all test cases for test in tests: