Changeset d03a386 for tests


Ignore:
Timestamp:
Apr 11, 2025, 1:23:39 AM (5 months ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
master
Children:
dab6e39
Parents:
570e7ad
Message:

Give a few string operator overloads a preference boost.

Intent is to approximate: When selecting +/* candidates, treat it ambiguous until finding a user-given arithmetic-vs-string constraint, such as assigning the result to a string. Once a string interpretation is imposed, prefer an alternative that converts to string as soon as possible.

This description is not directly achievable with the CFA type system. The approximation has the known flaw shown in the string-operator test, where a fairly built-up expression that should be ambiguous is actually defaulting to the string version.

This change is the last of the string-overload reorganizations that the string-operator test was originally meant to illustrate. In Mike's opinion, the resulting state is ideal, except for the just-mentioned flaw.

Location:
tests
Files:
9 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • tests/Makefile.am

    r570e7ad rd03a386  
    288288        -cp ${test} ${abspath ${@}}
    289289
    290 collections/string-operator-ERR01 : collections/string-operator.cfa
    291         ${CFACOMPILE_SYNTAX} -DTRY_MR01
    292         -cp ${test} ${abspath ${@}}
    293 
    294 collections/string-operator-ERR02 : collections/string-operator.cfa
    295         ${CFACOMPILE_SYNTAX} -DTRY_MR02
    296         -cp ${test} ${abspath ${@}}
    297 
    298 collections/string-operator-ERR03 : collections/string-operator.cfa
    299         ${CFACOMPILE_SYNTAX} -DTRY_MR03
    300         -cp ${test} ${abspath ${@}}
    301 
    302 collections/string-operator-ERR04 : collections/string-operator.cfa
    303         ${CFACOMPILE_SYNTAX} -DTRY_MR04
    304         -cp ${test} ${abspath ${@}}
    305 
    306 collections/string-operator-ERR05 : collections/string-operator.cfa
    307         ${CFACOMPILE_SYNTAX} -DTRY_MR05
    308         -cp ${test} ${abspath ${@}}
    309 
    310 collections/string-operator-ERR06 : collections/string-operator.cfa
    311         ${CFACOMPILE_SYNTAX} -DTRY_MR06
    312         -cp ${test} ${abspath ${@}}
    313 
    314 collections/string-operator-ERR07 : collections/string-operator.cfa
    315         ${CFACOMPILE_SYNTAX} -DTRY_MR07
    316         -cp ${test} ${abspath ${@}}
    317 
    318 collections/string-operator-ERR08 : collections/string-operator.cfa
    319         ${CFACOMPILE_SYNTAX} -DTRY_MR08
    320         -cp ${test} ${abspath ${@}}
    321 
    322290collections/string-operator-ERR09 : collections/string-operator.cfa
    323291        ${CFACOMPILE_SYNTAX} -DTRY_MR09
    324         -cp ${test} ${abspath ${@}}
    325 
    326 collections/string-operator-ERR10 : collections/string-operator.cfa
    327         ${CFACOMPILE_SYNTAX} -DTRY_MR10
    328292        -cp ${test} ${abspath ${@}}
    329293
  • tests/collections/.expect/string-operator.txt

    r570e7ad rd03a386  
    33
    44------------- Initialization
     5ab
     6ab
     7ab
     8ab
     9
     10abx
     11abx
     12abx
     13abx
     14
     15xab
     16xab
     17xab
     18xab
     19
     20axb
     21axb
     22axb
     23axb
     24
     25aaa
     26bbb
     27ababab
     28cdcdcd
     29
     30aaa
     31bbb
     32ababab
     33cdcdcd
     34
     35------------- Assignment
     36ab
     37ab
     38ab
     39ab
     40
     41ab
     42abab
     43ababab
     44abababab
     45
     46ab
     47abab
     48ababab
     49abababab
     50
     51ab
     52aabb
     53aaabbb
     54aaaabbbb
     55
     56aaa
     57bbb
     58ababab
     59cdcdcd
     60
     61aaa
     62bbb
     63ababab
     64cdcdcd
     65
     66------------- Bare (sout-direct)
    567(skip)
    668ab
     
    870ab
    971
    10 (skip)
     72abx
    1173abx
    1274abx
     
    2587(skip)
    2688bbb
    27 585
     89ababab
    2890cdcdcd
    2991
    3092(skip)
    3193bbb
    32 585
    33 cdcdcd
    34 
    35 ------------- Assignment
    36 (skip)
    37 ab
    38 ab
    39 ab
    40 
    41 (skip)
    42 ab
    43 abab
    4494ababab
    45 
    46 ab
    47 abab
    48 ababab
    49 abababab
    50 
    51 ab
    52 aabb
    53 aaabbb
    54 aaaabbbb
    55 
    56 (skip)
    57 bbb
    58 585
    59 cdcdcd
    60 
    61 (skip)
    62 bbb
    63 585
    64 cdcdcd
    65 
    66 ------------- Bare (sout-direct)
    67 (skip)
    68 ab
    69 ab
    70 ab
    71 
    72 (skip)
    73 abx
    74 abx
    75 abx
    76 
    77 xab
    78 xab
    79 xab
    80 xab
    81 
    82 axb
    83 axb
    84 axb
    85 axb
    86 
    87 (skip)
    88 bbb
    89 585
    90 cdcdcd
    91 
    92 (skip)
    93 bbb
    94 585
    9595cdcdcd
    9696
  • tests/collections/string-operator.cfa

    r570e7ad rd03a386  
    99
    1010// These MR points do reject in the current revision, so they have satellite "-ERR" cases:
    11 // MR01
    12 // MR02
    13 // MR03
    14 // MR04
    15 // MR05
    16 // MR06
    17 // MR07
    18 // MR08
    1911// MR09
    20 // MR10
    2112// MR11
    2213// MR13
     
    2516
    2617// These MR points do not reject in the current revision, so they join the "happy run":
     18#define TRY_MR01
     19#define TRY_MR02
     20#define TRY_MR03
     21#define TRY_MR04
     22#define TRY_MR05
     23#define TRY_MR06
     24#define TRY_MR07
     25#define TRY_MR08
     26#define TRY_MR10
    2727#define TRY_MR12
    2828#define TRY_MR14
     
    137137
    138138        sout | "------------- Initialization";
    139 MR01(  {string s = 'a' + 'b';           // (ambiguous)
     139MR01(  {string s = 'a' + 'b';           // ab
    140140        sout | s;}              )
    141141       {string s = 'a' + "b";           // ab
     
    149149        string s0 = "x";
    150150
    151 MR02(  {string s = 'a' + 'b' + s0;      // (ambiguous)
     151MR02(  {string s = 'a' + 'b' + s0;      // abx
    152152        sout | s;}              )
    153153       {string s = 'a' + "b" + s0;      // abx
     
    179179        sout | nl;                      //
    180180
    181 MR03(  {string s = 'a' * 3;             // (ambiguous)
     181MR03(  {string s = 'a' * 3;             // aaa
    182182        sout | s;}              )
    183183       {string s = "b" * 3;             // bbb
    184184        sout | s;}
    185        {string s = ('a' + 'b') * 3;     // ÃÃÃ (expecting ambiguous, likely from #309)
     185       {string s = ('a' + 'b') * 3;     // ababab
    186186        sout | s;}
    187187       {string s = ('c' + "d") * 3;     // cdcdcd
     
    189189        sout | nl;                      //
    190190
    191 MR04(  {string s = 3 * 'a';             // (ambiguous)
     191MR04(  {string s = 3 * 'a';             // aaa
    192192        sout | s;}              )
    193193       {string s = 3 * "b";             // bbb
     
    205205
    206206        s = "";
    207 MR05(   s = 'a' + 'b';          // (ambiguous)
     207MR05(   s = 'a' + 'b';          // ab
    208208        sout | s;              )
    209209        s = 'a' + "b";          // ab
     
    216216
    217217        s = "";
    218 MR06(   s = 'a' + 'b' + s;      // (ambiguous)
     218MR06(   s = 'a' + 'b' + s;      // ab
    219219        sout | s;              )
    220         s = 'a' + "b" + s;      // ab
    221         sout | s;
    222         s = "a" + 'b' + s;      // abab
    223         sout | s;
    224         s = "a" + "b" + s;      // ababab
     220        s = 'a' + "b" + s;      // abab
     221        sout | s;
     222        s = "a" + 'b' + s;      // ababab
     223        sout | s;
     224        s = "a" + "b" + s;      // abababab
    225225        sout | s;
    226226        sout | nl;              //
     
    249249
    250250        s = "";
    251 MR07(   s = 'a' * 3;            // (ambiguous)
     251MR07(   s = 'a' * 3;            // aaa
    252252        sout | s;              )
    253253        s = "b" * 3;            // bbb
    254254        sout | s;
    255         s = ('a' + 'b') * 3;    // ÃÃÃ (expecting ambiguous, likely from #309)
     255        s = ('a' + 'b') * 3;    // ababab
    256256        sout | s;
    257257        s = ('c' + "d") * 3;    // cdcdcd
     
    260260
    261261        s = "";
    262 MR08(   s = 3 * 'a';            // (ambiguous)
     262MR08(   s = 3 * 'a';            // aaa
    263263        sout | s;              )
    264264        s = 3 * "b";            // bbb
     
    281281        sout | nl;                  //
    282282
    283 MR10(   sout | 'a' + 'b' + s;  )    // (ambiguous)
     283MR10(   sout | 'a' + 'b' + s;  )    // abx
    284284        sout | 'a' + "b" + s;       // abx
    285285        sout | "a" + 'b' + s;       // abx
     
    301301MR11(   sout | 'a' * 3;          )  // (ambiguous)
    302302        sout | "b" * 3;             // bbb
    303 MR12(   sout | ('a' + 'b') * 3;  )  // 585 (expecting ambiguous, likely from #309)
     303MR12(   sout | ('a' + 'b') * 3;  )  // ababab (ideally ambiguous, known approximation flaw)
    304304        sout | ('c' + "d") * 3;     // cdcdcd
    305305        sout | nl;                  //
     
    307307MR13(   sout | 3 * 'a';          )  // (ambiguous)
    308308        sout | 3 * "b";             // bbb
    309 MR14(   sout | 3 * ('a' + 'b');  )  // 585 (expecting ambiguous, likely from #309)
     309MR14(   sout | 3 * ('a' + 'b');  )  // ababab (ideally ambiguous, known approximation flaw)
    310310        sout | 3 * ('c' + "d");     // cdcdcd
    311311        sout | nl;                  //
Note: See TracChangeset for help on using the changeset viewer.