diff options
Diffstat (limited to 'Examples/test-suite/ocaml')
-rw-r--r-- | Examples/test-suite/ocaml/Makefile.in | 28 | ||||
-rw-r--r-- | Examples/test-suite/ocaml/catches_strings_runme.ml | 14 | ||||
-rw-r--r-- | Examples/test-suite/ocaml/director_pass_by_value_runme.ml | 3 | ||||
-rw-r--r-- | Examples/test-suite/ocaml/enum_rename_runme.ml | 10 | ||||
-rw-r--r-- | Examples/test-suite/ocaml/extend_template_method_runme.ml | 20 | ||||
-rw-r--r-- | Examples/test-suite/ocaml/li_std_string_runme.ml | 53 | ||||
-rw-r--r-- | Examples/test-suite/ocaml/mod_runme.ml | 7 | ||||
-rw-r--r-- | Examples/test-suite/ocaml/rename_rstrip_encoder_runme.ml | 7 | ||||
-rw-r--r-- | Examples/test-suite/ocaml/special_variable_macros_runme.ml | 2 | ||||
-rw-r--r-- | Examples/test-suite/ocaml/template_methods_runme.ml | 25 | ||||
-rw-r--r-- | Examples/test-suite/ocaml/typedef_inherit_runme.ml | 3 | ||||
-rw-r--r-- | Examples/test-suite/ocaml/using2_runme.ml | 4 |
12 files changed, 165 insertions, 11 deletions
diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in index 775b1ea71..1863a4d74 100644 --- a/Examples/test-suite/ocaml/Makefile.in +++ b/Examples/test-suite/ocaml/Makefile.in @@ -9,30 +9,33 @@ OCAMLPP = -pp "camlp4o ./swigp4.cmo" VARIANT = _static SCRIPTSUFFIX = _runme.ml +HAVE_CXX11 = @HAVE_CXX11@ +HAVE_CXX14 = @HAVE_CXX14@ +HAVE_CXX17 = @HAVE_CXX17@ +HAVE_CXX20 = @HAVE_CXX20@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ FAILING_CPP_TESTS = \ allprotected \ -apply_signed_char \ apply_strings \ +cpp11_decltype \ +cpp11_director_enums \ +cpp11_strongly_typed_enumerations \ cpp_enum \ default_constructor \ director_binary_string \ +director_comparison_operators \ director_enum \ director_primitives \ -director_redefined \ director_string \ +director_using_member_scopes \ enum_thorough \ -li_windows \ -member_pointer_const \ -preproc_constants \ smart_pointer_inherit \ FAILING_C_TESTS = \ enums \ -preproc_constants_c \ CPP_TEST_CASES += \ inout \ @@ -92,15 +95,20 @@ extra_objects: swig.cmi swig.cmo swigp4.cmi $(C_TEST_CASES:=.ctest): extra_objects $(CPP_TEST_CASES:=.cpptest): extra_objects +$(CPP11_TEST_CASES:=.cpptest): extra_objects $(MULTI_CPP_TEST_CASES:=.multicpptest): extra_objects # Clean %.clean: - @rm -f $*.ml $*.mli $*_runme; + @rm -f $*_wrap.* $*.cmo $*.cmi $*.ml $*.mli $*_runme; @if test $(srcdir) != .; then rm -f $(ml_runme); fi clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' ocaml_clean - rm -f clientdata_prop_a.ml clientdata_prop_b.ml import_stl_a.ml import_stl_b.ml - rm -f imports_a.ml imports_b.ml mod_a.ml mod_b.ml multi_import_a.ml - rm -f multi_import_b.ml packageoption_a.ml packageoption_b.ml packageoption_c.ml + rm -f clientdata_prop_a.ml clientdata_prop_b.ml + rm -f import_stl_a.ml import_stl_b.ml + rm -f imports_a.ml imports_b.ml + rm -f mod_a.ml mod_b.ml + rm -f multi_import_a.ml multi_import_b.ml multi_import_d.ml + rm -f packageoption_a.ml packageoption_b.ml packageoption_c.ml + rm -f template_typedef_cplx2.ml diff --git a/Examples/test-suite/ocaml/catches_strings_runme.ml b/Examples/test-suite/ocaml/catches_strings_runme.ml new file mode 100644 index 000000000..901aed0ec --- /dev/null +++ b/Examples/test-suite/ocaml/catches_strings_runme.ml @@ -0,0 +1,14 @@ +open Swig +open Catches_strings + +let _ = + try + ignore (_StringsThrower_charstring (C_void)); assert false + with Failure s -> + assert (s = "charstring message") + +let _ = + try + ignore (_StringsThrower_stdstring (C_void)); assert false + with Failure s -> + assert (s = "stdstring message") diff --git a/Examples/test-suite/ocaml/director_pass_by_value_runme.ml b/Examples/test-suite/ocaml/director_pass_by_value_runme.ml index af862f189..ce2137fbe 100644 --- a/Examples/test-suite/ocaml/director_pass_by_value_runme.ml +++ b/Examples/test-suite/ocaml/director_pass_by_value_runme.ml @@ -14,10 +14,13 @@ let d = (director_pass_by_value_Derived) '() +let cpp11 = _has_cplusplus11 '() as bool + let _ = let caller = new_Caller '() in assert (caller -> call_virtualMethod (d) = C_void); assert (Array.length !passByVal = 1); +(* TODO: only run if cpp11... let _ = _Counter_check_counts (C_list [C_int 0; C_int 0; C_int 0; C_int 1; C_int 0; C_int 1]) in*) (* check move constructor called and just one destructor *) let a = List.hd (fnhelper (!passByVal.(0))) in assert (a -> getVal () as int = 0x12345678); assert (a -> "~" () = C_void); diff --git a/Examples/test-suite/ocaml/enum_rename_runme.ml b/Examples/test-suite/ocaml/enum_rename_runme.ml new file mode 100644 index 000000000..4aef31bac --- /dev/null +++ b/Examples/test-suite/ocaml/enum_rename_runme.ml @@ -0,0 +1,10 @@ +open Swig +open Enum_rename + +let mydec = C_enum `M_Dec +let _ = assert (((enum_to_int `Month mydec)) = C_int 2) +let _ = assert (((int_to_enum `Month 2)) = C_enum `M_Dec) + +let mymay = C_enum `May +let _ = assert (((enum_to_int `Month mymay)) = C_int 1) +let _ = assert (((int_to_enum `Month 1)) = C_enum `May) diff --git a/Examples/test-suite/ocaml/extend_template_method_runme.ml b/Examples/test-suite/ocaml/extend_template_method_runme.ml new file mode 100644 index 000000000..5f418c927 --- /dev/null +++ b/Examples/test-suite/ocaml/extend_template_method_runme.ml @@ -0,0 +1,20 @@ +open Swig +open Extend_template_method + +let _ = + let em = new_ExtendMe '() in + assert (em -> do_stuff_double (1, 1.1) as float = 1.1); + assert (em -> do_stuff_string (1, "hello there") as string = "hello there"); + assert (em -> do_overloaded_stuff (1.1) as float = 1.1); + assert (em -> do_overloaded_stuff ("hello there") as string = "hello there"); + + assert (_ExtendMe_static_method '(123) as int = 123); + ignore (new_ExtendMe '(123)); + let em = new_TemplateExtend '() in + assert (em -> do_template_stuff_double (1, 1.1) as float = 1.1); + assert (em -> do_template_stuff_string (1, "hello there") as string = "hello there"); + assert (em -> do_template_overloaded_stuff (1.1) as float = 1.1); + assert (em -> do_template_overloaded_stuff ("hello there") as string = "hello there"); + assert (_TemplateExtend_static_template_method '(123) as int = 123); + ignore (new_TemplateExtend '(123)) +;; diff --git a/Examples/test-suite/ocaml/li_std_string_runme.ml b/Examples/test-suite/ocaml/li_std_string_runme.ml new file mode 100644 index 000000000..3e0ad2c3b --- /dev/null +++ b/Examples/test-suite/ocaml/li_std_string_runme.ml @@ -0,0 +1,53 @@ +open Swig +open Li_std_string + +let _ = + assert (_test_value '("Fee") as string = "Fee"); + try + ignore (_test_value '(None)); assert false + with Invalid_argument _ -> () + + assert (_test_const_reference '("Fee") as string = "Fee"); + try + ignore (_test_const_reference '(None)); assert false + with Invalid_argument _ -> () + + let stringPtr = _test_pointer_out '() in + ignore (_test_pointer '(stringPtr)); + let stringPtr = _test_const_pointer_out '() in + ignore (_test_const_pointer '(stringPtr)); + let stringPtr = _test_reference_out '() in + ignore (_test_reference '(stringPtr)); + + try + ignore (_test_throw '()); assert false + with Failure s -> assert (s = "test_throw message") + try + ignore (_test_const_reference_throw '()); assert false + with Failure s -> assert (s = "test_const_reference_throw message") + assert (_GlobalString2 '() as string = "global string 2"); + let s = C_string "initial string" in + ignore (_GlobalString2 '(s)); + assert (_GlobalString2 '() = s); + assert (_ConstGlobalString '() as string = "const global string"); + + let myStructure = new_Structure '() in + assert (myStructure -> "[MemberString2]" () as string = "member string 2"); + assert (myStructure -> "[MemberString2]" (s) = C_void); + assert (myStructure -> "[MemberString2]" () = s); + assert (myStructure -> "[ConstMemberString]" () as string = "const member string"); + + assert (_Structure_StaticMemberString2 '() as string = "static member string 2"); + ignore (_Structure_StaticMemberString2 '(s)); + assert (_Structure_StaticMemberString2 '() = s); + assert (_Structure_ConstStaticMemberString '() as string = "const static member string") + + assert (_stdstring_empty '() as string = "") + assert (_c_empty '() as string = "") + (* FIXME: Can't work out what C++ NULL maps to here... + assert (_c_null '() = None) + assert (_get_null (_c_null '()) = None) + *) + assert (_get_null (_c_empty '()) as string = "non-null") + assert (_get_null (_stdstring_empty '()) as string = "non-null") +;; diff --git a/Examples/test-suite/ocaml/mod_runme.ml b/Examples/test-suite/ocaml/mod_runme.ml new file mode 100644 index 000000000..8adb50b6f --- /dev/null +++ b/Examples/test-suite/ocaml/mod_runme.ml @@ -0,0 +1,7 @@ +open Swig +open Mod_a +open Mod_b + +let c = new_C '() +let d = new_D '() +let _ = d -> "DoSomething" (c) diff --git a/Examples/test-suite/ocaml/rename_rstrip_encoder_runme.ml b/Examples/test-suite/ocaml/rename_rstrip_encoder_runme.ml new file mode 100644 index 000000000..88be24fcb --- /dev/null +++ b/Examples/test-suite/ocaml/rename_rstrip_encoder_runme.ml @@ -0,0 +1,7 @@ +open Swig +open Rename_rstrip_encoder + +let s = new_SomeThing '() +let a = new_AnotherThing '() in + assert (a -> DoClsX () = C_void); +;; diff --git a/Examples/test-suite/ocaml/special_variable_macros_runme.ml b/Examples/test-suite/ocaml/special_variable_macros_runme.ml index 7f4980ea3..50b2b1f33 100644 --- a/Examples/test-suite/ocaml/special_variable_macros_runme.ml +++ b/Examples/test-suite/ocaml/special_variable_macros_runme.ml @@ -11,4 +11,6 @@ let _ = assert (_testJim '(name) as string = "multiname num"); let arg = new_PairIntBool '(10, false) in assert (_testJohn '(arg) as int = 123); + assert (_makeStringInt '("stringint", 999) as string = "stringint"); + assert (_provideStringInt '(999) as string = "1000"); ;; diff --git a/Examples/test-suite/ocaml/template_methods_runme.ml b/Examples/test-suite/ocaml/template_methods_runme.ml new file mode 100644 index 000000000..aaa5a3416 --- /dev/null +++ b/Examples/test-suite/ocaml/template_methods_runme.ml @@ -0,0 +1,25 @@ +open Swig +open Template_methods + +let _ = + let num = C_float 1. in + assert (_convolve1Bool '() as int = 0); + assert (_convolve1Bool '(true) = C_void); + assert (_convolve2Float '() as int = 0); + assert (_convolve3FloatRenamed '(num) = C_void); + assert (_convolve4Float '() as int = 0); + assert (_convolve4FloatRenamed '(num) = C_void); + assert (_convolve5FloatRenamed '() as int = 0); + assert (_convolve5FloatRenamed '(num) = C_void); + + let k = new_Klass '() in + assert (k -> KlassTMethodBoolRenamed (true) as bool = true); + assert (k -> KlassTMethodBool () = C_void); + assert (_Klass_KlassStaticTMethodBoolRenamed '(true) as bool = true); + assert (_Klass_KlassStaticTMethodBool '() = C_void); + + let cp = new_ComponentProperties '() in + assert (cp -> adda ("key1", "val1", "key2", 22.2) = C_void); + assert (cp -> adda ("key1", "val1", "key2", "val2", "key3", "val3") = C_void); + assert (cp -> adda ("key1", 1, "key2", 2, "key3", 3) = C_void) +;; diff --git a/Examples/test-suite/ocaml/typedef_inherit_runme.ml b/Examples/test-suite/ocaml/typedef_inherit_runme.ml index 6352fd4ad..a5feb7c3f 100644 --- a/Examples/test-suite/ocaml/typedef_inherit_runme.ml +++ b/Examples/test-suite/ocaml/typedef_inherit_runme.ml @@ -7,5 +7,6 @@ let _ = assert (_do_blah (b) as string = "Bar::blah"); let c = new_Spam '() and d = new_Grok '() in assert (_do_blah2 (c) as string = "Spam::blah"); - assert (_do_blah2 (d) as string = "Grok::blah") + assert (_do_blah2 (d) as string = "Grok::blah"); + assert (d -> far() as string = "Spam::far") ;; diff --git a/Examples/test-suite/ocaml/using2_runme.ml b/Examples/test-suite/ocaml/using2_runme.ml new file mode 100644 index 000000000..1ec9e2e55 --- /dev/null +++ b/Examples/test-suite/ocaml/using2_runme.ml @@ -0,0 +1,4 @@ +open Swig +open Using2 + +let _ = assert (_spam '(37) as int = 37) |