From 2f3a18e49b04bed6f25b9cf7ae6ca7228519df6c Mon Sep 17 00:00:00 2001 From: Matevz Jekovec Date: Tue, 11 Aug 2009 19:44:03 +0000 Subject: [PATCH] Added cpp0x_result_of testcase. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@11534 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 3 ++- Examples/test-suite/cpp0x_result_of.i | 19 +++++++++++++++++++ .../python/cpp0x_result_of_runme.py | 3 +++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 Examples/test-suite/cpp0x_result_of.i create mode 100644 Examples/test-suite/python/cpp0x_result_of_runme.py diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index aa569bdea..8415197f4 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -412,7 +412,8 @@ CPP0X_TEST_CASES = \ cpp0x_variadic_templates \ cpp0x_alternate_function_syntax \ cpp0x_userdefined_literals \ - cpp0x_decltype + cpp0x_decltype \ + cpp0x_result_of # cpp0x_template_typedefs # not supported by any compiler yet # cpp0x_hash_types # not fully implemented yet # cpp0x_constructors # not supported by any compiler yet diff --git a/Examples/test-suite/cpp0x_result_of.i b/Examples/test-suite/cpp0x_result_of.i new file mode 100644 index 000000000..fb8586ba7 --- /dev/null +++ b/Examples/test-suite/cpp0x_result_of.i @@ -0,0 +1,19 @@ +/* This testcase checks whether Swig correctly uses the new result_of class + and its templating capabilities introduced in C++0x. */ +%module cpp0x_result_of + +%inline %{ +#include +#include + +double square(double x) { + return (x * x); +} + +template +typename std::result_of::type test_result_impl(Fun fun, Arg arg) { + return fun(arg); +} +%} + +%template(test_result) test_result_impl; diff --git a/Examples/test-suite/python/cpp0x_result_of_runme.py b/Examples/test-suite/python/cpp0x_result_of_runme.py new file mode 100644 index 000000000..5411cd1ce --- /dev/null +++ b/Examples/test-suite/python/cpp0x_result_of_runme.py @@ -0,0 +1,3 @@ +import cpp0x_result_of +if cpp0x_result_of.test_result(cpp0x_result_of.square, 3.0) != 9.0: + raise RuntimeError, "test_result(square, 3.0) is not 9.0."