Changeset d68de59 for tests/enum_tests
- Timestamp:
- Jun 3, 2024, 3:03:48 PM (8 months ago)
- Branches:
- master
- Children:
- 85855b0
- Parents:
- 0f5e8cd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/enum_tests/enumInlineValue.cfa
r0f5e8cd rd68de59 1 1 #include <fstream.hfa> 2 enum enumA { 3 A=5, B, C=10, D 2 #include <enum.hfa> 3 4 enum(int) A { 5 a = 10 4 6 }; 5 7 6 enum enumB { 7 inline enumA, 8 E 8 enum(int) B { 9 b = 20 9 10 }; 10 11 12 enum(int) AB { 13 inline A, 14 inline B, 15 ab = 30 16 }; 17 18 enum(int) C { 19 c = 40 20 }; 21 22 enum(int) D { 23 d = 50 24 }; 25 26 enum(int) CD { 27 inline C, 28 inline D, 29 cd = 60 30 }; 31 32 enum(int) ACD { 33 inline A, 34 inline CD, 35 acd = 70 36 }; 37 38 int identity(A a) { 39 return valueE(a); 40 } 41 11 42 int main() { 12 enum enumB val = A; 13 sout | "enumB.A is" | val; 14 enum enumB val2 = enumB.B; 15 sout | "enumB.B is" | val2; 16 sout | "enumB.D is" | enumB.D; 17 sout | "enumB.E is" | enumB.E; 43 // Note: We need to use qualified name syntax even if no ! hidding 44 // Because Inline introduce ambiguity on symbols 45 // sout | "Symbols (enumerator) should have the same values:" |nl; 46 // sout | "Symbol a: (10) " | valueE(A.a) | "," | valueE(AB.a) | "," | valueE(ACD.a) | nl; 47 // sout | "Symbol b: (20) " | valueE(B.b) | "," | valueE(AB.b) | nl; 48 // sout | "Symbol ab: (30) " | valueE(AB.ab) | nl; 49 // sout | "Symbol c: (40) " | valueE(C.c) | "," | valueE(CD.c) | "," | valueE(ACD.c) | nl; 50 // sout | "Symbol d: (50) " | valueE(D.d) | "," | valueE(CD.d) | "," | valueE(ACD.d) | nl; 51 // sout | "Symbol cd: (60) " | valueE(CD.cd) | "," | valueE(ACD.cd) | nl; 52 // sout | "Symbol acd: (70) " | valueE(ACD.acd) | nl; 53 54 // sout | "Casting/Upcasting:" | nl; 55 // sout | "Symbol a: (10) " | valueE((A)A.a) | "," | valueE((AB)A.a) | "," | valueE((ACD)A.a) | nl; 56 // sout | "Symbol b: (20) " | valueE((B)B.b) | "," | valueE((AB)B.b) | nl; 57 // sout | "Symbol ab: (30) " | valueE((AB)AB.ab) | nl; 58 // sout | "Symbol c: (40) " | valueE((C)C.c) | "," | valueE((CD)C.c) | "," | valueE((ACD)C.c) | "," | valueE((CD)CD.c)| "," | valueE((ACD)CD.c) | nl; 59 // sout | "Symbol d: (50) " | valueE((D)D.d) | "," | valueE((CD)D.d) | "," | valueE((ACD)D.d) | "," | valueE((ACD)CD.d) | nl; 60 // sout | "Symbol cd: (60) " | valueE((CD)CD.cd) | "," | valueE((ACD)CD.cd) | nl; 61 // sout | "Symbol acd: (70) " | valueE((ACD)ACD.acd) | nl; 62 63 // sout | "Function Call:" | nl; 64 // sout | "Symbol a: (10) " | identity(A.a) | "," | identity(ACD.a); 65 // sout | "Symbol c: (40) " | identity(C.c) | "," | identity(CD.c)| "," | identity(ACD.c); 66 identity(A.a); 67 18 68 }
Note: See TracChangeset
for help on using the changeset viewer.