Changeset f988834 for tests


Ignore:
Timestamp:
Jan 19, 2024, 2:44:41 AM (21 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
ac939461
Parents:
59c8dff (diff), e8b3717 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
tests
Files:
5 added
15 edited

Legend:

Unmodified
Added
Removed
  • tests/Makefile.am

    r59c8dff rf988834  
    9292        concurrency/channels/parallel_harness.hfa \
    9393        array-collections/dimexpr-match.hfa \
    94         array-collections/dimexpr-match-detail.sh
     94        array-collections/dimexpr-match-detail.sh \
     95        array-collections/array-raii.hfa
    9596
    9697dist-hook:
  • tests/collections/.expect/string-api-coverage.txt

    r59c8dff rf988834  
    1414true false
    1515true false
     161234567
    1617123
    1718hello
     19hell
    1820hello
    1921world
    2022hello
    2123world
     24Q
     251234567
     26hello
     27Q
     28123
     29hell
     301234567
     31hello
     32123
     33hell
    22345
    2335helloworld
     
    2941hello, friend
    3042bye, friend
     43ohello
     44ohell
     45ohell
     46omydarling
     47omy
     48omy
     49hellohellohellohello
    3150hellohellohello
    3251QQQ
    3352asdfasdfasdf
     53lo
     54hello heliocentric
    3455e
    3556help!!!o
  • tests/collections/.expect/string-compare.txt

    r59c8dff rf988834  
    11------- string -------
    2 (cmp(s_, s_) == 0) ok
     2(strcmp(s_, s_) == 0) ok
    33(s_ == s_) ok
    44!(s_ != s_) ok
     
    77(s_ <= s_) ok
    88!(s_ < s_) ok
    9 (cmp("", s_) == 0) ok
     9(strcmp("", s_) == 0) ok
    1010("" == s_) ok
    1111!("" != s_) ok
     
    1414("" <= s_) ok
    1515!("" < s_) ok
    16 (cmp(s_, "") == 0) ok
     16(strcmp(s_, "") == 0) ok
    1717(s_ == "") ok
    1818!(s_ != "") ok
     
    2121(s_ <= "") ok
    2222!(s_ < "") ok
    23 (cmp(s_, s_a) < 0) ok
     23(strcmp(s_, s_a) < 0) ok
    2424!(s_ == s_a) ok
    2525(s_ != s_a) ok
     
    2828(s_ <= s_a) ok
    2929(s_ < s_a) ok
    30 (cmp("", s_a) < 0) ok
     30(strcmp("", s_a) < 0) ok
    3131!("" == s_a) ok
    3232("" != s_a) ok
     
    3535("" <= s_a) ok
    3636("" < s_a) ok
    37 (cmp(s_, "a") < 0) ok
     37(strcmp(s_, "a") < 0) ok
    3838!(s_ == "a") ok
    3939(s_ != "a") ok
     
    4242(s_ <= "a") ok
    4343(s_ < "a") ok
    44 (cmp(s_a, s_) > 0) ok
     44(strcmp(s_a, s_) > 0) ok
    4545!(s_a == s_) ok
    4646(s_a != s_) ok
     
    4949!(s_a <= s_) ok
    5050!(s_a < s_) ok
    51 (cmp("a", s_) > 0) ok
     51(strcmp("a", s_) > 0) ok
    5252!("a" == s_) ok
    5353("a" != s_) ok
     
    5656!("a" <= s_) ok
    5757!("a" < s_) ok
    58 (cmp(s_a, "") > 0) ok
     58(strcmp(s_a, "") > 0) ok
    5959!(s_a == "") ok
    6060(s_a != "") ok
     
    6363!(s_a <= "") ok
    6464!(s_a < "") ok
    65 (cmp(s_, s_aa) < 0) ok
     65(strcmp(s_, s_aa) < 0) ok
    6666!(s_ == s_aa) ok
    6767(s_ != s_aa) ok
     
    7070(s_ <= s_aa) ok
    7171(s_ < s_aa) ok
    72 (cmp("", s_aa) < 0) ok
     72(strcmp("", s_aa) < 0) ok
    7373!("" == s_aa) ok
    7474("" != s_aa) ok
     
    7777("" <= s_aa) ok
    7878("" < s_aa) ok
    79 (cmp(s_, "aa") < 0) ok
     79(strcmp(s_, "aa") < 0) ok
    8080!(s_ == "aa") ok
    8181(s_ != "aa") ok
     
    8484(s_ <= "aa") ok
    8585(s_ < "aa") ok
    86 (cmp(s_aa, s_) > 0) ok
     86(strcmp(s_aa, s_) > 0) ok
    8787!(s_aa == s_) ok
    8888(s_aa != s_) ok
     
    9191!(s_aa <= s_) ok
    9292!(s_aa < s_) ok
    93 (cmp("aa", s_) > 0) ok
     93(strcmp("aa", s_) > 0) ok
    9494!("aa" == s_) ok
    9595("aa" != s_) ok
     
    9898!("aa" <= s_) ok
    9999!("aa" < s_) ok
    100 (cmp(s_aa, "") > 0) ok
     100(strcmp(s_aa, "") > 0) ok
    101101!(s_aa == "") ok
    102102(s_aa != "") ok
     
    105105!(s_aa <= "") ok
    106106!(s_aa < "") ok
    107 (cmp(s_a, s_aa) < 0) ok
     107(strcmp(s_a, s_aa) < 0) ok
    108108!(s_a == s_aa) ok
    109109(s_a != s_aa) ok
     
    112112(s_a <= s_aa) ok
    113113(s_a < s_aa) ok
    114 (cmp("a", s_aa) < 0) ok
     114(strcmp("a", s_aa) < 0) ok
    115115!("a" == s_aa) ok
    116116("a" != s_aa) ok
     
    119119("a" <= s_aa) ok
    120120("a" < s_aa) ok
    121 (cmp(s_a, "aa") < 0) ok
     121(strcmp(s_a, "aa") < 0) ok
    122122!(s_a == "aa") ok
    123123(s_a != "aa") ok
     
    126126(s_a <= "aa") ok
    127127(s_a < "aa") ok
    128 (cmp(s_aa, s_a) > 0) ok
     128(strcmp(s_aa, s_a) > 0) ok
    129129!(s_aa == s_a) ok
    130130(s_aa != s_a) ok
     
    133133!(s_aa <= s_a) ok
    134134!(s_aa < s_a) ok
    135 (cmp("aa", s_a) > 0) ok
     135(strcmp("aa", s_a) > 0) ok
    136136!("aa" == s_a) ok
    137137("aa" != s_a) ok
     
    140140!("aa" <= s_a) ok
    141141!("aa" < s_a) ok
    142 (cmp(s_aa, "a") > 0) ok
     142(strcmp(s_aa, "a") > 0) ok
    143143!(s_aa == "a") ok
    144144(s_aa != "a") ok
     
    147147!(s_aa <= "a") ok
    148148!(s_aa < "a") ok
    149 (cmp(s_a, s_a) == 0) ok
     149(strcmp(s_a, s_a) == 0) ok
    150150(s_a == s_a) ok
    151151!(s_a != s_a) ok
     
    154154(s_a <= s_a) ok
    155155!(s_a < s_a) ok
    156 (cmp("a", s_a) == 0) ok
     156(strcmp("a", s_a) == 0) ok
    157157("a" == s_a) ok
    158158!("a" != s_a) ok
     
    161161("a" <= s_a) ok
    162162!("a" < s_a) ok
    163 (cmp(s_a, "a") == 0) ok
     163(strcmp(s_a, "a") == 0) ok
    164164(s_a == "a") ok
    165165!(s_a != "a") ok
     
    168168(s_a <= "a") ok
    169169!(s_a < "a") ok
    170 (cmp(s_aa, s_aa) == 0) ok
     170(strcmp(s_aa, s_aa) == 0) ok
    171171(s_aa == s_aa) ok
    172172!(s_aa != s_aa) ok
     
    175175(s_aa <= s_aa) ok
    176176!(s_aa < s_aa) ok
    177 (cmp("aa", s_aa) == 0) ok
     177(strcmp("aa", s_aa) == 0) ok
    178178("aa" == s_aa) ok
    179179!("aa" != s_aa) ok
     
    182182("aa" <= s_aa) ok
    183183!("aa" < s_aa) ok
    184 (cmp(s_aa, "aa") == 0) ok
     184(strcmp(s_aa, "aa") == 0) ok
    185185(s_aa == "aa") ok
    186186!(s_aa != "aa") ok
     
    189189(s_aa <= "aa") ok
    190190!(s_aa < "aa") ok
    191 (cmp(s_a, s_b) < 0) ok
     191(strcmp(s_a, s_b) < 0) ok
    192192!(s_a == s_b) ok
    193193(s_a != s_b) ok
     
    196196(s_a <= s_b) ok
    197197(s_a < s_b) ok
    198 (cmp("a", s_b) < 0) ok
     198(strcmp("a", s_b) < 0) ok
    199199!("a" == s_b) ok
    200200("a" != s_b) ok
     
    203203("a" <= s_b) ok
    204204("a" < s_b) ok
    205 (cmp(s_a, "b") < 0) ok
     205(strcmp(s_a, "b") < 0) ok
    206206!(s_a == "b") ok
    207207(s_a != "b") ok
     
    210210(s_a <= "b") ok
    211211(s_a < "b") ok
    212 (cmp(s_b, s_a) > 0) ok
     212(strcmp(s_b, s_a) > 0) ok
    213213!(s_b == s_a) ok
    214214(s_b != s_a) ok
     
    217217!(s_b <= s_a) ok
    218218!(s_b < s_a) ok
    219 (cmp("b", s_a) > 0) ok
     219(strcmp("b", s_a) > 0) ok
    220220!("b" == s_a) ok
    221221("b" != s_a) ok
     
    224224!("b" <= s_a) ok
    225225!("b" < s_a) ok
    226 (cmp(s_b, "a") > 0) ok
     226(strcmp(s_b, "a") > 0) ok
    227227!(s_b == "a") ok
    228228(s_b != "a") ok
     
    231231!(s_b <= "a") ok
    232232!(s_b < "a") ok
    233 (cmp(s_a, s_ba) < 0) ok
     233(strcmp(s_a, s_ba) < 0) ok
    234234!(s_a == s_ba) ok
    235235(s_a != s_ba) ok
     
    238238(s_a <= s_ba) ok
    239239(s_a < s_ba) ok
    240 (cmp("a", s_ba) < 0) ok
     240(strcmp("a", s_ba) < 0) ok
    241241!("a" == s_ba) ok
    242242("a" != s_ba) ok
     
    245245("a" <= s_ba) ok
    246246("a" < s_ba) ok
    247 (cmp(s_a, "ba") < 0) ok
     247(strcmp(s_a, "ba") < 0) ok
    248248!(s_a == "ba") ok
    249249(s_a != "ba") ok
     
    252252(s_a <= "ba") ok
    253253(s_a < "ba") ok
    254 (cmp(s_ba, s_a) > 0) ok
     254(strcmp(s_ba, s_a) > 0) ok
    255255!(s_ba == s_a) ok
    256256(s_ba != s_a) ok
     
    259259!(s_ba <= s_a) ok
    260260!(s_ba < s_a) ok
    261 (cmp("ba", s_a) > 0) ok
     261(strcmp("ba", s_a) > 0) ok
    262262!("ba" == s_a) ok
    263263("ba" != s_a) ok
     
    266266!("ba" <= s_a) ok
    267267!("ba" < s_a) ok
    268 (cmp(s_ba, "a") > 0) ok
     268(strcmp(s_ba, "a") > 0) ok
    269269!(s_ba == "a") ok
    270270(s_ba != "a") ok
     
    273273!(s_ba <= "a") ok
    274274!(s_ba < "a") ok
    275 (cmp(s_aa, s_ab) < 0) ok
     275(strcmp(s_aa, s_ab) < 0) ok
    276276!(s_aa == s_ab) ok
    277277(s_aa != s_ab) ok
     
    280280(s_aa <= s_ab) ok
    281281(s_aa < s_ab) ok
    282 (cmp("aa", s_ab) < 0) ok
     282(strcmp("aa", s_ab) < 0) ok
    283283!("aa" == s_ab) ok
    284284("aa" != s_ab) ok
     
    287287("aa" <= s_ab) ok
    288288("aa" < s_ab) ok
    289 (cmp(s_aa, "ab") < 0) ok
     289(strcmp(s_aa, "ab") < 0) ok
    290290!(s_aa == "ab") ok
    291291(s_aa != "ab") ok
     
    294294(s_aa <= "ab") ok
    295295(s_aa < "ab") ok
    296 (cmp(s_ab, s_aa) > 0) ok
     296(strcmp(s_ab, s_aa) > 0) ok
    297297!(s_ab == s_aa) ok
    298298(s_ab != s_aa) ok
     
    301301!(s_ab <= s_aa) ok
    302302!(s_ab < s_aa) ok
    303 (cmp("ab", s_aa) > 0) ok
     303(strcmp("ab", s_aa) > 0) ok
    304304!("ab" == s_aa) ok
    305305("ab" != s_aa) ok
     
    308308!("ab" <= s_aa) ok
    309309!("ab" < s_aa) ok
    310 (cmp(s_ab, "aa") > 0) ok
     310(strcmp(s_ab, "aa") > 0) ok
    311311!(s_ab == "aa") ok
    312312(s_ab != "aa") ok
     
    315315!(s_ab <= "aa") ok
    316316!(s_ab < "aa") ok
    317 (cmp(s_ba, s_bb) < 0) ok
     317(strcmp(s_ba, s_bb) < 0) ok
    318318!(s_ba == s_bb) ok
    319319(s_ba != s_bb) ok
     
    322322(s_ba <= s_bb) ok
    323323(s_ba < s_bb) ok
    324 (cmp("ba", s_bb) < 0) ok
     324(strcmp("ba", s_bb) < 0) ok
    325325!("ba" == s_bb) ok
    326326("ba" != s_bb) ok
     
    329329("ba" <= s_bb) ok
    330330("ba" < s_bb) ok
    331 (cmp(s_ba, "bb") < 0) ok
     331(strcmp(s_ba, "bb") < 0) ok
    332332!(s_ba == "bb") ok
    333333(s_ba != "bb") ok
     
    336336(s_ba <= "bb") ok
    337337(s_ba < "bb") ok
    338 (cmp(s_bb, s_ba) > 0) ok
     338(strcmp(s_bb, s_ba) > 0) ok
    339339!(s_bb == s_ba) ok
    340340(s_bb != s_ba) ok
     
    343343!(s_bb <= s_ba) ok
    344344!(s_bb < s_ba) ok
    345 (cmp("bb", s_ba) > 0) ok
     345(strcmp("bb", s_ba) > 0) ok
    346346!("bb" == s_ba) ok
    347347("bb" != s_ba) ok
     
    350350!("bb" <= s_ba) ok
    351351!("bb" < s_ba) ok
    352 (cmp(s_bb, "ba") > 0) ok
     352(strcmp(s_bb, "ba") > 0) ok
    353353!(s_bb == "ba") ok
    354354(s_bb != "ba") ok
     
    357357!(s_bb <= "ba") ok
    358358!(s_bb < "ba") ok
    359 (cmp(s_aa, s_b) < 0) ok
     359(strcmp(s_aa, s_b) < 0) ok
    360360!(s_aa == s_b) ok
    361361(s_aa != s_b) ok
     
    364364(s_aa <= s_b) ok
    365365(s_aa < s_b) ok
    366 (cmp("aa", s_b) < 0) ok
     366(strcmp("aa", s_b) < 0) ok
    367367!("aa" == s_b) ok
    368368("aa" != s_b) ok
     
    371371("aa" <= s_b) ok
    372372("aa" < s_b) ok
    373 (cmp(s_aa, "b") < 0) ok
     373(strcmp(s_aa, "b") < 0) ok
    374374!(s_aa == "b") ok
    375375(s_aa != "b") ok
     
    378378(s_aa <= "b") ok
    379379(s_aa < "b") ok
    380 (cmp(s_b, s_aa) > 0) ok
     380(strcmp(s_b, s_aa) > 0) ok
    381381!(s_b == s_aa) ok
    382382(s_b != s_aa) ok
     
    385385!(s_b <= s_aa) ok
    386386!(s_b < s_aa) ok
    387 (cmp("b", s_aa) > 0) ok
     387(strcmp("b", s_aa) > 0) ok
    388388!("b" == s_aa) ok
    389389("b" != s_aa) ok
     
    392392!("b" <= s_aa) ok
    393393!("b" < s_aa) ok
    394 (cmp(s_b, "aa") > 0) ok
     394(strcmp(s_b, "aa") > 0) ok
    395395!(s_b == "aa") ok
    396396(s_b != "aa") ok
     
    400400!(s_b < "aa") ok
    401401------- string_res -------
    402 (cmp(s_, s_) == 0) ok
     402(strcmp(s_, s_) == 0) ok
    403403(s_ == s_) ok
    404404!(s_ != s_) ok
     
    407407(s_ <= s_) ok
    408408!(s_ < s_) ok
    409 (cmp("", s_) == 0) ok
     409(strcmp("", s_) == 0) ok
    410410("" == s_) ok
    411411!("" != s_) ok
     
    414414("" <= s_) ok
    415415!("" < s_) ok
    416 (cmp(s_, "") == 0) ok
     416(strcmp(s_, "") == 0) ok
    417417(s_ == "") ok
    418418!(s_ != "") ok
     
    421421(s_ <= "") ok
    422422!(s_ < "") ok
    423 (cmp(s_, s_a) < 0) ok
     423(strcmp(s_, s_a) < 0) ok
    424424!(s_ == s_a) ok
    425425(s_ != s_a) ok
     
    428428(s_ <= s_a) ok
    429429(s_ < s_a) ok
    430 (cmp("", s_a) < 0) ok
     430(strcmp("", s_a) < 0) ok
    431431!("" == s_a) ok
    432432("" != s_a) ok
     
    435435("" <= s_a) ok
    436436("" < s_a) ok
    437 (cmp(s_, "a") < 0) ok
     437(strcmp(s_, "a") < 0) ok
    438438!(s_ == "a") ok
    439439(s_ != "a") ok
     
    442442(s_ <= "a") ok
    443443(s_ < "a") ok
    444 (cmp(s_a, s_) > 0) ok
     444(strcmp(s_a, s_) > 0) ok
    445445!(s_a == s_) ok
    446446(s_a != s_) ok
     
    449449!(s_a <= s_) ok
    450450!(s_a < s_) ok
    451 (cmp("a", s_) > 0) ok
     451(strcmp("a", s_) > 0) ok
    452452!("a" == s_) ok
    453453("a" != s_) ok
     
    456456!("a" <= s_) ok
    457457!("a" < s_) ok
    458 (cmp(s_a, "") > 0) ok
     458(strcmp(s_a, "") > 0) ok
    459459!(s_a == "") ok
    460460(s_a != "") ok
     
    463463!(s_a <= "") ok
    464464!(s_a < "") ok
    465 (cmp(s_, s_aa) < 0) ok
     465(strcmp(s_, s_aa) < 0) ok
    466466!(s_ == s_aa) ok
    467467(s_ != s_aa) ok
     
    470470(s_ <= s_aa) ok
    471471(s_ < s_aa) ok
    472 (cmp("", s_aa) < 0) ok
     472(strcmp("", s_aa) < 0) ok
    473473!("" == s_aa) ok
    474474("" != s_aa) ok
     
    477477("" <= s_aa) ok
    478478("" < s_aa) ok
    479 (cmp(s_, "aa") < 0) ok
     479(strcmp(s_, "aa") < 0) ok
    480480!(s_ == "aa") ok
    481481(s_ != "aa") ok
     
    484484(s_ <= "aa") ok
    485485(s_ < "aa") ok
    486 (cmp(s_aa, s_) > 0) ok
     486(strcmp(s_aa, s_) > 0) ok
    487487!(s_aa == s_) ok
    488488(s_aa != s_) ok
     
    491491!(s_aa <= s_) ok
    492492!(s_aa < s_) ok
    493 (cmp("aa", s_) > 0) ok
     493(strcmp("aa", s_) > 0) ok
    494494!("aa" == s_) ok
    495495("aa" != s_) ok
     
    498498!("aa" <= s_) ok
    499499!("aa" < s_) ok
    500 (cmp(s_aa, "") > 0) ok
     500(strcmp(s_aa, "") > 0) ok
    501501!(s_aa == "") ok
    502502(s_aa != "") ok
     
    505505!(s_aa <= "") ok
    506506!(s_aa < "") ok
    507 (cmp(s_a, s_aa) < 0) ok
     507(strcmp(s_a, s_aa) < 0) ok
    508508!(s_a == s_aa) ok
    509509(s_a != s_aa) ok
     
    512512(s_a <= s_aa) ok
    513513(s_a < s_aa) ok
    514 (cmp("a", s_aa) < 0) ok
     514(strcmp("a", s_aa) < 0) ok
    515515!("a" == s_aa) ok
    516516("a" != s_aa) ok
     
    519519("a" <= s_aa) ok
    520520("a" < s_aa) ok
    521 (cmp(s_a, "aa") < 0) ok
     521(strcmp(s_a, "aa") < 0) ok
    522522!(s_a == "aa") ok
    523523(s_a != "aa") ok
     
    526526(s_a <= "aa") ok
    527527(s_a < "aa") ok
    528 (cmp(s_aa, s_a) > 0) ok
     528(strcmp(s_aa, s_a) > 0) ok
    529529!(s_aa == s_a) ok
    530530(s_aa != s_a) ok
     
    533533!(s_aa <= s_a) ok
    534534!(s_aa < s_a) ok
    535 (cmp("aa", s_a) > 0) ok
     535(strcmp("aa", s_a) > 0) ok
    536536!("aa" == s_a) ok
    537537("aa" != s_a) ok
     
    540540!("aa" <= s_a) ok
    541541!("aa" < s_a) ok
    542 (cmp(s_aa, "a") > 0) ok
     542(strcmp(s_aa, "a") > 0) ok
    543543!(s_aa == "a") ok
    544544(s_aa != "a") ok
     
    547547!(s_aa <= "a") ok
    548548!(s_aa < "a") ok
    549 (cmp(s_a, s_a) == 0) ok
     549(strcmp(s_a, s_a) == 0) ok
    550550(s_a == s_a) ok
    551551!(s_a != s_a) ok
     
    554554(s_a <= s_a) ok
    555555!(s_a < s_a) ok
    556 (cmp("a", s_a) == 0) ok
     556(strcmp("a", s_a) == 0) ok
    557557("a" == s_a) ok
    558558!("a" != s_a) ok
     
    561561("a" <= s_a) ok
    562562!("a" < s_a) ok
    563 (cmp(s_a, "a") == 0) ok
     563(strcmp(s_a, "a") == 0) ok
    564564(s_a == "a") ok
    565565!(s_a != "a") ok
     
    568568(s_a <= "a") ok
    569569!(s_a < "a") ok
    570 (cmp(s_aa, s_aa) == 0) ok
     570(strcmp(s_aa, s_aa) == 0) ok
    571571(s_aa == s_aa) ok
    572572!(s_aa != s_aa) ok
     
    575575(s_aa <= s_aa) ok
    576576!(s_aa < s_aa) ok
    577 (cmp("aa", s_aa) == 0) ok
     577(strcmp("aa", s_aa) == 0) ok
    578578("aa" == s_aa) ok
    579579!("aa" != s_aa) ok
     
    582582("aa" <= s_aa) ok
    583583!("aa" < s_aa) ok
    584 (cmp(s_aa, "aa") == 0) ok
     584(strcmp(s_aa, "aa") == 0) ok
    585585(s_aa == "aa") ok
    586586!(s_aa != "aa") ok
     
    589589(s_aa <= "aa") ok
    590590!(s_aa < "aa") ok
    591 (cmp(s_a, s_b) < 0) ok
     591(strcmp(s_a, s_b) < 0) ok
    592592!(s_a == s_b) ok
    593593(s_a != s_b) ok
     
    596596(s_a <= s_b) ok
    597597(s_a < s_b) ok
    598 (cmp("a", s_b) < 0) ok
     598(strcmp("a", s_b) < 0) ok
    599599!("a" == s_b) ok
    600600("a" != s_b) ok
     
    603603("a" <= s_b) ok
    604604("a" < s_b) ok
    605 (cmp(s_a, "b") < 0) ok
     605(strcmp(s_a, "b") < 0) ok
    606606!(s_a == "b") ok
    607607(s_a != "b") ok
     
    610610(s_a <= "b") ok
    611611(s_a < "b") ok
    612 (cmp(s_b, s_a) > 0) ok
     612(strcmp(s_b, s_a) > 0) ok
    613613!(s_b == s_a) ok
    614614(s_b != s_a) ok
     
    617617!(s_b <= s_a) ok
    618618!(s_b < s_a) ok
    619 (cmp("b", s_a) > 0) ok
     619(strcmp("b", s_a) > 0) ok
    620620!("b" == s_a) ok
    621621("b" != s_a) ok
     
    624624!("b" <= s_a) ok
    625625!("b" < s_a) ok
    626 (cmp(s_b, "a") > 0) ok
     626(strcmp(s_b, "a") > 0) ok
    627627!(s_b == "a") ok
    628628(s_b != "a") ok
     
    631631!(s_b <= "a") ok
    632632!(s_b < "a") ok
    633 (cmp(s_a, s_ba) < 0) ok
     633(strcmp(s_a, s_ba) < 0) ok
    634634!(s_a == s_ba) ok
    635635(s_a != s_ba) ok
     
    638638(s_a <= s_ba) ok
    639639(s_a < s_ba) ok
    640 (cmp("a", s_ba) < 0) ok
     640(strcmp("a", s_ba) < 0) ok
    641641!("a" == s_ba) ok
    642642("a" != s_ba) ok
     
    645645("a" <= s_ba) ok
    646646("a" < s_ba) ok
    647 (cmp(s_a, "ba") < 0) ok
     647(strcmp(s_a, "ba") < 0) ok
    648648!(s_a == "ba") ok
    649649(s_a != "ba") ok
     
    652652(s_a <= "ba") ok
    653653(s_a < "ba") ok
    654 (cmp(s_ba, s_a) > 0) ok
     654(strcmp(s_ba, s_a) > 0) ok
    655655!(s_ba == s_a) ok
    656656(s_ba != s_a) ok
     
    659659!(s_ba <= s_a) ok
    660660!(s_ba < s_a) ok
    661 (cmp("ba", s_a) > 0) ok
     661(strcmp("ba", s_a) > 0) ok
    662662!("ba" == s_a) ok
    663663("ba" != s_a) ok
     
    666666!("ba" <= s_a) ok
    667667!("ba" < s_a) ok
    668 (cmp(s_ba, "a") > 0) ok
     668(strcmp(s_ba, "a") > 0) ok
    669669!(s_ba == "a") ok
    670670(s_ba != "a") ok
     
    673673!(s_ba <= "a") ok
    674674!(s_ba < "a") ok
    675 (cmp(s_aa, s_ab) < 0) ok
     675(strcmp(s_aa, s_ab) < 0) ok
    676676!(s_aa == s_ab) ok
    677677(s_aa != s_ab) ok
     
    680680(s_aa <= s_ab) ok
    681681(s_aa < s_ab) ok
    682 (cmp("aa", s_ab) < 0) ok
     682(strcmp("aa", s_ab) < 0) ok
    683683!("aa" == s_ab) ok
    684684("aa" != s_ab) ok
     
    687687("aa" <= s_ab) ok
    688688("aa" < s_ab) ok
    689 (cmp(s_aa, "ab") < 0) ok
     689(strcmp(s_aa, "ab") < 0) ok
    690690!(s_aa == "ab") ok
    691691(s_aa != "ab") ok
     
    694694(s_aa <= "ab") ok
    695695(s_aa < "ab") ok
    696 (cmp(s_ab, s_aa) > 0) ok
     696(strcmp(s_ab, s_aa) > 0) ok
    697697!(s_ab == s_aa) ok
    698698(s_ab != s_aa) ok
     
    701701!(s_ab <= s_aa) ok
    702702!(s_ab < s_aa) ok
    703 (cmp("ab", s_aa) > 0) ok
     703(strcmp("ab", s_aa) > 0) ok
    704704!("ab" == s_aa) ok
    705705("ab" != s_aa) ok
     
    708708!("ab" <= s_aa) ok
    709709!("ab" < s_aa) ok
    710 (cmp(s_ab, "aa") > 0) ok
     710(strcmp(s_ab, "aa") > 0) ok
    711711!(s_ab == "aa") ok
    712712(s_ab != "aa") ok
     
    715715!(s_ab <= "aa") ok
    716716!(s_ab < "aa") ok
    717 (cmp(s_ba, s_bb) < 0) ok
     717(strcmp(s_ba, s_bb) < 0) ok
    718718!(s_ba == s_bb) ok
    719719(s_ba != s_bb) ok
     
    722722(s_ba <= s_bb) ok
    723723(s_ba < s_bb) ok
    724 (cmp("ba", s_bb) < 0) ok
     724(strcmp("ba", s_bb) < 0) ok
    725725!("ba" == s_bb) ok
    726726("ba" != s_bb) ok
     
    729729("ba" <= s_bb) ok
    730730("ba" < s_bb) ok
    731 (cmp(s_ba, "bb") < 0) ok
     731(strcmp(s_ba, "bb") < 0) ok
    732732!(s_ba == "bb") ok
    733733(s_ba != "bb") ok
     
    736736(s_ba <= "bb") ok
    737737(s_ba < "bb") ok
    738 (cmp(s_bb, s_ba) > 0) ok
     738(strcmp(s_bb, s_ba) > 0) ok
    739739!(s_bb == s_ba) ok
    740740(s_bb != s_ba) ok
     
    743743!(s_bb <= s_ba) ok
    744744!(s_bb < s_ba) ok
    745 (cmp("bb", s_ba) > 0) ok
     745(strcmp("bb", s_ba) > 0) ok
    746746!("bb" == s_ba) ok
    747747("bb" != s_ba) ok
     
    750750!("bb" <= s_ba) ok
    751751!("bb" < s_ba) ok
    752 (cmp(s_bb, "ba") > 0) ok
     752(strcmp(s_bb, "ba") > 0) ok
    753753!(s_bb == "ba") ok
    754754(s_bb != "ba") ok
     
    757757!(s_bb <= "ba") ok
    758758!(s_bb < "ba") ok
    759 (cmp(s_aa, s_b) < 0) ok
     759(strcmp(s_aa, s_b) < 0) ok
    760760!(s_aa == s_b) ok
    761761(s_aa != s_b) ok
     
    764764(s_aa <= s_b) ok
    765765(s_aa < s_b) ok
    766 (cmp("aa", s_b) < 0) ok
     766(strcmp("aa", s_b) < 0) ok
    767767!("aa" == s_b) ok
    768768("aa" != s_b) ok
     
    771771("aa" <= s_b) ok
    772772("aa" < s_b) ok
    773 (cmp(s_aa, "b") < 0) ok
     773(strcmp(s_aa, "b") < 0) ok
    774774!(s_aa == "b") ok
    775775(s_aa != "b") ok
     
    778778(s_aa <= "b") ok
    779779(s_aa < "b") ok
    780 (cmp(s_b, s_aa) > 0) ok
     780(strcmp(s_b, s_aa) > 0) ok
    781781!(s_b == s_aa) ok
    782782(s_b != s_aa) ok
     
    785785!(s_b <= s_aa) ok
    786786!(s_b < s_aa) ok
    787 (cmp("b", s_aa) > 0) ok
     787(strcmp("b", s_aa) > 0) ok
    788788!("b" == s_aa) ok
    789789("b" != s_aa) ok
     
    792792!("b" <= s_aa) ok
    793793!("b" < s_aa) ok
    794 (cmp(s_b, "aa") > 0) ok
     794(strcmp(s_b, "aa") > 0) ok
    795795!(s_b == "aa") ok
    796796(s_b != "aa") ok
  • tests/collections/.expect/string-istream-manip.txt

    r59c8dff rf988834  
    696913 wwwwwwww
    707014 cccc
    71 15 q
     7115
    72721 yyyyyyyyyyyyyyyyyyyy
    73732 abcxxx
     
    848413 wwwwwwww
    858514 cccc
    86 15 q
     8615
  • tests/collections/string-api-coverage.cfa

    r59c8dff rf988834  
    5151    sout | (s == "hello") | (s == "world");
    5252    sout | (s != "world") | (s != "hello");
    53     sout | ( frag == s(1,4) ) | ( s3   == s(1,4) );
    54     sout | ( s3   != s(1,4) ) | ( frag != s(1,4) );
    55     sout | ( s2(1,4) == s(1,4) ) | ( s3(1,4)   == s(1,4) );
    56     sout | ( s3(1,4) != s(1,4) ) | ( s2(1,4)   != s(1,4) );
    57     sout | ( s(1,4) == frag ) | ( s(1,4) == s3   );
    58     sout | ( s(1,4) != s3   ) | ( s(1,4) != frag );
    59     sout | ( s(1,4) == "ell"   ) | ( s(1,4) == "world" );
    60     sout | ( s(1,4) != "world" ) | ( s(1,4) != "ell"   );
     53    sout | ( frag == s(1,3) ) | ( s3   == s(1,3) );
     54    sout | ( s3   != s(1,3) ) | ( frag != s(1,3) );
     55    sout | ( s2(1,3) == s(1,3) ) | ( s3(1,3)   == s(1,3) );
     56    sout | ( s3(1,3) != s(1,3) ) | ( s2(1,3)   != s(1,3) );
     57    sout | ( s(1,3) == frag ) | ( s(1,3) == s3   );
     58    sout | ( s(1,3) != s3   ) | ( s(1,3) != frag );
     59    sout | ( s(1,3) == "ell"   ) | ( s(1,3) == "world" );
     60    sout | ( s(1,3) != "world" ) | ( s(1,3) != "ell"   );
    6161
    6262
     
    6666    //
    6767    {
    68         string b1 = { "1234567", 3 };
    69         sout | b1; // 123
     68        string b1 = "1234567";
     69        sout | b1; // 1234567
     70
     71        string b1x = { "1234567", 3 };
     72        sout | b1x; // 123
    7073
    7174        string b2 = s;
    7275        sout | b2; // hello
     76
     77        string b2x = { s, 4 };
     78        sout | b2x; // hell
    7379
    7480        // todo: a plain string &
     
    8894        b4 = s_constref;
    8995        sout | b4;  // world
     96
     97        string b5 = 'Q';
     98        sout | b5; // Q
     99
     100
    90101    }
    91102                                            assertWellFormedHandleList( 10 );
     103    //
     104    // Assignments
     105    //
     106    {
     107        string b = "xxx";
     108
     109        b = "1234567";
     110        sout | b; // 1234567
     111
     112        b = "xxx";
     113        b = s;
     114        sout | b; // hello
     115       
     116        b = "xxx";
     117        b = 'Q';
     118        sout | b; // Q
     119       
     120        b = "xxx";
     121        assign( b, "1234567", 3 );
     122        sout | b; // 123
     123
     124        b = "xxx";
     125        assign( b, s, 4 );
     126        sout | b; // hell
     127
     128        b = "xxx";
     129        strcpy(b, "1234567");
     130        sout | b; // 1234567
     131
     132        b = "xxx";
     133        strcpy(b, s);
     134        sout | b; // hello
     135       
     136        b = "xxx";
     137        strncpy( b, "1234567", 3 );
     138        sout | b; // 123
     139
     140        b = "xxx";
     141        strncpy( b, s, 4 );
     142        sout | b; // hell
     143    }
     144                                            assertWellFormedHandleList( 10 );
     145
     146
    92147
    93148    sout | size(s); // 5
     
    126181    sout | sx; // bye, friend
    127182
     183    sx = "o";
     184    strcat( sx, s );
     185    sout | sx; // ohello
     186
     187    sx = "o";
     188    append( sx, s, 4 );
     189    sout | sx; // ohell
     190
     191    sx = "o";
     192    strncat( sx, s, 4 );
     193    sout | sx; // ohell
     194
     195    sx = "o";
     196    strcat( sx, "mydarling" );
     197    sout | sx; // omydarling
     198
     199    sx = "o";
     200    append( sx, "mydarling", 2 );
     201    sout | sx; // omy
     202
     203    sx = "o";
     204    strncat( sx, "mydarling", 2 );
     205    sout | sx; // omy
     206
    128207    //
    129208    // repetition
    130209    //
     210
     211    sx = s;
     212    sx *= 4;
     213    sout | sx; // hellohellohellohello
     214
    131215    sx = s * 3;
    132216    sout | sx; // hellohellohello
     
    142226    //
    143227
    144     //...
     228    // Range cases treated thoroughly in "string-overwrite" test.
     229    // Composability with comparison and search are demoed above and below.
     230    // Coverage here adds the single-argument ("rest of string") overload.
     231
     232    sx = s;
     233    sout | sx(3); // lo
     234    sx(3) = "iocentric";
     235    sout | s | sx; // hello heliocentric
    145236
    146237    //
     
    244335        | find( alphabet        , "def")  // 3
    245336        | find( alphabet( 0, 26), "def")  // 3
    246         | find( alphabet( 2, 26), "def")  // 1
    247         | find( alphabet( 3, 26), "def")  // 0
    248         | find( alphabet( 4, 26), "def")  // 22, not found
    249         | find( alphabet( 4, 26),  "ef")  // 0
     337        | find( alphabet( 2, 24), "def")  // 1
     338        | find( alphabet( 3, 23), "def")  // 0
     339        | find( alphabet( 4, 22), "def")  // 22, not found
     340        | find( alphabet( 4, 22),  "ef")  // 0
    250341        | find( alphabet( 0,  6), "def")  // 3
    251342        | find( alphabet( 0,  5), "def")  // 5, not found
     
    255346        | includes( alphabet        , "def")  // true
    256347        | includes( alphabet( 0, 26), "def")  // true
    257         | includes( alphabet( 2, 26), "def")  // true
    258         | includes( alphabet( 3, 26), "def")  // true
    259         | includes( alphabet( 4, 26), "def")  // false
    260         | includes( alphabet( 4, 26),  "ef")  // true
     348        | includes( alphabet( 2, 24), "def")  // true
     349        | includes( alphabet( 3, 23), "def")  // true
     350        | includes( alphabet( 4, 22), "def")  // false
     351        | includes( alphabet( 4, 22),  "ef")  // true
    261352        | includes( alphabet( 0,  6), "def")  // true
    262353        | includes( alphabet( 0,  5), "def")  // false
     
    266357        | startsWith( alphabet        , "abc")  // true
    267358        | startsWith( alphabet( 0, 26), "abc")  // true
    268         | startsWith( alphabet( 1, 26), "abc")  // false
    269         | startsWith( alphabet( 1, 26),  "bc")  // true
     359        | startsWith( alphabet( 1, 25), "abc")  // false
     360        | startsWith( alphabet( 1, 25),  "bc")  // true
    270361        | startsWith( alphabet( 0, 26), "abc")  // true
    271362        | startsWith( alphabet( 0,  4), "abc")  // true
     
    281372        | endsWith( alphabet( 0, 25), "xy" )  // true
    282373        | endsWith( alphabet( 0, 26), "xyz")  // true
    283         | endsWith( alphabet(23, 26), "xyz")  // true
    284         | endsWith( alphabet(24, 26), "xyz")  // false
    285         | endsWith( alphabet(24, 26),  "yz")  // true
     374        | endsWith( alphabet(23,  3), "xyz")  // true
     375        | endsWith( alphabet(24,  2), "xyz")  // false
     376        | endsWith( alphabet(24,  2),  "yz")  // true
    286377        | endsWith( alphabet        , "abc"); // false
    287378
  • tests/collections/string-compare.cfa

    r59c8dff rf988834  
    33
    44#define test_eq_(l, r) \
    5     chk( (cmp(l, r) == 0) ) \
     5    chk( (strcmp(l, r) == 0) ) \
    66    chk(  (l == r) ) \
    77    chk( !(l != r) ) \
     
    1717
    1818#define test_lt_(l, r) \
    19     chk( (cmp(l, r) < 0) ) \
     19    chk( (strcmp(l, r) < 0) ) \
    2020    chk( !(l == r) ) \
    2121    chk(  (l != r) ) \
     
    2626
    2727#define test_gt_(l, r) \
    28     chk( (cmp(l, r) > 0) ) \
     28    chk( (strcmp(l, r) > 0) ) \
    2929    chk( !(l == r) ) \
    3030    chk(  (l != r) ) \
  • tests/collections/string-overwrite.cfa

    r59c8dff rf988834  
    99MS = modifier start
    1010ME = modifier end
     11ML = modifier length
    1112WS = witness start
    1213WE = witness end
     14WL = witness length
    1315
    1416The test does:
     
    7173
    7274
    73 void showOneReplacement(string & s, int ms, int me, int ws, int we, const char* replaceWith) {
     75void showOneReplacement(string & s, int ms, int ml, int ws, int wl, const char* replaceWith) {
     76
     77    int me = ms + ml;
     78    int we = ws + wl;
    7479
    7580    assert( ms >= 0 && ms <= me && me <= size(s) );
    7681    assert( ws >= 0 && ws <= we && we <= size(s) );
    7782
    78     string mod = s(ms, me)`shareEdits;
    79     string wit = s(ws, we)`shareEdits;
     83    string mod = s(ms, ml)`shareEdits;
     84    string wit = s(ws, wl)`shareEdits;
    8085
    8186    string modOld = mod;
     
    118123void runReplaceCases() {
    119124    char * alphabetTemplate = "abcdefghijklmnopqrstuvwxyz";
    120     struct { int ms; int me; int ws; int we; char *replaceWith; char *label; } cases[] = {
    121         { 12, 14, 10, 20, "xxxxx", "warmup" },
    122         { 10, 10, 10, 10, "=====", "1"      },
    123         { 10, 10, 10, 10, "=="   , ""       },
    124         { 10, 10, 10, 10, "="    , ""       },
    125         { 10, 10, 10, 10, ""     , ""       },
    126         { 10, 12, 12, 12, "=====", "2"      },
    127         { 10, 12, 12, 12, "=="   , ""       },
    128         { 10, 12, 12, 12, "="    , ""       },
    129         { 10, 12, 12, 12, ""     , ""       },
    130         { 12, 12, 10, 12, "=====", "3"      },
    131         { 12, 12, 10, 12, "=="   , ""       },
    132         { 12, 12, 10, 12, "="    , ""       },
    133         { 12, 12, 10, 12, ""     , ""       },
    134         { 10, 10, 12, 12, "=====", "4"      },
    135         { 10, 10, 12, 12, "=="   , ""       },
    136         { 10, 10, 12, 12, "="    , ""       },
    137         { 10, 10, 12, 12, ""     , ""       },
    138         { 12, 12, 10, 10, "=====", "5"      },
    139         { 12, 12, 10, 10, "=="   , ""       },
    140         { 12, 12, 10, 10, "="    , ""       },
    141         { 12, 12, 10, 10, ""     , ""       },
    142         { 10, 12, 10, 12, "=====", "6"      },
    143         { 10, 12, 10, 12, "=="   , ""       },
    144         { 10, 12, 10, 12, "="    , ""       },
    145         { 10, 12, 10, 12, ""     , ""       },
    146         { 10, 12, 10, 10, "=====", "7"      },
    147         { 10, 12, 10, 10, "=="   , ""       },
    148         { 10, 12, 10, 10, "="    , ""       },
    149         { 10, 12, 10, 10, ""     , ""       },
    150         { 10, 10, 10, 12, "=====", "8"      },
    151         { 10, 10, 10, 12, "=="   , ""       },
    152         { 10, 10, 10, 12, "="    , ""       },
    153         { 10, 10, 10, 12, ""     , ""       },
    154         { 10, 12, 14, 14, "=====", "9"      },
    155         { 10, 12, 14, 14, "=="   , ""       },
    156         { 10, 12, 14, 14, "="    , ""       },
    157         { 10, 12, 14, 14, ""     , ""       },
    158         { 10, 14, 12, 14, "=====", "10"     },
    159         { 10, 14, 12, 14, "=="   , ""       },
    160         { 10, 14, 12, 14, "="    , ""       },  // FORMERLY unrunnable bug: tries to print seemingly infinite string
    161         { 10, 14, 12, 14, ""     , ""       },  // ditto
    162         { 14, 14, 10, 12, "=====", "11"     },
    163         { 14, 14, 10, 12, "=="   , ""       },
    164         { 14, 14, 10, 12, "="    , ""       },
    165         { 14, 14, 10, 12, ""     , ""       },
    166         { 12, 14, 10, 14, "=====", "12"     }, // correctness observation:  watching klmn while mn |-> xxx gives klxxx because the mn is inside what I'm watching
    167         { 12, 14, 10, 14, "=="   , ""       },
    168         { 12, 14, 10, 14, "="    , ""       },
    169         { 12, 14, 10, 14, ""     , ""       },
    170         { 10, 12, 12, 14, "=====", "13"     },
    171         { 10, 12, 12, 14, "=="   , ""       },
    172         { 10, 12, 12, 14, "="    , ""       },
    173         { 10, 12, 12, 14, ""     , ""       },
    174         { 10, 14, 12, 12, "=====", "14"     },
    175         { 10, 14, 12, 12, "=="   , ""       },
    176         { 10, 14, 12, 12, "="    , ""       },
    177         { 10, 14, 12, 12, ""     , ""       },
    178         { 12, 14, 10, 12, "=====", "15"     },
    179         { 12, 14, 10, 12, "=="   , ""       },
    180         { 12, 14, 10, 12, "="    , ""       },
    181         { 12, 14, 10, 12, ""     , ""       },
    182         { 12, 12, 10, 14, "=====", "16"     },
    183         { 12, 12, 10, 14, "=="   , ""       },
    184         { 12, 12, 10, 14, "="    , ""       },
    185         { 12, 12, 10, 14, ""     , ""       },
    186         { 10, 14, 10, 12, "=====", "17"     },
    187         { 10, 14, 10, 12, "=="   , ""       },
    188         { 10, 14, 10, 12, "="    , ""       },
    189         { 10, 14, 10, 12, ""     , ""       },
    190         { 10, 10, 12, 14, "=====", "18"     },
    191         { 10, 10, 12, 14, "=="   , ""       },
    192         { 10, 10, 12, 14, "="    , ""       },
    193         { 10, 10, 12, 14, ""     , ""       },
    194         { 10, 12, 10, 14, "=====", "19"     },
    195         { 10, 12, 10, 14, "=="   , ""       },
    196         { 10, 12, 10, 14, "="    , ""       },
    197         { 10, 12, 10, 14, ""     , ""       },
    198         { 12, 14, 10, 10, "=====", "20"     },
    199         { 12, 14, 10, 10, "=="   , ""       },
    200         { 12, 14, 10, 10, "="    , ""       },
    201         { 12, 14, 10, 10, ""     , ""       },
    202         { 10, 12, 14, 16, "=====", "21"     },
    203         { 10, 12, 14, 16, "=="   , ""       },
    204         { 10, 12, 14, 16, "="    , ""       },
    205         { 10, 12, 14, 16, ""     , ""       },
    206         { 10, 14, 12, 16, "=====", "22"     },
    207         { 10, 14, 12, 16, "=="   , ""       },
    208         { 10, 14, 12, 16, "="    , ""       },
    209         { 10, 14, 12, 16, ""     , ""       },
    210         { 10, 16, 12, 14, "=====", "23"     },
    211         { 10, 16, 12, 14, "=="   , ""       },
    212         { 10, 16, 12, 14, "="    , ""       },
    213         { 10, 16, 12, 14, ""     , ""       },
    214         { 14, 16, 10, 12, "=====", "24"     },
    215         { 14, 16, 10, 12, "=="   , ""       },
    216         { 14, 16, 10, 12, "="    , ""       },
    217         { 14, 16, 10, 12, ""     , ""       },
    218         { 12, 16, 10, 14, "=====", "25"     },
    219         { 12, 16, 10, 14, "=="   , ""       },
    220         { 12, 16, 10, 14, "="    , ""       },
    221         { 12, 16, 10, 14, ""     , ""       },
    222         { 12, 14, 10, 16, "=====", "26"     },
    223         { 12, 14, 10, 16, "=="   , ""       },
    224         { 12, 14, 10, 16, "="    , ""       },
    225         { 12, 14, 10, 16, ""     , ""       },
     125    struct { int ms; int ml; int ws; int wl; char *replaceWith; char *label; } cases[] = {
     126        { 12,  2, 10, 10, "xxxxx", "warmup" },
     127        { 10,  0, 10,  0, "=====", "1"      },
     128        { 10,  0, 10,  0, "=="   , ""       },
     129        { 10,  0, 10,  0, "="    , ""       },
     130        { 10,  0, 10,  0, ""     , ""       },
     131        { 10,  2, 12,  0, "=====", "2"      },
     132        { 10,  2, 12,  0, "=="   , ""       },
     133        { 10,  2, 12,  0, "="    , ""       },
     134        { 10,  2, 12,  0, ""     , ""       },
     135        { 12,  0, 10,  2, "=====", "3"      },
     136        { 12,  0, 10,  2, "=="   , ""       },
     137        { 12,  0, 10,  2, "="    , ""       },
     138        { 12,  0, 10,  2, ""     , ""       },
     139        { 10,  0, 12,  0, "=====", "4"      },
     140        { 10,  0, 12,  0, "=="   , ""       },
     141        { 10,  0, 12,  0, "="    , ""       },
     142        { 10,  0, 12,  0, ""     , ""       },
     143        { 12,  0, 10,  0, "=====", "5"      },
     144        { 12,  0, 10,  0, "=="   , ""       },
     145        { 12,  0, 10,  0, "="    , ""       },
     146        { 12,  0, 10,  0, ""     , ""       },
     147        { 10,  2, 10,  2, "=====", "6"      },
     148        { 10,  2, 10,  2, "=="   , ""       },
     149        { 10,  2, 10,  2, "="    , ""       },
     150        { 10,  2, 10,  2, ""     , ""       },
     151        { 10,  2, 10,  0, "=====", "7"      },
     152        { 10,  2, 10,  0, "=="   , ""       },
     153        { 10,  2, 10,  0, "="    , ""       },
     154        { 10,  2, 10,  0, ""     , ""       },
     155        { 10,  0, 10,  2, "=====", "8"      },
     156        { 10,  0, 10,  2, "=="   , ""       },
     157        { 10,  0, 10,  2, "="    , ""       },
     158        { 10,  0, 10,  2, ""     , ""       },
     159        { 10,  2, 14,  0, "=====", "9"      },
     160        { 10,  2, 14,  0, "=="   , ""       },
     161        { 10,  2, 14,  0, "="    , ""       },
     162        { 10,  2, 14,  0, ""     , ""       },
     163        { 10,  4, 12,  2, "=====", "10"     },
     164        { 10,  4, 12,  2, "=="   , ""       },
     165        { 10,  4, 12,  2, "="    , ""       },  // FORMERLY unrunnable bug: tries to print seemingly infinite string
     166        { 10,  4, 12,  2, ""     , ""       },  // ditto
     167        { 14,  0, 10,  2, "=====", "11"     },
     168        { 14,  0, 10,  2, "=="   , ""       },
     169        { 14,  0, 10,  2, "="    , ""       },
     170        { 14,  0, 10,  2, ""     , ""       },
     171        { 12,  2, 10,  4, "=====", "12"     }, // correctness observation:  watching klmn while mn |-> xxx gives klxxx because the mn is inside what I'm watching
     172        { 12,  2, 10,  4, "=="   , ""       },
     173        { 12,  2, 10,  4, "="    , ""       },
     174        { 12,  2, 10,  4, ""     , ""       },
     175        { 10,  2, 12,  2, "=====", "13"     },
     176        { 10,  2, 12,  2, "=="   , ""       },
     177        { 10,  2, 12,  2, "="    , ""       },
     178        { 10,  2, 12,  2, ""     , ""       },
     179        { 10,  4, 12,  0, "=====", "14"     },
     180        { 10,  4, 12,  0, "=="   , ""       },
     181        { 10,  4, 12,  0, "="    , ""       },
     182        { 10,  4, 12,  0, ""     , ""       },
     183        { 12,  2, 10,  2, "=====", "15"     },
     184        { 12,  2, 10,  2, "=="   , ""       },
     185        { 12,  2, 10,  2, "="    , ""       },
     186        { 12,  2, 10,  2, ""     , ""       },
     187        { 12,  0, 10,  4, "=====", "16"     },
     188        { 12,  0, 10,  4, "=="   , ""       },
     189        { 12,  0, 10,  4, "="    , ""       },
     190        { 12,  0, 10,  4, ""     , ""       },
     191        { 10,  4, 10,  2, "=====", "17"     },
     192        { 10,  4, 10,  2, "=="   , ""       },
     193        { 10,  4, 10,  2, "="    , ""       },
     194        { 10,  4, 10,  2, ""     , ""       },
     195        { 10,  0, 12,  2, "=====", "18"     },
     196        { 10,  0, 12,  2, "=="   , ""       },
     197        { 10,  0, 12,  2, "="    , ""       },
     198        { 10,  0, 12,  2, ""     , ""       },
     199        { 10,  2, 10,  4, "=====", "19"     },
     200        { 10,  2, 10,  4, "=="   , ""       },
     201        { 10,  2, 10,  4, "="    , ""       },
     202        { 10,  2, 10,  4, ""     , ""       },
     203        { 12,  2, 10,  0, "=====", "20"     },
     204        { 12,  2, 10,  0, "=="   , ""       },
     205        { 12,  2, 10,  0, "="    , ""       },
     206        { 12,  2, 10,  0, ""     , ""       },
     207        { 10,  2, 14,  2, "=====", "21"     },
     208        { 10,  2, 14,  2, "=="   , ""       },
     209        { 10,  2, 14,  2, "="    , ""       },
     210        { 10,  2, 14,  2, ""     , ""       },
     211        { 10,  4, 12,  4, "=====", "22"     },
     212        { 10,  4, 12,  4, "=="   , ""       },
     213        { 10,  4, 12,  4, "="    , ""       },
     214        { 10,  4, 12,  4, ""     , ""       },
     215        { 10,  6, 12,  2, "=====", "23"     },
     216        { 10,  6, 12,  2, "=="   , ""       },
     217        { 10,  6, 12,  2, "="    , ""       },
     218        { 10,  6, 12,  2, ""     , ""       },
     219        { 14,  2, 10,  2, "=====", "24"     },
     220        { 14,  2, 10,  2, "=="   , ""       },
     221        { 14,  2, 10,  2, "="    , ""       },
     222        { 14,  2, 10,  2, ""     , ""       },
     223        { 12,  4, 10,  4, "=====", "25"     },
     224        { 12,  4, 10,  4, "=="   , ""       },
     225        { 12,  4, 10,  4, "="    , ""       },
     226        { 12,  4, 10,  4, ""     , ""       },
     227        { 12,  2, 10,  6, "=====", "26"     },
     228        { 12,  2, 10,  6, "=="   , ""       },
     229        { 12,  2, 10,  6, "="    , ""       },
     230        { 12,  2, 10,  6, ""     , ""       },
    226231    };
    227232    for ( i; sizeof(cases)/sizeof(cases[0]) ) {
    228233        sout | "------------------------------------------------------------------------" | cases[i].label;
    229234        string replaceIn = alphabetTemplate;
    230         showOneReplacement( replaceIn, cases[i].ms, cases[i].me, cases[i].ws, cases[i].we, cases[i].replaceWith );
     235        showOneReplacement( replaceIn, cases[i].ms, cases[i].ml, cases[i].ws, cases[i].wl, cases[i].replaceWith );
    231236    }
    232237}
     
    244249    string s = "abcdefghijklmnopqrstuvwxyz";
    245250
    246     s(5,10) = "qqqqq";  // start=5, end=10, len=5
    247 
    248     sout | s;
    249 
    250 
    251     s(5,5) = "-----";  // start=5, end=5, len=0
     251    s(5,5) = "qqqqq";  // start=5, end=10, len=5
     252
     253    sout | s;
     254
     255
     256    s(5,0) = "-----";  // start=5, end=5, len=0
    252257
    253258    sout | s;
  • tests/concurrency/examples/quickSort.cfa

    r59c8dff rf988834  
    1111// Created On       : Wed Dec  6 12:15:52 2017
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Wed Feb 12 18:24:47 2020
    14 // Update Count     : 177
    15 //
    16 
    17 #include <fstream.hfa>
    18 #include <stdlib.hfa>
    19 #include <kernel.hfa>
     13// Last Modified On : Mon Jan  1 12:07:59 2024
     14// Update Count     : 188
     15//
     16
     17#include <fstream.hfa>                                                                  // sin/sout
     18#include <stdlib.hfa>                                                                   // convert
    2019#include <thread.hfa>
     20#include <math.hfa>                                                                             // sqrt
    2121#include <string.h>                                                                             // strcmp
    2222
     
    8282} // main
    8383
    84 
    85 bool convert( int & val, const char * nptr ) {                  // convert C string to integer
    86         char * eptr;
    87         int temp = strto( nptr, &eptr, 10 );                            // do not change val on false
    88         // true => entire string valid with no extra characters
    89         return *nptr != '\0' && *eptr == '\0' ? val = temp, true : false;
    90 } // convert
    91 
    92 void usage( char * argv[] ) {
    93         sout | "Usage:" | argv[0] | "( -s unsorted-file [ sorted-file ] | -t size (>= 0) [ depth (>= 0) ] )";
    94         exit( EXIT_FAILURE );                                                           // TERMINATE!
    95 } // usage
    96 
     84// convert(...) throws out_of_range or invalid_argument
     85ExceptionDecl( cmd_error );
    9786
    9887int main( int argc, char * argv[] ) {
    99         ifstream & unsortedfile = sin;
    100         ofstream & sortedfile = sout;                                           // default value
    101         int depth = 0, size;
    102 
    103         if ( argc != 1 ) {                                                                      // do not use defaults
    104                 if ( argc < 2 || argc > 4 ) usage( argv );              // wrong number of options
    105                 if ( strcmp( argv[1], "-t" ) == 0 ) {                   // timing ?
    106                         &unsortedfile = (ifstream *)0;                          // no input
     88        ifstream unsortedfile = sin;                                            // default values
     89        ofstream sortedfile = sout;
     90        // Must be signed because of the conversion routine.
     91        intmax_t depth = 0;
     92        intmax_t size = -1;                                                                     // -1 means time mode not activated
     93
     94        try {
     95                if ( 1 < argc && strcmp( argv[1], "-t" ) == 0 ) { // time mode ?
    10796                        choose ( argc ) {
    10897                          case 4:
    109                                 if ( ! convert( depth, argv[3] ) || depth < 0 ) usage( argv );
     98                                depth = convert( argv[3] );                             // invalid integer ?
     99                                if ( depth < 0 ) throw ExceptionInst( cmd_error );
    110100                                fallthrough;
    111101                          case 3:
    112                                 if ( ! convert( size, argv[2] ) || size < 0 ) usage( argv );
     102                                size = convert( argv[2] );                              // invalid integer ?
     103                                if ( size < 0 ) throw ExceptionInst( cmd_error );
     104                          default:                                                                      // wrong number of options
     105                                throw ExceptionInst( cmd_error );
    113106                        } // choose
    114107                } else {                                                                                // sort file
    115108                        choose ( argc ) {
    116                           case 3:
    117                                 &sortedfile = new( (const char *)argv[2] ); // open the output file
    118                                 if ( fail( sortedfile ) ) {
    119                                         serr | "Error! Could not open sorted output file \"" | argv[2] | "\"";
    120                                         usage( argv );
     109                          case 4:
     110                                depth = convert( argv[3] );                             // invalid integer ?
     111                                if ( depth < 0 ) throw ExceptionInst( cmd_error );
     112                                fallthrough;
     113                          case 3: case 2:
     114                                if ( strcmp( argv[1], "d" ) != 0 ) {
     115                                        try {                                                           // open input file first as output creates file
     116                                                open( unsortedfile, argv[1] );
     117                                        } catch( open_failure * ) {                     // open failed ?
     118                                                serr | "Error! Could not open unsorted input file \"" | argv[1] | "\"";
     119                                                throw ExceptionInst( cmd_error );
     120                                        } // try
     121                                } // if
     122                                if ( argc > 2 && strcmp( argv[2], "d" ) != 0 ) {
     123                                        try {
     124                                                open( sortedfile, argv[2] );
     125                                        } catch( open_failure * ) {                     // open failed ?
     126                                                serr | "Error! Could not open sorted output file \"" | argv[2] | "\"";
     127                                                throw ExceptionInst( cmd_error );
     128                                        } // try
    121129                                } // if
    122130                                fallthrough;
    123                           case 2:
    124                                 &unsortedfile = new( (const char *)argv[1] ); // open the input file
    125                                 if ( fail( unsortedfile ) ) {
    126                                         serr | "Error! Could not open unsorted input file \"" | argv[1] | "\"";
    127                                         usage( argv );
    128                                 } // if
     131                          case 1: ;                                                                     // defaults
     132                          default:                                                                      // wrong number of options
     133                                throw ExceptionInst( cmd_error );
    129134                        } // choose
    130135                } // if
    131         } // if
     136        } catch( exception_t * ) {                                                      // catch any
     137                exit | "Usage: " | argv[0] |                                    // TERMINATE
     138                        " ( [ unsorted-file | 'd' [ sorted-file | 'd' [ depth (>= 0) ] ] ]"
     139                        " | -t size (>= 0) [ depth (>= 0) ] )";
     140        } //  try
     141
     142        enum { ValuesPerLine = 22 };                                            // number of values printed per line
     143
    132144        sortedfile | nlOff;                                                                     // turn off auto newline
    133145
    134         enum { ValuesPerLine = 22 };                                            // number of values printed per line
    135 
    136         if ( &unsortedfile ) {                                                          // generate output ?
     146        if ( size == -1 ) {                                                                     // generate output ?
    137147                for () {
    138148                        unsortedfile | size;                                            // read number of elements in the list
    139149                  if ( eof( unsortedfile ) ) break;
    140                         int * values = alloc( size );                           // values to be sorted, too large to put on stack
     150
     151                        int * values = aalloc( size );                          // values to be sorted, too large to put on stack
    141152                        for ( counter; size ) {                                         // read unsorted numbers
    142153                                unsortedfile | values[counter];
     
    146157                        } // for
    147158                        sortedfile | nl;
     159
    148160                        if ( size > 0 ) {                                                       // values to sort ?
    149161                                Quicksort QS = { values, size - 1, 0 }; // sort values
     
    158170                        delete( values );
    159171                } // for
    160                 if ( &unsortedfile != &sin ) delete( &unsortedfile ); // close input/output files
    161                 if ( &sortedfile != &sout ) delete( &sortedfile );
    162         } else {
     172        } else {                                                                                        // timing
     173                PRNG prng;                                                                             
    163174                processor processors[ (1 << depth) - 1 ] __attribute__(( unused )); // create 2^depth-1 kernel threads
    164 
    165                 int * values = alloc( size );                                   // values to be sorted, too large to put on stack
     175                int * values = aalloc( size );                                  // values to be sorted, too large to put on stack
     176
    166177                for ( counter; size ) {                                                 // generate unsorted numbers
    167178                        values[counter] = size - counter;                       // descending values
    168179                } // for
    169                 for ( i; 200 ) {                                                                // random shuffle a few values
    170                         swap( values[rand() % size], values[rand() % size] );
     180
     181                unsigned int times = sqrt( size );
     182                for ( unsigned int counter = 0; counter < times; counter += 1 ) {
     183                        swap( values[0], values[prng(size)] );          // randomize unsorted numbers
    171184                } // for
    172185                {
  • tests/exceptions/hotpotato.cfa

    r59c8dff rf988834  
    55
    66struct Potato {
    7         PRNG & prng;
    8         unsigned int deadline;                                                          // when timer goes off
    9         unsigned int timer;                                                                     // up counter to deadline
     7        PRNG & prng;
     8        unsigned int deadline;                                                          // when timer goes off
     9        unsigned int timer;                                                                     // up counter to deadline
    1010}; // Potato
    1111
     
    1616        &potato.prng = &prng;
    1717        reset( potato, maxTicks );
    18 } // Potato
     18                } // Potato
    1919
    2020coroutine Player {
    21         PRNG & prng;
    22         int id;                                                                                         // player identity
    23         Potato & potato;                                                                        // potato being tossed
    24         Player * partner[2];                                                            // left and right player
     21        PRNG & prng;
     22        int id;                                                                                         // player identity
     23        Potato & potato;                                                                        // potato being tossed
     24        Player * partner[2];                                                            // left and right player
    2525}; // Player
    2626
     
    2929        player.id = id;
    3030        &player.potato = &potato;
    31 } // Player
     31                } // Player
    3232
    3333Player & umpire;
     
    3939
    4040void reset( Potato & potato, unsigned int maxTicks ) with(potato) {
    41   if ( maxTicks < 2 ) abort( "Hot Potato initialized with less than 2 ticks" ); // optional
     41        if ( maxTicks < 2 ) abort( "Hot Potato initialized with less than 2 ticks" ); // optional
    4242        deadline = prng( prng, 1, maxTicks );
    4343        timer = 0;
     
    6060enum { LEFT = 0, RIGHT = 1 };
    6161
    62 static void vote( Player & player, Election & election ) {                                      // cause partner to vote
    63     resumeAt( player, election );
     62static void vote( Player & player, Election & election ) { // cause partner to vote
     63        resumeAt( player, election );
    6464        resume( player );
    6565} // vote
     
    7676
    7777void main( Player & player ) with(player) {
    78     suspend;                                                                    // return immediately after establishing starter
     78        suspend;                                                                                        // return immediately after establishing starter
    7979        try {
    80         for ( ;; ) {
    81             poll();                                     // check for non-local exceptions before proceeding
    82 
    83             if ( partner[LEFT] == &player ) {                   // stop when only one player
    84                 sout | id | " wins the Match!";
    85                 return;
    86             } // exit
    87            
    88             countdown( potato );                                // player is eliminated if countdown() returned true
    89            
    90             size_t side = prng( prng, 2 );
    91             sout | id | " -> " | nonl;
    92             resume( *partner[ side ] );                 // random toss left/right
    93         } // for
     80                for ( ;; ) {
     81                        poll();                                                                         // check for non-local exceptions before proceeding
     82
     83                        if ( partner[LEFT] == &player ) {                       // stop when only one player
     84                                sout | id | " wins the Match!";
     85                                return;
     86                        } // exit
     87
     88                        countdown( potato );                                            // player is eliminated if countdown() returned true
     89
     90                        size_t side = prng( prng, 2 );
     91                        sout | id | " -> " | nonl;
     92                        resume( *partner[ side ] );                                     // random toss left/right
     93                } // for
    9494        } catchResume( Terminate * v ) {
    9595                v->victim->partner[LEFT]->partner[RIGHT] = v->victim->partner[RIGHT]; // unlink node
    9696                v->victim->partner[RIGHT]->partner[LEFT] = v->victim->partner[LEFT];
    97         delete( v->victim );
     97                delete( v->victim );
    9898                reset( potato );
    9999                sout | "U " | nonl;                                                             // start new game
     
    102102                sout | "election";
    103103                sout | " -> " | id | nonl;
    104                 if ( id > getId( umpire ) ) &umpire = &player; // set umpire to highest id so far
     104                if ( id > getId( umpire ) ) &umpire = &player;  // set umpire to highest id so far
    105105                vote( *partner[RIGHT], *election );
    106106        } catchResume ( Explode * ) {
    107         sout | id | " is eliminated";
    108         if ( &player == &umpire ) {
    109             id = -1;                                    // remove from election
    110             vote( *partner[RIGHT], ExceptionInst( Election ) );         // start election
    111             try { poll(); } catchResume( Election * election ) {} // handle end of election
    112             sout | " : umpire " | getId( umpire );
    113         } // if
    114         resumeAt( umpire, ExceptionInst( Terminate, &player ) );
    115         resume( umpire );                   // resume umpire to terminate this player
    116         assert( false );                                        // no return
    117     } // try
     107                sout | id | " is eliminated";
     108                if ( &player == &umpire ) {
     109                        id = -1;                                                                        // remove from election
     110                        vote( *partner[RIGHT], ExceptionInst( Election ) );     // start election
     111                        try { poll(); } catchResume( Election * election ) {} // handle end of election
     112                        sout | " : umpire " | getId( umpire );
     113                } // if
     114                resumeAt( umpire, ExceptionInst( Terminate, &player ) );
     115                resume( umpire );                                                               // resume umpire to terminate this player
     116                assert( false );                                                                // no return
     117        } // try
    118118} // main
    119119
     
    151151                  case 1: ;                                                                             // defaults
    152152                  default:                                                                              // too many arguments
    153                         throw ExceptionInst( cmd_error );
     153                          throw ExceptionInst( cmd_error );
    154154                } // choose
    155155        } catch( exception_t * ) {                                                      // catch any
    156156                exit | "Usage: " | argv[0]
    157                          | " [ games (>=0) | 'd' (default " | DefaultGames
    158                          | ") [ players (>=2) | 'd' (random " | MinNoPlayers | "-" | MaxNoPlayers
    159                          | ") [ seed (>0) | 'd' (random) ] ] ]";
     157                        | " [ games (>=0) | 'd' (default " | DefaultGames
     158                        | ") [ players (>=2) | 'd' (random " | MinNoPlayers | "-" | MaxNoPlayers
     159                        | ") [ seed (>0) | 'd' (random) ] ] ]";
    160160        } // try
    161161        sout | numGames | numPlayers | seed;
  • tests/exceptions/hotpotato_checked.cfa

    r59c8dff rf988834  
    55
    66struct Potato {
    7         PRNG & prng;
    8         unsigned int deadline;                                                          // when timer goes off
    9         unsigned int timer;                                                                     // up counter to deadline
     7        PRNG & prng;
     8        unsigned int deadline;                                                          // when timer goes off
     9        unsigned int timer;                                                                     // up counter to deadline
    1010}; // Potato
    1111
     
    1616        &potato.prng = &prng;
    1717        reset( potato, maxTicks );
    18 } // Potato
     18                } // Potato
    1919
    2020coroutine Player {
    21         PRNG & prng;
    22         int id;                                                                                         // player identity
    23         Potato & potato;                                                                        // potato being tossed
    24         Player * partner[2];                                                            // left and right player
     21        PRNG & prng;
     22        int id;                                                                                         // player identity
     23        Potato & potato;                                                                        // potato being tossed
     24        Player * partner[2];                                                            // left and right player
    2525}; // Player
    2626
     
    2929        player.id = id;
    3030        &player.potato = &potato;
    31 } // Player
     31                } // Player
    3232
    3333Player & umpire;
     
    3939
    4040void reset( Potato & potato, unsigned int maxTicks ) with(potato) {
    41   if ( maxTicks < 2 ) abort( "Hot Potato initialized with less than 2 ticks" ); // optional
     41        if ( maxTicks < 2 ) abort( "Hot Potato initialized with less than 2 ticks" ); // optional
    4242        deadline = prng( prng, 1, maxTicks );
    4343        timer = 0;
     
    6666static void terminate( Player & player ) {                              // resume umpire
    6767        resume( player );
    68     checked_poll();
    69     sout | "THIS SHOULD NOT BE REACHED";
     68        checked_poll();
     69        sout | "THIS SHOULD NOT BE REACHED";
    7070} // terminate
    7171
     
    7474        partner[RIGHT] = &rp;
    7575        resume( player );                                                                       // establish main as starter for termination
    76     checked_poll();
     76        checked_poll();
    7777} // init
    7878
     
    8282
    8383void toss( Player & player ) {                                                  // tossed the potato
    84     resume( player );
     84        resume( player );
    8585        checked_poll();
    8686} // toss
     
    8888void main( Player & player ) with(player) {
    8989        try {
    90         enable_ehm();                                                           // allow delivery of nonlocal exceptions
    91         suspend;                                                                        // return immediately after establishing starter
    92         checked_poll();
    93 
    94         for ( ;; ) {
    95             checked_poll();
    96             if ( partner[LEFT] == &player ) {                   // stop when only one player
    97                 sout | id | " wins the Match!";
    98                 return;
    99             } // exit
    100 
    101             countdown( potato );                                // player is eliminated if countdown() returned true
    102 
    103             size_t side = prng( prng, 2 );
    104             sout | id | " -> " | nonl;
    105             toss( *partner[ side ] );                   // random toss left/right
    106         } // for
    107         disable_ehm();
     90                enable_ehm();                                                                   // allow delivery of nonlocal exceptions
     91                suspend;                                                                                // return immediately after establishing starter
     92                checked_poll();
     93
     94                for ( ;; ) {
     95                        checked_poll();
     96                        if ( partner[LEFT] == &player ) {                       // stop when only one player
     97                                sout | id | " wins the Match!";
     98                                return;
     99                        } // exit
     100
     101                        countdown( potato );                                            // player is eliminated if countdown() returned true
     102
     103                        size_t side = prng( prng, 2 );
     104                        sout | id | " -> " | nonl;
     105                        toss( *partner[ side ] );                                       // random toss left/right
     106                } // for
     107                disable_ehm();
    108108        } catchResume( Terminate * v ) {
    109109                v->victim->partner[LEFT]->partner[RIGHT] = v->victim->partner[RIGHT]; // unlink node
    110110                v->victim->partner[RIGHT]->partner[LEFT] = v->victim->partner[LEFT];
    111         delete( v->victim );
     111                delete( v->victim );
    112112                reset( potato );
    113113                sout | "U " | nonl;                                                             // start new game
     
    116116                sout | "election";
    117117                sout | " -> " | id | nonl;
    118                 if ( id > getId( umpire ) ) &umpire = &player; // set umpire to highest id so far
    119         resumeAt( *partner[RIGHT], *election );
    120         disable_ehm();              // disable ehm since we can't handle execption thrown in vote here and want to poll later
     118                if ( id > getId( umpire ) ) &umpire = &player;  // set umpire to highest id so far
     119                resumeAt( *partner[RIGHT], *election );
     120                disable_ehm();                                                                  // disable ehm since we can't handle execption thrown in vote here and want to poll later
    121121                vote( *partner[RIGHT] );
    122         enable_ehm();               // enable after vote
     122                enable_ehm();                                                                   // enable after vote
    123123        } catchResume( Explode * ) {
    124         sout | id | " is eliminated";
    125         if ( &player == &umpire ) {
    126             try {
    127                 id = -1;                                        // remove from election
    128                 resumeAt( *partner[RIGHT], ExceptionInst( Election ) );
    129                 vote( *partner[RIGHT] );                // start election
    130                 checked_poll();
    131             } catchResume( Election * election ) {
    132                 sout | " : umpire " | getId( umpire );
    133             } // try
    134         } // if
    135         resumeAt( umpire, ExceptionInst( Terminate, &player ) );
    136         terminate( umpire );
    137         assert( false );                                        // no return
    138     } // try
     124                sout | id | " is eliminated";
     125                if ( &player == &umpire ) {
     126                        try {
     127                                id = -1;                                                                // remove from election
     128                                resumeAt( *partner[RIGHT], ExceptionInst( Election ) );
     129                                vote( *partner[RIGHT] );                                // start election
     130                                checked_poll();
     131                        } catchResume( Election * election ) {
     132                                sout | " : umpire " | getId( umpire );
     133                        } // try
     134                } // if
     135                resumeAt( umpire, ExceptionInst( Terminate, &player ) );
     136                terminate( umpire );
     137                assert( false );                                                                // no return
     138        } // try
    139139} // main
    140140
     
    172172                  case 1: ;                                                                             // defaults
    173173                  default:                                                                              // too many arguments
    174                         throw ExceptionInst( cmd_error );
     174                          throw ExceptionInst( cmd_error );
    175175                } // choose
    176176        } catch( exception_t * ) {                                                      // catch any
    177177                exit | "Usage: " | argv[0]
    178                          | " [ games (>=0) | 'd' (default " | DefaultGames
    179                          | ") [ players (>=2) | 'd' (random " | MinNoPlayers | "-" | MaxNoPlayers
    180                          | ") [ seed (>0) | 'd' (random) ] ] ]";
     178                        | " [ games (>=0) | 'd' (default " | DefaultGames
     179                        | ") [ players (>=2) | 'd' (random " | MinNoPlayers | "-" | MaxNoPlayers
     180                        | ") [ seed (>0) | 'd' (random) ] ] ]";
    181181        } // try
    182182        sout | numGames | numPlayers | seed;
  • tests/io/.expect/manipulatorsInput.arm64.txt

    r59c8dff rf988834  
    202014 rc=1, cccc
    212115 rc=0, q
     2216 get this line
     2317 @# this line 1)-{}
     2418 abc
     2519 abc 
     2620  d d
     27
     28d
     2921              ZC44%
    22301 yyyyyyyyyyyyyyyyyyyy
    23312 abcxxx
     
    354314 cccc
    364415
     4516 get this line
     4617 @# this line 1)-{}
     4718 abc
     4819 abc 
     4920 d d
     50
     51d
     5221              ZC44%
    3753a
    3854a
  • tests/io/.expect/manipulatorsInput.x64.txt

    r59c8dff rf988834  
    202014 rc=1, cccc
    212115 rc=0, q
     2216 get this line
     2317 @# this line 1)-{}
     2418 abc
     2519 abc 
     2620  d d
     27
     28d
     2921              ZC44%
    22301 yyyyyyyyyyyyyyyyyyyy
    23312 abcxxx
     
    354314 cccc
    364415
     4516 get this line
     4617 @# this line 1)-{}
     4718 abc
     4819 abc 
     4920 d d
     50
     51d
     5221              ZC44%
    3753a
    3854a
  • tests/io/.expect/manipulatorsInput.x86.txt

    r59c8dff rf988834  
    202014 rc=1, cccc
    212115 rc=0, q
     2216 get this line
     2317 @# this line 1)-{}
     2418 abc
     2519 abc 
     2620  d d
     27
     28d
     2921              ZC44%
    22301 yyyyyyyyyyyyyyyyyyyy
    23312 abcxxx
     
    354314 cccc
    364415
     4516 get this line
     4617 @# this line 1)-{}
     4718 abc
     4819 abc 
     4920 d d
     50
     51d
     5221              ZC44%
    3753a
    3854a
  • tests/io/.in/manipulatorsInput.txt

    r59c8dff rf988834  
    1010aaaaaaaaxxxxxxxxaabbccbbdddwwwbbbbbbbbwwwwwwwwaaaaaaaawwwwwwww
    1111uuuuuccccuuuuu
     12get this line
     13@# this line 1)-{}%
     14"abc"
     15'abc  '
     16{ d d
     17
     18d }
     19X               ZC44%Y
    1220abc
    1321cccccb
     
    1725aaaaaaaaxxxxxxxxaabbccbbdddwwwbbbbbbbbwwwwwwwwaaaaaaaawwwwwwww
    1826uuuuuccccuuuuu
     27get this line
     28@# this line 1)-{}%
     29"abc"
     30'abc  '
     31{ d d
     32
     33d }
     34X               ZC44%Y
    1935ab
    20360xff 017 15-15
  • tests/io/manipulatorsInput.cfa

    r59c8dff rf988834  
    77// Created On       : Sat Jun  8 17:58:54 2019
    88// Last Modified By : Peter A. Buhr
    9 // Last Modified On : Sat Sep  2 14:27:46 2023
    10 // Update Count     : 65
     9// Last Modified On : Wed Jan  3 11:15:04 2024
     10// Update Count     : 103
    1111//
    1212
     
    7777                s[0] = 'q'; s[1] = '\0'; rc = 99;
    7878                rc = scanf( "%[^u]", s );                                               printf( "15 rc=%d, %s\n", rc, s );
    79                 scanf( "%*[u]" );
    80                 scanf("\n");
     79                scanf( "%*[u]\n" );
     80                scanf( "%[^\n]\n", s );                                                 printf( "16 %s\n", s );
     81                scanf( "%[^%%]%%\n", s );                                               printf( "17 %s\n", s );
     82
     83                scanf( "%*[ \f\n\r\t\v]" );                                             // ignore whitespace
     84                scanf( "\"%[^\"]\"", s );                                               printf( "18 %s\n", s );
     85                scanf( "%*[ \f\n\r\t\v]" );                                             // ignore whitespace
     86                scanf( "'%[^']'", s );                                                  printf( "19 %s\n", s );
     87                scanf( "%*[ \f\n\r\t\v]" );                                             // ignore whitespace
     88                scanf( "{%[^}]}", s );                                                  printf( "20 %s\n", s );
     89                scanf( "%*[ \f\n\r\t\v]" );                                             // ignore whitespace
     90                scanf( "X%[^Y]Y", s );                                                  printf( "21 %s\n", s );
     91                scanf( "\n" );                                                                  // must start next line
    8192        }
    8293        {
     
    102113                s[0] = 'q'; s[1] = '\0';
    103114                sin | excl( "u", wdi( sizeof(s), s ) );                 sout | "15" | s;
    104                 sin | skip( "u" );
    105                 sin | "\n";
    106         }
    107     /* Keep harmonized with collections/string-istream-manip */
     115                sin | skip( "u" ) | "\n";
     116                sin | getline( wdi( sizeof(s), s ) );                   sout | "16" | s;
     117                sin | getline( wdi( sizeof(s), s ), '%' ) | "\n"; sout | "17" | s;
     118
     119                sin | quoted( wdi( sizeof(s), s ) );                    sout | "18" | s;
     120                sin | quoted( wdi( sizeof(s), s ), '\'' );              sout | "19" | s;
     121                sin | quoted( wdi( sizeof(s), s ), '{', '}' );  sout | "20" | s;
     122                sin | quoted( wdi( sizeof(s), s ), 'X', 'Y' );  sout | "21" | s;
     123        }
     124    // Keep harmonized with collections/string-istream-manip
    108125        {
    109126                char c;
Note: See TracChangeset for help on using the changeset viewer.