[libsigcplusplus] tests: Use the sigc::slot<R(Args...)> syntax only.



commit b757954a449b2618da1248e16cd43c72b14dc4ff
Author: Murray Cumming <murrayc murrayc com>
Date:   Wed Mar 16 10:42:04 2016 +0100

    tests: Use the sigc::slot<R(Args...)> syntax only.

 tests/test_bind.cc              |    2 +-
 tests/test_bind_as_slot.cc      |    6 +++---
 tests/test_bind_ref.cc          |    2 +-
 tests/test_bind_return.cc       |    2 +-
 tests/test_copy_invalid_slot.cc |    4 ++--
 tests/test_cpp11_lambda.cc      |    4 ++--
 tests/test_disconnect.cc        |    4 ++--
 tests/test_limit_reference.cc   |    6 +++---
 tests/test_retype.cc            |   20 +++++---------------
 tests/test_retype_return.cc     |    2 +-
 tests/test_size.cc              |    2 +-
 tests/test_slot.cc              |   25 ++++++-------------------
 tests/test_slot_disconnect.cc   |    4 ++--
 tests/test_slot_move.cc         |    6 +++---
 tests/test_track_obj.cc         |    8 ++++----
 tests/test_trackable.cc         |    2 +-
 tests/test_trackable_move.cc    |    2 +-
 tests/test_visit_each.cc        |    2 +-
 18 files changed, 40 insertions(+), 63 deletions(-)
---
diff --git a/tests/test_bind.cc b/tests/test_bind.cc
index b0f356e..94e2f61 100644
--- a/tests/test_bind.cc
+++ b/tests/test_bind.cc
@@ -147,7 +147,7 @@ int main(int argc, char* argv[])
   result_stream << " " << str; // (This cannot be the default behaviour: just think about what happens if 
str dies!)
   util->check_result(result_stream, "egon(string 'guest book') egon was here");
 
-  sigc::slot<void> sl;
+  sigc::slot<void()> sl;
   {
     book guest_book("karl");
     sl = sigc::bind(&egon, std::ref(guest_book));
diff --git a/tests/test_bind_as_slot.cc b/tests/test_bind_as_slot.cc
index 28bcf4f..763e48f 100644
--- a/tests/test_bind_as_slot.cc
+++ b/tests/test_bind_as_slot.cc
@@ -46,7 +46,7 @@ int main(int argc, char* argv[])
 
   //Test that sigc::bind()'s result can be converted to a sigc::slot<>.
   {
-    sigc::slot<bool, int> bound_slot = sigc::bind(sigc::ptr_fun(&func_to_bind), 2);
+    sigc::slot<bool(int)> bound_slot = sigc::bind(sigc::ptr_fun(&func_to_bind), 2);
     bound_slot(1);
     util->check_result(result_stream, "func_to_bind(1, 2)");
   }
@@ -54,7 +54,7 @@ int main(int argc, char* argv[])
   //Test with a non-const iterator:
   {
     std::string c = "2";
-    sigc::slot<bool, int> bound_slot = sigc::bind(sigc::ptr_fun(&func_to_bind_with_iter), c.begin());
+    sigc::slot<bool(int)> bound_slot = sigc::bind(sigc::ptr_fun(&func_to_bind_with_iter), c.begin());
     bound_slot(1);
     util->check_result(result_stream, "func_to_bind_with_iter(1, 2)");
   }
@@ -62,7 +62,7 @@ int main(int argc, char* argv[])
   //Test with a const_iterator:
   {
     const std::string c = "2";
-    sigc::slot<bool, int> bound_slot = sigc::bind(sigc::ptr_fun(&func_to_bind_with_const_iter), c.begin());
+    sigc::slot<bool(int)> bound_slot = sigc::bind(sigc::ptr_fun(&func_to_bind_with_const_iter), c.begin());
     bound_slot(1);
     util->check_result(result_stream, "func_to_bind_with_const_iter(1, 2)");
   }
diff --git a/tests/test_bind_ref.cc b/tests/test_bind_ref.cc
index f3e11c6..d1e02c6 100644
--- a/tests/test_bind_ref.cc
+++ b/tests/test_bind_ref.cc
@@ -43,7 +43,7 @@ int main(int argc, char* argv[])
     return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 
   auto slot_full = sigc::ptr_fun(&handler);
-  sigc::slot<void> slot_bound;
+  sigc::slot<void()> slot_bound;
 
   slot_bound();
   util->check_result(result_stream, "");
diff --git a/tests/test_bind_return.cc b/tests/test_bind_return.cc
index 232f402..737e96b 100644
--- a/tests/test_bind_return.cc
+++ b/tests/test_bind_return.cc
@@ -65,7 +65,7 @@ int main(int argc, char* argv[])
   // long as there exists a default constructor for it.
   //
   // Therefore, we use 'bar', and not 'bar&' for this slot signature.
-  sigc::slot<bar, int> sl;
+  sigc::slot<bar(int)> sl;
   {
     bar choco(-1);
     sl = sigc::bind_return(foo(), std::ref(choco));
diff --git a/tests/test_copy_invalid_slot.cc b/tests/test_copy_invalid_slot.cc
index a6179c3..4dcb6d6 100644
--- a/tests/test_copy_invalid_slot.cc
+++ b/tests/test_copy_invalid_slot.cc
@@ -31,7 +31,7 @@ int main(int argc, char* argv[])
   util->check_result(result_stream, "sigc::trackable instance at " + pointer_stream.str());
   pointer_stream.str("");
 
-  sigc::slot<void> foo = sigc::bind(sigc::ptr_fun(Foo), std::ref(*t));
+  sigc::slot<void()> foo = sigc::bind(sigc::ptr_fun(Foo), std::ref(*t));
   foo();
   util->check_result(result_stream, "Foo(x)");
 
@@ -56,7 +56,7 @@ int main(int argc, char* argv[])
   // Now copy foo: up to libsigc++ version 2.0.11, the copy constructor fails
   // because the pointer value it dereferences does not point to a
   // sigc::trackable anymore, it now points to a polluted buffer.
-  sigc::slot<void> bar = foo;
+  sigc::slot<void()> bar = foo;
   bar();
   util->check_result(result_stream, "");
 
diff --git a/tests/test_cpp11_lambda.cc b/tests/test_cpp11_lambda.cc
index a927884..8d62536 100644
--- a/tests/test_cpp11_lambda.cc
+++ b/tests/test_cpp11_lambda.cc
@@ -265,7 +265,7 @@ int main(int argc, char* argv[])
   // If you want to auto-disconnect a slot with a C++11 lambda expression
   // that contains references to sigc::trackable-derived objects, you must use
   // sigc::track_obj().
-  sigc::slot<void, std::ostringstream&> sl1;
+  sigc::slot<void(std::ostringstream&)> sl1;
   {
     book guest_book("karl");
     //sl1 = (sigc::var(std::cout) << std::ref(guest_book) << sigc::var("\n"));
@@ -316,7 +316,7 @@ int main(int argc, char* argv[])
   // functor has an unambiguous operator()().
 
   // auto-disconnect
-  sigc::slot<void> sl2;
+  sigc::slot<void()> sl2;
   {
     book guest_book("karl");
     //sl2 = sigc::group(&egon, std::ref(guest_book));
diff --git a/tests/test_disconnect.cc b/tests/test_disconnect.cc
index c1ddf3b..7069a4d 100644
--- a/tests/test_disconnect.cc
+++ b/tests/test_disconnect.cc
@@ -139,7 +139,7 @@ int main(int argc, char* argv[])
 
   { // A slot# within a slot
     A a2;
-    sigc::slot<int, int> setter = sigc::mem_fun(a2, &A::foo);
+    sigc::slot<int(int)> setter = sigc::mem_fun(a2, &A::foo);
     sig.connect(sigc::compose(setter, &foo));
     result_stream << "sig is connected to compose(slot1(A::foo), foo) (size=" << sig.size() << "): ";
     sig(9);
@@ -151,7 +151,7 @@ int main(int argc, char* argv[])
 
   { // A slot within a slot
     A a2;
-    sigc::slot<int, int> setter = sigc::mem_fun(a2, &A::foo);
+    sigc::slot<int(int)> setter = sigc::mem_fun(a2, &A::foo);
     sig.connect(sigc::compose(setter, &foo));
     result_stream << "sig is connected to compose(slot(A::foo), foo) (size=" << sig.size() << "): ";
     sig(11);
diff --git a/tests/test_limit_reference.cc b/tests/test_limit_reference.cc
index ea1edcd..33d019b 100644
--- a/tests/test_limit_reference.cc
+++ b/tests/test_limit_reference.cc
@@ -41,17 +41,17 @@ int main(int argc, char* argv[])
     return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 
   auto instance = new Derived();
-  sigc::slot<void> handler = sigc::mem_fun(*instance, &Derived::method);
+  sigc::slot<void()> handler = sigc::mem_fun(*instance, &Derived::method);
   handler();
   util->check_result(result_stream, "method()");
 
   auto param =
-    sigc::bind(sigc::slot<void, Derived&>(), std::ref(*instance));
+    sigc::bind(sigc::slot<void(Derived&)>(), std::ref(*instance));
   param();
   util->check_result(result_stream, "");
 
   auto ret =
-    sigc::bind_return(sigc::slot<void>(), std::ref(*instance));
+    sigc::bind_return(sigc::slot<void()>(), std::ref(*instance));
   ret();
   util->check_result(result_stream, "");
 
diff --git a/tests/test_retype.cc b/tests/test_retype.cc
index 95de57c..1dbb785 100644
--- a/tests/test_retype.cc
+++ b/tests/test_retype.cc
@@ -57,7 +57,7 @@ void test_ptr_fun()
 void test_member_int_with_slot()
 {
   foo foo_;
-  sigc::slot<float,float> s1 = sigc::retype(sigc::mem_fun(foo_, &foo::test_int));
+  sigc::slot<float(float)> s1 = sigc::retype(sigc::mem_fun(foo_, &foo::test_int));
   result_stream << s1(1.234f);
   util->check_result(result_stream, "foo::test_int(int 1) 1.5");
 }
@@ -65,14 +65,14 @@ void test_member_int_with_slot()
 void test_member_float_with_slot()
 {
   foo foo_;
-  sigc::slot<float,int> s2 = sigc::retype(sigc::mem_fun(foo_, &foo::test_float));
+  sigc::slot<float(int)> s2 = sigc::retype(sigc::mem_fun(foo_, &foo::test_float));
   result_stream << s2(5);
   util->check_result(result_stream, "foo::test_float(float 5) 25");
 }
 
 void test_ptr_fun_with_slot()
 {
-  sigc::slot<void,double> s3 = sigc::retype(sigc::ptr_fun(&bar));
+  sigc::slot<void(double)> s3 = sigc::retype(sigc::ptr_fun(&bar));
   s3(6.789);
   util->check_result(result_stream, "bar(short 6)");
 }
@@ -80,20 +80,12 @@ void test_ptr_fun_with_slot()
 void test_retype_slot()
 {
   foo foo_;
-  sigc::slot<float,float> s1 = sigc::retype(sigc::mem_fun(foo_, &foo::test_int));
-  sigc::slot<float,int> s2 = sigc::retype(s1);
+  sigc::slot<float(float)> s1 = sigc::retype(sigc::mem_fun(foo_, &foo::test_int));
+  sigc::slot<float(int)> s2 = sigc::retype(s1);
   result_stream << s2(5);
   util->check_result(result_stream, "foo::test_int(int 5) 7.5");
 }
 
-void test_std_function_style_syntax()
-{
-  foo foo_;
-  sigc::slot<float(float)> s1 = sigc::retype(sigc::mem_fun(foo_, &foo::test_int));
-  result_stream << s1(1.234f);
-  util->check_result(result_stream, "foo::test_int(int 1) 1.5");
-}
-
 } // end anonymous namespace
 
 int main(int argc, char* argv[])
@@ -113,7 +105,5 @@ int main(int argc, char* argv[])
 
   test_retype_slot();
 
-  test_std_function_style_syntax();
-
   return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/test_retype_return.cc b/tests/test_retype_return.cc
index 3c83ed2..2d02cac 100644
--- a/tests/test_retype_return.cc
+++ b/tests/test_retype_return.cc
@@ -55,7 +55,7 @@ int main(int argc, char* argv[])
   util->check_result(result_stream, "foo(float 1.234) 6");
 
   // retype_return<void> / hide_return
-  sigc::slot<void, int> sl;
+  sigc::slot<void(int)> sl;
   sl = sigc::retype_return<void>(bar());
   sl(5);
   util->check_result(result_stream, "bar(int 5)");
diff --git a/tests/test_size.cc b/tests/test_size.cc
index 5931f9f..9aeecb0 100644
--- a/tests/test_size.cc
+++ b/tests/test_size.cc
@@ -33,7 +33,7 @@ int main(int argc, char* argv[])
     std::cout << "sizes of public classes:" << std::endl;
 
     std::cout << "  trackable:               " << sizeof(sigc::trackable) << std::endl;
-    std::cout << "  slot<void>:              " << sizeof(sigc::slot<void>) << std::endl;
+    std::cout << "  slot<void()>:              " << sizeof(sigc::slot<void()>) << std::endl;
     std::cout << "  signal<void()>:            " << sizeof(sigc::signal<void()>) << std::endl;
     std::cout << "  signal<void()>::iterator:  " << sizeof(sigc::signal<void()>::iterator) << std::endl;
     std::cout << "  connection:              " << sizeof(sigc::connection) << std::endl;
diff --git a/tests/test_slot.cc b/tests/test_slot.cc
index 40e55dc..d9a5385 100644
--- a/tests/test_slot.cc
+++ b/tests/test_slot.cc
@@ -41,18 +41,6 @@ public:
 void test_simple()
 {
   // simple test
-  sigc::slot<void,int> s1 = foo();
-  s1(1);
-  util->check_result(result_stream, "foo(int 1)");
-
-  s1 = foo();
-  s1(2);
-  util->check_result(result_stream, "foo(int 2)");
-}
-
-void test_std_function_style_syntax()
-{
-  // simple test
   sigc::slot<void(int)> s1 = foo();
   s1(1);
   util->check_result(result_stream, "foo(int 1)");
@@ -65,7 +53,7 @@ void test_std_function_style_syntax()
 void test_implicit_conversion()
 {
   // test implicit conversion
-  sigc::slot<void,char> s2 = foo();
+  sigc::slot<void(char)> s2 = foo();
   s2(3);
   util->check_result(result_stream, "foo(int 3)");
 }
@@ -73,7 +61,7 @@ void test_implicit_conversion()
 void test_reference()
 {
   // test reference
-  sigc::slot<void,std::string&> sl1 = foo();
+  sigc::slot<void(std::string&)> sl1 = foo();
   std::string str("guest book");
   sl1(str);
   result_stream << str;
@@ -84,8 +72,8 @@ void test_operator_equals()
 {
   // test operator=
   std::string str = "guest book";
-  sigc::slot<void,std::string&> sl1 = foo();
-  sigc::slot<void,std::string&> sl2;
+  sigc::slot<void(std::string&)> sl1 = foo();
+  sigc::slot<void(std::string&)> sl2;
   sl2 = sl1;
   sl1 = sl2;
   sl1(str);
@@ -96,8 +84,8 @@ void test_operator_equals()
 void test_copy_ctor()
 {
   // test copy ctor
-  sigc::slot<void,int> s1 = foo();
-  sigc::slot<void,int> s1_clone(s1);
+  sigc::slot<void(int)> s1 = foo();
+  sigc::slot<void(int)> s1_clone(s1);
   s1_clone(4);
   util->check_result(result_stream, "foo(int 4)");
 }
@@ -112,7 +100,6 @@ int main(int argc, char* argv[])
     return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 
   test_simple();
-  test_std_function_style_syntax();
   test_implicit_conversion();
   test_reference();
   test_operator_equals();
diff --git a/tests/test_slot_disconnect.cc b/tests/test_slot_disconnect.cc
index 232066b..12171a6 100644
--- a/tests/test_slot_disconnect.cc
+++ b/tests/test_slot_disconnect.cc
@@ -32,7 +32,7 @@ int main(int argc, char* argv[])
     return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 
   //Note that sigc::ptr_fun() creates a sig::pointer_functor.
-  sigc::slot<void> theSlot(sigc::ptr_fun(&Foo));
+  sigc::slot<void()> theSlot(sigc::ptr_fun(&Foo));
   theSlot();
   util->check_result(result_stream, "Foo");
 
@@ -44,7 +44,7 @@ int main(int argc, char* argv[])
   theSlot();
   util->check_result(result_stream, "Bar");
 
-  theSlot = sigc::slot<void>(); // Assign an empty slot.
+  theSlot = sigc::slot<void()>(); // Assign an empty slot.
   theSlot();
   util->check_result(result_stream, "");
 
diff --git a/tests/test_slot_move.cc b/tests/test_slot_move.cc
index 06975f5..b35853f 100644
--- a/tests/test_slot_move.cc
+++ b/tests/test_slot_move.cc
@@ -46,18 +46,18 @@ int main(int argc, char* argv[])
     return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 
   // simple test
-  sigc::slot<void,int> s1 = foo();
+  sigc::slot<void(int)> s1 = foo();
   s1(1);
   util->check_result(result_stream, "foo(int 1)");
 
   // test move constructor:
-  sigc::slot<void,int> s2(std::move(s1));
+  sigc::slot<void(int)> s2(std::move(s1));
   s1(-2);
   s2(2);
   util->check_result(result_stream, "foo(int 2)");
 
   // test move assignment:
-  sigc::slot<void,int> s3;
+  sigc::slot<void(int)> s3;
   s3 = std::move(s2);
   s2(-3);
   s3(3);
diff --git a/tests/test_track_obj.cc b/tests/test_track_obj.cc
index a2a0019..e305062 100644
--- a/tests/test_track_obj.cc
+++ b/tests/test_track_obj.cc
@@ -126,7 +126,7 @@ int main(int argc, char* argv[])
   if (!util->check_command_args(argc, argv))
     return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 
-  sigc::slot<std::string, int> sl1;
+  sigc::slot<std::string(int)> sl1;
   {
     bar_group4 bar4;
     sl1 = sigc::track_obj(Functor1(bar4), bar4);
@@ -140,7 +140,7 @@ int main(int argc, char* argv[])
 
   // Allocate on the heap. valgrind can then find erroneous memory accesses.
   // (There should be none, of course.)
-  auto psl2 = new sigc::slot<std::string, int, std::string>;
+  auto psl2 = new sigc::slot<std::string(int, std::string)>;
   bar_group4* pbar4 = new bar_group4;
   book* pbook4 = new book("A Book");
   *psl2 = sigc::track_obj(Functor2(*pbar4, *pbook4), *pbar4, *pbook4);
@@ -163,7 +163,7 @@ int main(int argc, char* argv[])
   // If you want to auto-disconnect a slot with a C++11 lambda expression
   // that contains references to sigc::trackable-derived objects, you must use
   // sigc::track_obj().
-  sigc::slot<void, std::ostringstream&> sl10;
+  sigc::slot<void(std::ostringstream&)> sl10;
   {
     book guest_book("karl");
     // sl1 = [&guest_book](std::ostringstream& stream){ stream << guest_book << "\n"; }; // no 
auto-disconnect
@@ -177,7 +177,7 @@ int main(int argc, char* argv[])
   util->check_result(result_stream, "");
 
   // auto-disconnect
-  sigc::slot<void> sl20;
+  sigc::slot<void()> sl20;
   {
     book guest_book("karl");
     // sl2 = [&guest_book] () { egon(guest_book); }; // no auto-disconnect
diff --git a/tests/test_trackable.cc b/tests/test_trackable.cc
index 6677c43..daba58b 100644
--- a/tests/test_trackable.cc
+++ b/tests/test_trackable.cc
@@ -34,7 +34,7 @@ int main(int argc, char* argv[])
   if (!util->check_command_args(argc, argv))
     return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 
-  sigc::slot<void> sl;
+  sigc::slot<void()> sl;
   {
     my_class t;
     t.i = 10;
diff --git a/tests/test_trackable_move.cc b/tests/test_trackable_move.cc
index d42b9c3..664f769 100644
--- a/tests/test_trackable_move.cc
+++ b/tests/test_trackable_move.cc
@@ -57,7 +57,7 @@ int main(int argc, char* argv[])
   if (!util->check_command_args(argc, argv))
     return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 
-  sigc::slot<void> sl;
+  sigc::slot<void()> sl;
   {
     my_class t;
     t.i = 10;
diff --git a/tests/test_visit_each.cc b/tests/test_visit_each.cc
index 4c508b6..bd76765 100644
--- a/tests/test_visit_each.cc
+++ b/tests/test_visit_each.cc
@@ -160,7 +160,7 @@ int main(int argc, char* argv[])
   if (!util->check_command_args(argc, argv))
     return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;
 
-  sigc::slot<void, int> sl1;
+  sigc::slot<void(int)> sl1;
 
   {
     MyClass1 my_class1("x=");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]