$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: gpderetta_at_[hidden]
Date: 2008-04-11 11:57:24
Author: giovanni.deretta
Date: 2008-04-11 11:57:23 EDT (Fri, 11 Apr 2008)
New Revision: 44180
URL: http://svn.boost.org/trac/boost/changeset/44180
Log:
test continuation class
Added:
   sandbox/SOC/2006/coroutine/branches/cleanup/libs/coroutine/test/test_continuation.cpp   (contents, props changed)
Text files modified: 
   sandbox/SOC/2006/coroutine/branches/cleanup/libs/coroutine/test/Jamfile.v2 |     3 ++-                                     
   1 files changed, 2 insertions(+), 1 deletions(-)
Modified: sandbox/SOC/2006/coroutine/branches/cleanup/libs/coroutine/test/Jamfile.v2
==============================================================================
--- sandbox/SOC/2006/coroutine/branches/cleanup/libs/coroutine/test/Jamfile.v2	(original)
+++ sandbox/SOC/2006/coroutine/branches/cleanup/libs/coroutine/test/Jamfile.v2	2008-04-11 11:57:23 EDT (Fri, 11 Apr 2008)
@@ -40,7 +40,7 @@
 
 project
     : requirements
-      	<library>/boost/test//boost_unit_test_framework
+      	# <library>/boost/test//boost_unit_test_framework
               <library>../build//boost_coroutine
               <link>static
         <define>"_WIN32_WINNT=0x0400" #$(TARGET_SPECIFIC_DEFINE)
@@ -63,5 +63,6 @@
       [ run test_non_default_constructible.cpp ]
       [ run test_reference.cpp ]
       [ run test_generator.cpp ]
+      [ run test_continuation.cpp ]
    ;
 
Added: sandbox/SOC/2006/coroutine/branches/cleanup/libs/coroutine/test/test_continuation.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2006/coroutine/branches/cleanup/libs/coroutine/test/test_continuation.cpp	2008-04-11 11:57:23 EDT (Fri, 11 Apr 2008)
@@ -0,0 +1,69 @@
+//  Copyright (c) 2006, Giovanni P. Deretta
+//
+//  Distributed under the Boost Software License, Version 1.0.
+//  (See accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+
+#include <iostream>
+#include <boost/coroutine/detail/context_linux.hpp>
+#include <boost/coroutine/continuation.hpp>
+//#include <boost/test/unit_test.hpp>
+
+namespace coro = boost::coroutines; 
+
+typedef coro::continuation_tpl<coro::detail::oslinux::ia32_gcc_context_interface> continuation;
+
+continuation f(continuation x) {
+  std::cerr << "**** in f (1)"<<std::endl;
+  x = x();
+  std::cerr << "**** in f (2)"<<std::endl;
+  x = x();
+  std::cerr << "**** in f (3)"<<std::endl;
+  return move(x);
+}
+
+struct g {
+  g(int n_) : n(n_){}
+  continuation operator()(continuation x) {
+    for(int i = 0; i != n; ++i) {
+      std::cerr << "**** in g ("<<i<<')'<<std::endl;
+      x = x();
+    }
+    return f(move(x));
+  }
+  int n;
+};
+
+
+void test_continuation() {
+  std::cerr << "**** in main (1)"<<std::endl;
+  continuation c = coro::callcc1(f);
+  std::cerr << "**** in main (2)"<<std::endl;
+  c = c();
+  std::cerr << "**** in main (3)"<<std::endl;
+  c = c();
+  std::cerr << "**** in main (4)"<<std::endl;
+  continuation c2 = coro::callcc1(g(10));
+  int j = 0;
+  while(!c2.fired()) {
+    std::cerr << "**** in main ("<<j<<')'<<std::endl;
+    j++;
+    c2 = c2();
+  }
+}
+
+int main() {
+  test_continuation();
+  return -1;
+}
+
+
+// boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] )
+// {
+//   std::cout << "starting test" <<std::endl;
+//     boost::unit_test::test_suite *test = BOOST_TEST_SUITE("continuation test");
+
+//     test->add(BOOST_TEST_CASE(&test_continuation));
+
+//     return test;
+// }