Changeset 6e6e372 for tests/zero_one.cfa
- Timestamp:
- Dec 10, 2024, 3:07:06 PM (8 days ago)
- Branches:
- master
- Children:
- ec22220
- Parents:
- 8e4f34e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/zero_one.cfa
r8e4f34e r6e6e372 24 24 25 25 struct S { int i, j; }; 26 void ?{}( S & s, zero_t ) { s.[i,j] = 0; } 26 void ?{}( S & s, zero_t ) { s.[i,j] = 0; } // constructors 27 27 void ?{}( S & s, one_t ) { s.[i,j] = 1; } 28 S ?=?( S & dst, zero_t ) { dst.[i,j] = 0; return dst; } 28 S ?=?( S & dst, zero_t ) { dst.[i,j] = 0; return dst; } // assignment 29 29 S ?=?( S & dst, one_t ) { dst.[i,j] = 1; return dst; } 30 S ?+=?( S & s, one_t ) { s.[i,j] += 1; return s; } // increment30 S ?+=?( S & s, one_t ) { s.[i,j] += 1; return s; } // increment/decrement each field 31 31 S ?-=?( S & s, one_t ) { s.[i,j] -= 1; return s; } 32 32 int ?!=?( S s, zero_t ) { return s.i != 0 && s.j != 0; } // comparison 33 33 void testInitAssignQueryIncrement() { 34 S s = 0; 35 s = 0; 36 37 if ( s ) ++s; 38 34 S s = 0; // initialization 35 s = 0; // assignments 36 s = 1; 37 if ( s ) ++s; // special, unary ++/-\,- come from +=/-= 38 sout | s.i | s.j; 39 39 } 40 40
Note: See TracChangeset
for help on using the changeset viewer.