Changeset ea46db7 for src/tests


Ignore:
Timestamp:
Mar 4, 2018, 12:20:36 PM (6 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
1feb535f, d893266a
Parents:
0a2168f
git-author:
Peter A. Buhr <pabuhr@…> (03/04/18 10:35:22)
git-committer:
Peter A. Buhr <pabuhr@…> (03/04/18 12:20:36)
Message:

updates, and extend section on user literals

Location:
src/tests
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/tests/.expect/literals.x64.txt

    r0a2168f rea46db7  
    522522signed int __main__Fi___1(){
    523523    __attribute__ ((unused)) signed int ___retval_main__i_1;
     524    ((void)0b01101011);
     525    ((void)0b01101011u);
     526    ((void)0b01101011l);
     527    ((void)0b01101011ll);
     528    ((void)0b01101011ul);
     529    ((void)0b01101011lu);
     530    ((void)0b01101011ull);
     531    ((void)0b01101011llu);
     532    ((void)(+0b01101011));
     533    ((void)(+0b01101011u));
     534    ((void)(+0b01101011l));
     535    ((void)(+0b01101011ll));
     536    ((void)(+0b01101011ul));
     537    ((void)(+0b01101011lu));
     538    ((void)(+0b01101011ull));
     539    ((void)(+0b01101011llu));
     540    ((void)(-0b01101011));
     541    ((void)(-0b01101011u));
     542    ((void)(-0b01101011l));
     543    ((void)(-0b01101011ll));
     544    ((void)(-0b01101011ul));
     545    ((void)(-0b01101011lu));
     546    ((void)(-0b01101011ull));
     547    ((void)(-0b01101011llu));
    524548    ((void)01234567);
    525549    ((void)01234567u);
     
    10171041    ((void)(-0X0123456789.0123456789P-09F));
    10181042    ((void)(-0X0123456789.0123456789P-09L));
     1043    ((void)((signed char )0b01101011));
     1044    ((void)((signed short int )0b01101011));
     1045    ((void)((signed int )0b01101011));
     1046    ((void)((signed long int )0b01101011));
     1047    ((void)((__int128 )0b01101011));
     1048    ((void)((unsigned char )0b01101011u));
     1049    ((void)((signed short int )0b01101011u));
     1050    ((void)((unsigned int )0b01101011u));
     1051    ((void)((signed long int )0b01101011u));
     1052    ((void)((__int128 )0b01101011u));
     1053    ((void)(+((signed int )((signed char )0b01101011))));
     1054    ((void)(+((signed int )((signed short int )0b01101011))));
     1055    ((void)(+((signed int )0b01101011)));
     1056    ((void)(+((signed long int )0b01101011)));
     1057    ((void)(+((float )((__int128 )0b01101011))));
     1058    ((void)(+((signed int )((unsigned char )0b01101011u))));
     1059    ((void)(+((signed int )((signed short int )0b01101011u))));
     1060    ((void)(+((unsigned int )0b01101011u)));
     1061    ((void)(+((signed long int )0b01101011u)));
     1062    ((void)(+((float )((__int128 )0b01101011u))));
     1063    ((void)(-((signed int )((signed char )0b01101011))));
     1064    ((void)(-((signed int )((signed short int )0b01101011))));
     1065    ((void)(-((signed int )0b01101011)));
     1066    ((void)(-((signed long int )0b01101011)));
     1067    ((void)(-((float )((__int128 )0b01101011))));
     1068    ((void)(-((signed int )((unsigned char )0b01101011u))));
     1069    ((void)(-((signed int )((signed short int )0b01101011u))));
     1070    ((void)(-((unsigned int )0b01101011u)));
     1071    ((void)(-((signed long int )0b01101011u)));
     1072    ((void)(-((float )((__int128 )0b01101011u))));
    10191073    ((void)((signed char )01234567));
    10201074    ((void)((signed short int )01234567));
  • src/tests/.expect/user_literals.txt

    r0a2168f rea46db7  
    1111.0714285714286
    2 11.07225
     215
    3311.0714285714286
     424.8
     511.248
    4611.0714285714286
    5 11.0714285714286
    6 22.0457142857143
     728.0657142857143
    78secs 1
    89secs 23
  • src/tests/literals.c

    r0a2168f rea46db7  
    1010// Created On       : Sat Sep  9 16:34:38 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Sep 25 20:26:00 2017
    13 // Update Count     : 132
     12// Last Modified On : Sun Mar  4 10:41:31 2018
     13// Update Count     : 134
    1414//
    1515
     
    3131// integer literals
    3232
     33        // binary
     34         0b01101011;   0b01101011u;   0b01101011l;   0b01101011ll;   0b01101011ul;   0b01101011lu;   0b01101011ull;   0b01101011llu;
     35        +0b01101011;  +0b01101011u;  +0b01101011l;  +0b01101011ll;  +0b01101011ul;  +0b01101011lu;  +0b01101011ull;  +0b01101011llu;
     36        -0b01101011;  -0b01101011u;  -0b01101011l;  -0b01101011ll;  -0b01101011ul;  -0b01101011lu;  -0b01101011ull;  -0b01101011llu;
     37
    3338        // octal
    3439         01234567;   01234567u;   01234567l;   01234567ll;   01234567ul;   01234567lu;   01234567ull;   01234567llu;
     
    148153#ifdef __CFA__
    149154// fixed-size length
     155
     156        // binary
     157         0b01101011_l8;   0b01101011_l16;   0b01101011_l32;   0b01101011_l64;   0b01101011_l128;   0b01101011_l8u;   0b01101011_ul16;   0b01101011_l32u;   0b01101011_ul64;   0b01101011_ul128;
     158        +0b01101011_l8;  +0b01101011_l16;  +0b01101011_l32;  +0b01101011_l64;  +0b01101011_l128;  +0b01101011_l8u;  +0b01101011_ul16;  +0b01101011_l32u;  +0b01101011_ul64;  +0b01101011_ul128;
     159        -0b01101011_l8;  -0b01101011_l16;  -0b01101011_l32;  -0b01101011_l64;  -0b01101011_l128;  -0b01101011_l8u;  -0b01101011_ul16;  -0b01101011_l32u;  -0b01101011_ul64;  -0b01101011_ul128;
    150160
    151161        // octal
  • src/tests/user_literals.c

    r0a2168f rea46db7  
    1010// Created On       : Wed Sep  6 21:40:50 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Dec  7 09:12:36 2017
    13 // Update Count     : 50
     12// Last Modified On : Sun Mar  4 11:14:02 2018
     13// Update Count     : 52
    1414//
    1515
     
    3131
    3232
    33 struct Weight {
    34         double stones;
    35 };
    36 void ?{}( Weight & w ) { w.stones = 0; }                                // operations
     33struct Weight { double stones; };
     34void ?{}( Weight & w ) { w.stones = 0; }
    3735void ?{}( Weight & w, double w ) { w.stones = w; }
    38 Weight ?+?( Weight l, Weight r ) { return (Weight){ l.stones + r.stones }; }
     36Weight ?+?( Weight l, Weight r ) {
     37        return (Weight){ l.stones + r.stones };
     38}
    3939ofstream & ?|?( ofstream & os, Weight w ) { return os | w.stones; }
    4040
    4141Weight ?`st( double w ) { return (Weight){ w }; }               // backquote for user literals
    4242Weight ?`lb( double w ) { return (Weight){ w / 14.0 }; }
    43 Weight ?`kg( double w ) { return (Weight) { w * 0.1575}; }
    44 
     43Weight ?`kg( double w ) { return (Weight) { w * 0.16 }; }
    4544
    4645int main() {
    47         Weight w, hw = { 14 };                                                          // 14 stone
    48         w = 11`st + 1`lb;
     46        Weight w, heavy = { 20 };                                                       // 20 stone
     47        w = 155`lb;
     48        sout | w | endl;
     49        w = 0b_1111`st;
     50        sout | w | endl;
     51        w = 0_233`lb;                                                                           // octal weight (155)
     52        sout | w | endl;
     53        w = 0x_9b_u`kg;
    4954        sout | w | endl;
    5055        w = 70.3`kg;
    5156        sout | w | endl;
    52         w = 155`lb;
     57        w = 11`st + 1`lb;
    5358        sout | w | endl;
    54         w = 0x_9b_u`lb;                                                                         // hexadecimal unsigned weight (155)
    55         sout | w | endl;
    56         w = 0_233`lb;                                                                           // octal weight (155)
    57         sout | w | endl;
    58         w = 5`st + 8`kg + 25`lb + hw;
     59        w = 5`st + 8`kg + 25`lb + heavy;
    5960        sout | w | endl;
    6061
Note: See TracChangeset for help on using the changeset viewer.