Changeset 85855b0 for tests/enum_tests


Ignore:
Timestamp:
Jun 10, 2024, 2:43:13 AM (6 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
42cdd07d
Parents:
d68de59
Message:
  1. Implement enum cast; 2. Change valueE so that opague enum returns quasi_void; 3. change enum hiding interpretation and pass visiting scheme
Location:
tests/enum_tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tests/enum_tests/.expect/enumInlineValue.txt

    rd68de59 r85855b0  
    1 enumB.A is 5
    2 enumB.B is 6
    3 enumB.D is 11
    4 enumB.E is 12
     1Symbols (enumerator) should have the same values:
     2Symbol a: (10) 10, 10, 10
     3Symbol b: (20) 20, 20
     4Symbol ab: (30) 30
     5Symbol c: (40) 40, 40, 40
     6Symbol d: (50) 50, 50, 50
     7Symbol cd: (60) 60, 60
     8Symbol acd: (70) 70
     9Casting/Upcasting:
     10Symbol a: (10) 10, 10, 10
     11Symbol b: (20) 20, 20
     12Symbol ab: (30) 30
     13Symbol c: (40) 40, 40, 40, 40, 40
     14Symbol d: (50) 50, 50, 50, 50
     15Symbol cd: (60) 60, 60
     16Symbol acd: (70) 70
     17Function Call:
     18Symbol a: (10) 10, 10
     19Symbol c: (40) 40, 40
     20Symbol d: (50) 50, 50
     21Symbol cd: (60) 60, 60
     22Symbol acd: (70) 70
  • tests/enum_tests/enumInlineValue.cfa

    rd68de59 r85855b0  
    22#include <enum.hfa>
    33
    4 enum(int) A {
     4enum(int) A !{
    55    a = 10
    66};
     
    3636};
    3737
    38 int identity(A a) {
    39     return valueE(a);
     38// Note: variable name (cat in this case) cannot be overloaded with those declared in enum,
     39// Probably for the same reason as const overloading problem
     40// i.e. int identity_t(enum ACD a) would not work as the valueE(a) is ambigious currently
     41int identity_t(enum ACD cat) {
     42    return valueE(cat);
    4043}
    4144
     
    4346    // Note: We need to use qualified name syntax even if no ! hidding
    4447    // 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;
     48    sout | "Symbols (enumerator) should have the same values:" |nl;
     49    sout | "Symbol a: (10) " | valueE(A.a) | "," | valueE(AB.a) | "," | valueE(ACD.a) | nl;
     50    sout | "Symbol b: (20) " | valueE(B.b) | "," | valueE(AB.b) | nl;
     51    sout | "Symbol ab: (30) " | valueE(AB.ab) | nl;
     52    sout | "Symbol c: (40) " | valueE(C.c) | "," | valueE(CD.c) | "," | valueE(ACD.c) | nl;
     53    sout | "Symbol d: (50) " | valueE(D.d) | "," | valueE(CD.d) | "," | valueE(ACD.d) | nl;
     54    sout | "Symbol cd: (60) " | valueE(CD.cd) | "," | valueE(ACD.cd) | nl;
     55    sout | "Symbol acd: (70) " | valueE(ACD.acd) | nl;
    5356
    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;
     57    sout | "Casting/Upcasting:" | nl;
     58    sout | "Symbol a: (10) " | valueE((A)A.a) | "," | valueE((AB)A.a) | "," | valueE((ACD)A.a) | nl;
     59    sout | "Symbol b: (20) " | valueE((B)B.b) | "," | valueE((AB)B.b) | nl;
     60    sout | "Symbol ab: (30) " | valueE((AB)AB.ab) | nl;
     61    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;
     62    sout | "Symbol d: (50) " | valueE((D)D.d) | "," | valueE((CD)D.d) | "," | valueE((ACD)D.d) | "," | valueE((ACD)CD.d) | nl;
     63    sout | "Symbol cd: (60) " | valueE((CD)CD.cd) | "," | valueE((ACD)CD.cd) | nl;
     64    sout | "Symbol acd: (70) " | valueE((ACD)ACD.acd) | nl;
    6265
    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 
     66    sout | "Function Call:" | nl;
     67    sout | "Symbol a: (10) " | identity_t(A.a) | "," | identity_t(ACD.a) | nl;
     68    sout | "Symbol c: (40) " | identity_t(C.c) | "," | identity_t(ACD.c) | nl;
     69    sout | "Symbol d: (50) " | identity_t(D.d) | "," | identity_t(ACD.d) | nl;
     70    sout | "Symbol cd: (60) " | identity_t(CD.cd) | "," | identity_t(ACD.cd) | nl;
     71    sout | "Symbol acd: (70) " | identity_t(ACD.acd) | nl;
    6872}
Note: See TracChangeset for help on using the changeset viewer.