sort out c++0x lambda tests and reorder cpp0x tests

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@12182 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2010-07-24 00:20:11 +00:00
commit 996455b50e
3 changed files with 82 additions and 36 deletions

View file

@ -430,33 +430,34 @@ CPP_TEST_CASES += \
# C++0x test cases.
CPP0X_TEST_CASES = \
cpp0x_template_double_brackets \
cpp0x_alternate_function_syntax \
cpp0x_constexpr \
cpp0x_decltype \
cpp0x_default_delete \
cpp0x_explicit_conversion_operators \
cpp0x_raw_string_literals \
cpp0x_static_assert \
cpp0x_template_explicit \
cpp0x_uniform_initialization \
cpp0x_function_objects \
cpp0x_strongly_typed_enumerations \
cpp0x_initializer_list \
cpp0x_raw_string_literals \
cpp0x_result_of \
cpp0x_rvalue_reference \
cpp0x_rvalue_reference2 \
cpp0x_variadic_templates \
cpp0x_alternate_function_syntax \
cpp0x_userdefined_literals \
cpp0x_decltype \
cpp0x_result_of \
cpp0x_default_delete \
cpp0x_sizeof_object \
cpp0x_initializer_list
# cpp0x_template_typedefs # not supported by any compiler yet
# cpp0x_hash_types # not fully implemented yet
# cpp0x_constructors # not supported by any compiler yet
# cpp0x_lambda_functions # not supported by GCC or MSVC yet
# cpp0x_null_pointer_constant # not supported by any compiler yet
# cpp0x_unrestricted_unions # not supported by any compiler yet
# cpp0x_smart_pointers # not supported by standard library yet
# cpp0x_constexpr # not supported by any compiler yet
# cpp0x_thread_local # not supported by any compiler yet
cpp0x_static_assert \
cpp0x_strongly_typed_enumerations \
cpp0x_template_double_brackets \
cpp0x_template_explicit \
cpp0x_uniform_initialization \
cpp0x_userdefined_literals \
cpp0x_variadic_templates
# cpp0x_constructors \ # not supported by any compiler yet
# cpp0x_hash_tables \ # not fully implemented yet
# cpp0x_lambda_functions \ # not supported by GCC or MSVC yet
# cpp0x_null_pointer_constant \ # not supported by any compiler yet
# cpp0x_smart_pointers \ # not supported by standard library yet
# cpp0x_template_typedefs \ # not supported by any compiler yet
# cpp0x_thread_local \ # not supported by any compiler yet
# cpp0x_unrestricted_unions \ # not supported by any compiler yet
# Broken C++0x test cases.
CPP0X_TEST_BROKEN =

View file

@ -5,30 +5,47 @@
*/
%module cpp0x_lambda_functions
%inline %{
struct A {
/* Defined lambda function with return value. */
auto lambda1 = [](int x, int y) -> int { return x+y; };
#pragma SWIG nowarn=SWIGWARN_LANG_NATIVE_UNIMPL
/* Defined lambda function without return value.
Return value is calculated by compiler, if the function contains a
single statement "return expr;". */
auto lambda2 = [](int x, int y) { return x+y; };
};
%inline %{
/* Defined lambda function with return value. */
auto lambda1 = [](int x, int y) -> int { return x+y; };
/* Defined lambda function without return value.
Return value is calculated by compiler, if the function contains a
single statement "return expr;". */
auto lambda2 = [](int x, int y) { return x+y; };
auto lambda3 = [&](int x, int y) { return x+y; };
auto lambda4 = [=](int x, int y) { return x+y; };
int thing = 0;
auto lambda5 = [=,&thing]() { return thing;};
int runLambda1() {
A myA;
return myA.lambda1(5,6);
return lambda1(5,6);
}
int runLambda2() {
A myA;
return myA.lambda2(5,6);
return lambda2(5,6);
}
int runLambda3() {
return lambda3(5,6);
}
int runLambda4() {
return lambda4(5,6);
}
int runLambda5() {
thing++;
return lambda5();
}
/* Inline defined lambda function. */
int runLambda3() {
int runLambdaInline() {
auto myLambda = [](int x, int y) { return x+y; };
return myLambda(5,6);
}
%}

View file

@ -0,0 +1,28 @@
import cpp0x_lambda_functions.*;
public class cpp0x_lambda_functions_runme {
static {
try {
System.loadLibrary("cpp0x_lambda_functions");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
System.exit(1);
}
}
private static void check(int received, int expected) {
if (expected != received)
throw new RuntimeException("check failed, expected: " + expected + " received: " + received);
}
public static void main(String argv[])
{
check(cpp0x_lambda_functions.runLambda1(), 11);
check(cpp0x_lambda_functions.runLambda2(), 11);
check(cpp0x_lambda_functions.runLambda3(), 11);
check(cpp0x_lambda_functions.runLambda4(), 11);
check(cpp0x_lambda_functions.runLambda5(), 1);
check(cpp0x_lambda_functions.runLambda5(), 2);
}
}