Skip to content

Commit f142447

Browse files
authored
Merge pull request #97 from czgdp1807/enum_02
Ported ``integration_tests/enum_02.py`` from LPython
2 parents d77844d + a881e68 commit f142447

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

Diff for: integration_tests/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -224,3 +224,4 @@ RUN(NAME nbody_01.cpp LABELS gcc llvm NOFAST)
224224
RUN(NAME nbody_02.cpp LABELS gcc llvm NOFAST)
225225

226226
RUN(NAME enum_01.cpp LABELS gcc llvm NOFAST)
227+
RUN(NAME enum_02.cpp LABELS gcc llvm NOFAST)

Diff for: integration_tests/enum_02.cpp

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#include <iostream>
2+
3+
enum MolecularMass {
4+
water = 18,
5+
methane = 16,
6+
ammonia = 17,
7+
oxygen = 16
8+
};
9+
10+
enum RelativeCharge {
11+
proton = 1,
12+
electron = -1,
13+
neutron = 0
14+
};
15+
16+
void test_mm() {
17+
std::cout << methane << " " << oxygen << std::endl;
18+
if( methane != oxygen ) {
19+
exit(2);
20+
}
21+
22+
std::cout << ammonia - methane << std::endl;
23+
if( ammonia - methane != 1 ) {
24+
exit(2);
25+
}
26+
27+
std::cout << water << " " << oxygen + 2 << std::endl;
28+
if( water != oxygen + 2 ) {
29+
exit(2);
30+
}
31+
}
32+
33+
void test_rc() {
34+
std::cout << proton << " " << electron << " " << neutron << std::endl;
35+
if( proton + electron != neutron ) {
36+
exit(2);
37+
}
38+
}
39+
40+
int main() {
41+
42+
test_mm();
43+
test_rc();
44+
45+
return 0;
46+
47+
}

0 commit comments

Comments
 (0)