From f30054523233db2f500496c9bcc5bf4acdcb3b85 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 9 Dec 2017 03:49:59 +0100 Subject: [PATCH] TreeExplorer: investigate wrong behaviour in test turns out that -- again -- we miss some kind of refresh after expanding children. But this case is more tricky; it indicates a design mismatch in IterSource: we (ab)use the pos-pointer to communicate iteration state. While this might be a clever trick for iterating a real container, it is more than dangerous when applied to an opaque source state as in this case. After expanding children, the pos-pointer still points into the cache buffer of the last transformer. In fact, we miss an actualisation call, but the IterSource interface does not support such a call (since it tries to get away with state hidden in the pos pointer) --- tests/library/iter-tree-explorer-test.cpp | 24 +++++++----- wiki/thinkPad.ichthyo.mm | 45 ++++++++++++++++++++++- 2 files changed, 59 insertions(+), 10 deletions(-) diff --git a/tests/library/iter-tree-explorer-test.cpp b/tests/library/iter-tree-explorer-test.cpp index a6c330d8d..984ee2192 100644 --- a/tests/library/iter-tree-explorer-test.cpp +++ b/tests/library/iter-tree-explorer-test.cpp @@ -738,32 +738,38 @@ namespace test{ CHECK (not isnil (sequence)); CHECK (19 == *sequence); - cout << materialise (sequence) < exploreIter; + CHECK (22 == *sequence); + ++sequence; + CHECK (isnil (sequence)); + + + IterExploreSource exploreIter; CHECK (isnil (exploreIter)); - exploreIter = treeExplore(sequence) - .filter([](int i){ return i>30; }) + exploreIter = treeExplore(CountDown{20,10}) + .filter([](uint i){ return i % 2; }) + .transform([](uint i){ return i*2; }) + .filter([](int i){ return i>25; }) .expand([](uint i){ return CountDown{i-10, 20}; }) - .transform([](uint u) -> char { return '@'+u-20; }) +// .transform([](uint u) -> char { return '@'+u-20; }) + .transform([](int u) -> uint { return u; }) .asIterSource(); - CHECK (38 == *sequence); - cout << materialise(exploreIter) << endl; - CHECK (isnil (sequence)); - CHECK (38 == *sequence); // CHECK (38 == *exploreIter); ++exploreIter; exploreIter.expandChildren(); + cout << *exploreIter << endl; cout << materialise(exploreIter) << endl; + cout << *exploreIter << endl; #if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #888 #endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #888 } diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 4cbf4d81f..bc68b64f1 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -6108,9 +6108,45 @@ + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -6252,6 +6288,9 @@ + + + @@ -6586,6 +6625,10 @@ + + + +