- Timestamp:
- Oct 7, 2021, 2:13:46 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
- Children:
- 804bf677
- Parents:
- 0f781fb8
- Location:
- tests/collections
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/collections/.expect/string-ctx-manage.txt
r0f781fb8 r4b3b352 1 hi 2 bye 3 hi 4 bye 1 5 done -
tests/collections/string-ctx-manage.cfa
r0f781fb8 r4b3b352 1 1 #include <string.hfa> 2 2 #include <string_sharectx.hfa> 3 #include <string_res.hfa> 3 4 4 // The functionality for these tests isn't written yet. 5 // But its interface compiles and the cases it drives are detected. 5 void baseline() { 6 string x = "hi"; 6 7 7 void failEagerCopy() { 8 string y = x; // construct y in same context, no write yet => no copy yet 9 assert( y.inner->Handle.s == x.inner->Handle.s); 10 sout | y; // hi 11 12 x = "bye"; 13 y = x; // y in same context, no write yet => no copy yet 14 assert( y.inner->Handle.s == x.inner->Handle.s); 15 sout | y; // bye 16 } 17 18 void eagerCopy() { 8 19 string x = "hi"; 9 string_sharectx c = { N O_SHARING };20 string_sharectx c = { NEW_SHARING }; 10 21 11 // want: implied forced eager copy 12 // got: assertion failure, "need to implement context crossing" 13 string y = x; 22 string y = x; // construct y in different context => eager copy 23 assert( y.inner->Handle.s != x.inner->Handle.s); 24 sout | y; // hi 25 26 x = "bye"; //.... Bookmark 9/30 shallow: surprisingly this step failed 27 y = x; // y was already in different context => eager copy 28 assert( y.inner->Handle.s != x.inner->Handle.s); 29 sout | y; // bye 14 30 } 15 31 … … 26 42 27 43 int main() { 44 baseline(); 45 eagerCopy(); 28 46 if (showFail) { 29 failEagerCopy();30 47 failSoloAlloc(); 31 48 }
Note: See TracChangeset
for help on using the changeset viewer.