From a6252c93823b832a7964e8a5aa06b9df0a1e57e9 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Thu, 29 Feb 2024 15:22:34 +0530 Subject: [PATCH 1/2] TEST: Ported integration_tests/enum_02.py from LPython --- integration_tests/enum_02.cpp | 47 +++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 integration_tests/enum_02.cpp diff --git a/integration_tests/enum_02.cpp b/integration_tests/enum_02.cpp new file mode 100644 index 0000000..ed7ded4 --- /dev/null +++ b/integration_tests/enum_02.cpp @@ -0,0 +1,47 @@ +#include + +enum MolecularMass { + water = 18, + methane = 16, + ammonia = 17, + oxygen = 16 +}; + +enum RelativeCharge { + proton = 1, + electron = -1, + neutron = 0 +}; + +void test_mm() { + std::cout << methane << " " << oxygen << std::endl; + if( methane != oxygen ) { + exit(2); + } + + std::cout << ammonia - methane << std::endl; + if( ammonia - methane != 1 ) { + exit(2); + } + + std::cout << water << " " << oxygen + 2 << std::endl; + if( water != oxygen + 2 ) { + exit(2); + } +} + +void test_rc() { + std::cout << proton << " " << electron << " " << neutron << std::endl; + if( proton + electron != neutron ) { + exit(2); + } +} + +int main() { + +test_mm(); +test_rc(); + +return 0; + +} From a881e688a0e856af1ac4380130674f943bb7f4b4 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Thu, 29 Feb 2024 15:22:46 +0530 Subject: [PATCH 2/2] TEST: Register enum_02.cpp --- integration_tests/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index 4e0b1e5..ba05406 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -224,3 +224,4 @@ RUN(NAME nbody_01.cpp LABELS gcc llvm NOFAST) RUN(NAME nbody_02.cpp LABELS gcc llvm NOFAST) RUN(NAME enum_01.cpp LABELS gcc llvm NOFAST) +RUN(NAME enum_02.cpp LABELS gcc llvm NOFAST)