From 3a7db1603e3736e6ecb9927de76ca6b9cf61c91c Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Mon, 28 May 2012 03:42:15 +0200 Subject: [PATCH] add test for the base case --- tests/lib/iter-explorer-test.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/lib/iter-explorer-test.cpp b/tests/lib/iter-explorer-test.cpp index 71e0f5ffc..3a5edfcca 100644 --- a/tests/lib/iter-explorer-test.cpp +++ b/tests/lib/iter-explorer-test.cpp @@ -34,6 +34,7 @@ //#include #include #include +#include @@ -49,6 +50,7 @@ namespace test{ // using std::vector; // using std::cout; // using std::endl; + using std::string; using lib::LinkedElements; using lumiera::error::LUMIERA_ERROR_ITER_EXHAUST; @@ -191,6 +193,7 @@ namespace test{ { verifyStateAdapter(); + verifyMonadOperator (); UNIMPLEMENTED ("IterExplorer Monad"); verifyChainedIterators(); verifyRawChainedIterators(); @@ -428,6 +431,35 @@ namespace test{ } + + /** @test cover the basic monad bind operator, + * which is used to build all the specialised Iterator flavours. + * The default implementation ("Combinator strategy") uses heap allocations + * to keep track of the intermediary results. (Of course this can be changed) + */ + void + verifyMonadOperator () + { + typedef IterExplorer > SrcSequence; + +#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #892 + SrcSequence src = exploreIter(seq(5)); + + string result = materialise(src >>= explode); + CHECK (result == "0-0-1-0-1-2-0-1-2-3"); + + result = materialise(src >>= explode >>= explode); + CHECK (result == "0-0-0-1-0-0-1-0-1-2"); +#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #892 + } + + static NumberSequence + explode (uint top) + { + return seq(0,top); + } + + }; LAUNCHER (IterExplorer_test, "unit common");