diff options
| author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2009-08-18 20:56:02 +0000 |
|---|---|---|
| committer | Lorry <lorry@roadtrain.codethink.co.uk> | 2012-09-25 16:59:08 +0000 |
| commit | 9f8a09ed743cedd9547bf0661d518647966ab114 (patch) | |
| tree | 9c7803d3b27a8ec22e91792ac7f7932efa128b20 /Examples/test-suite/guile | |
| download | swig-tarball-master.tar.gz | |
Imported from /srv/lorry/lorry-area/swig-tarball/swig-1.3.40.tar.gz.HEADswig-1.3.40master
Diffstat (limited to 'Examples/test-suite/guile')
31 files changed, 293 insertions, 0 deletions
diff --git a/Examples/test-suite/guile/Makefile.in b/Examples/test-suite/guile/Makefile.in new file mode 100644 index 0000000..c6be92c --- /dev/null +++ b/Examples/test-suite/guile/Makefile.in @@ -0,0 +1,56 @@ +####################################################################### +# Makefile for guile test-suite +####################################################################### + +LANGUAGE = guile +VARIANT = _gh +SCRIPTSUFFIX = _runme.scm +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +top_builddir = @top_builddir@ +GUILE = @GUILE@ +GUILE_RUNTIME=-runtime + +C_TEST_CASES = long_long \ + list_vector \ + multivalue \ + pointer_in_out + + +include $(srcdir)/../common.mk + +# Overridden variables here +# none! + +# Custom tests - tests with additional commandline options +%.multicpptest: SWIGOPT += $(GUILE_RUNTIME) + +# Rules for the different types of tests +%.cpptest: + $(setup) + +$(swig_and_compile_cpp) + $(run_testcase) + +%.ctest: + $(setup) + +$(swig_and_compile_c) + $(run_testcase) + +%.multicpptest: + $(setup) + +$(swig_and_compile_multi_cpp) + $(run_testcase) + +# Runs the testcase. A testcase is only run if +# a file is found which has _runme.scm appended after the testcase name. +run_testcase = \ + if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ + fi + +# Clean +%.clean: + @rm -f $*-guile + +clean: + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile guile_clean diff --git a/Examples/test-suite/guile/README b/Examples/test-suite/guile/README new file mode 100644 index 0000000..37432ea --- /dev/null +++ b/Examples/test-suite/guile/README @@ -0,0 +1,4 @@ +See ../README for common README file. + +Any testcases which have _runme.scm appended after the testcase name will be detected and run. + diff --git a/Examples/test-suite/guile/casts_runme.scm b/Examples/test-suite/guile/casts_runme.scm new file mode 100644 index 0000000..7a0a042 --- /dev/null +++ b/Examples/test-suite/guile/casts_runme.scm @@ -0,0 +1,5 @@ +;; The SWIG modules have "passive" Linkage, i.e., they don't generate +;; Guile modules (namespaces) but simply put all the bindings into the +;; current module. That's enough for such a simple test. +(dynamic-call "scm_init_casts_module" (dynamic-link "./libcasts.so")) +(load "../schemerunme/casts.scm") diff --git a/Examples/test-suite/guile/char_constant_runme.scm b/Examples/test-suite/guile/char_constant_runme.scm new file mode 100644 index 0000000..d183b35 --- /dev/null +++ b/Examples/test-suite/guile/char_constant_runme.scm @@ -0,0 +1,5 @@ +;; The SWIG modules have "passive" Linkage, i.e., they don't generate +;; Guile modules (namespaces) but simply put all the bindings into the +;; current module. That's enough for such a simple test. +(dynamic-call "scm_init_char_constant_module" (dynamic-link "./libchar_constant.so")) +(load "../schemerunme/char_constant.scm") diff --git a/Examples/test-suite/guile/class_ignore_runme.scm b/Examples/test-suite/guile/class_ignore_runme.scm new file mode 100644 index 0000000..b3229f8 --- /dev/null +++ b/Examples/test-suite/guile/class_ignore_runme.scm @@ -0,0 +1,2 @@ +(dynamic-call "scm_init_class_ignore_module" (dynamic-link "./libclass_ignore.so")) +(load "../schemerunme/class_ignore.scm") diff --git a/Examples/test-suite/guile/constover_runme.scm b/Examples/test-suite/guile/constover_runme.scm new file mode 100644 index 0000000..1ab42d3 --- /dev/null +++ b/Examples/test-suite/guile/constover_runme.scm @@ -0,0 +1,2 @@ +(dynamic-call "scm_init_constover_module" (dynamic-link "./libconstover.so")) +(load "../schemerunme/constover.scm") diff --git a/Examples/test-suite/guile/contract_runme.scm b/Examples/test-suite/guile/contract_runme.scm new file mode 100644 index 0000000..ea80e32 --- /dev/null +++ b/Examples/test-suite/guile/contract_runme.scm @@ -0,0 +1,6 @@ +;; The SWIG modules have "passive" Linkage, i.e., they don't generate +;; Guile modules (namespaces) but simply put all the bindings into the +;; current module. That's enough for such a simple test. +(dynamic-call "scm_init_contract_module" (dynamic-link "./libcontract.so")) +(load "testsuite.scm") +(load "../schemerunme/contract.scm") diff --git a/Examples/test-suite/guile/cpp_enum_runme.scm b/Examples/test-suite/guile/cpp_enum_runme.scm new file mode 100644 index 0000000..5a2d9f0 --- /dev/null +++ b/Examples/test-suite/guile/cpp_enum_runme.scm @@ -0,0 +1,5 @@ +;; The SWIG modules have "passive" Linkage, i.e., they don't generate +;; Guile modules (namespaces) but simply put all the bindings into the +;; current module. That's enough for such a simple test. +(dynamic-call "scm_init_cpp_enum_module" (dynamic-link "./libcpp_enum.so")) +(load "../schemerunme/cpp_enum.scm") diff --git a/Examples/test-suite/guile/cpp_namespace_runme.scm b/Examples/test-suite/guile/cpp_namespace_runme.scm new file mode 100644 index 0000000..2a871de --- /dev/null +++ b/Examples/test-suite/guile/cpp_namespace_runme.scm @@ -0,0 +1,2 @@ +(dynamic-call "scm_init_cpp_namespace_module" (dynamic-link "./libcpp_namespace.so")) +(load "../schemerunme/cpp_namespace.scm") diff --git a/Examples/test-suite/guile/dynamic_cast_runme.scm b/Examples/test-suite/guile/dynamic_cast_runme.scm new file mode 100644 index 0000000..7b70001 --- /dev/null +++ b/Examples/test-suite/guile/dynamic_cast_runme.scm @@ -0,0 +1,2 @@ +(dynamic-call "scm_init_dynamic_cast_module" (dynamic-link "./libdynamic_cast.so")) +(load "../schemerunme/dynamic_cast.scm") diff --git a/Examples/test-suite/guile/import_nomodule_runme.scm b/Examples/test-suite/guile/import_nomodule_runme.scm new file mode 100644 index 0000000..ffb2474 --- /dev/null +++ b/Examples/test-suite/guile/import_nomodule_runme.scm @@ -0,0 +1,2 @@ +(dynamic-call "scm_init_import_nomodule_module" (dynamic-link "./libimport_nomodule.so")) +(load "../schemerunme/import_nomodule.scm") diff --git a/Examples/test-suite/guile/imports_runme.scm b/Examples/test-suite/guile/imports_runme.scm new file mode 100644 index 0000000..2fda017 --- /dev/null +++ b/Examples/test-suite/guile/imports_runme.scm @@ -0,0 +1,11 @@ +;;; This file is part of a test for SF bug #231619. +;;; It shows that the %import directive does not work properly in SWIG +;;; 1.3a5: Type information is not properly generated if a base class +;;; comes from an %import-ed file. + +;; The SWIG modules have "passive" Linkage, i.e., they don't generate +;; Guile modules (namespaces) but simply put all the bindings into the +;; current module. That's enough for such a simple test. +(dynamic-call "scm_init_imports_a_module" (dynamic-link "./libimports_a.so")) +(dynamic-call "scm_init_imports_b_module" (dynamic-link "./libimports_b.so")) +(load "../schemerunme/imports.scm") diff --git a/Examples/test-suite/guile/inherit_missing_runme.scm b/Examples/test-suite/guile/inherit_missing_runme.scm new file mode 100644 index 0000000..97e950c --- /dev/null +++ b/Examples/test-suite/guile/inherit_missing_runme.scm @@ -0,0 +1,2 @@ +(dynamic-call "scm_init_inherit_missing_module" (dynamic-link "./libinherit_missing.so")) +(load "../schemerunme/inherit_missing.scm") diff --git a/Examples/test-suite/guile/integers_runme.scm b/Examples/test-suite/guile/integers_runme.scm new file mode 100644 index 0000000..14ec8b0 --- /dev/null +++ b/Examples/test-suite/guile/integers_runme.scm @@ -0,0 +1,11 @@ +;; The SWIG modules have "passive" Linkage, i.e., they don't generate +;; Guile modules (namespaces) but simply put all the bindings into the +;; current module. That's enough for such a simple test. +(dynamic-call "scm_init_integers_module" (dynamic-link "./libintegers.so")) + +(define-macro (throws-exception? form) + `(catch #t + (lambda () ,form #f) + (lambda args #t))) + +(load "../schemerunme/integers.scm") diff --git a/Examples/test-suite/guile/li_std_string_runme.scm b/Examples/test-suite/guile/li_std_string_runme.scm new file mode 100644 index 0000000..05b74cd --- /dev/null +++ b/Examples/test-suite/guile/li_std_string_runme.scm @@ -0,0 +1,5 @@ +;; The SWIG modules have "passive" Linkage, i.e., they don't generate +;; Guile modules (namespaces) but simply put all the bindings into the +;; current module. That's enough for such a simple test. +(dynamic-call "scm_init_li_std_string_module" (dynamic-link "./libli_std_string.so")) +(load "../schemerunme/li_std_string.scm") diff --git a/Examples/test-suite/guile/li_typemaps_runme.scm b/Examples/test-suite/guile/li_typemaps_runme.scm new file mode 100644 index 0000000..9824fc9 --- /dev/null +++ b/Examples/test-suite/guile/li_typemaps_runme.scm @@ -0,0 +1,18 @@ +;;; This is the union runtime testcase. It ensures that values within a +;;; union embedded within a struct can be set and read correctly. + +;; The SWIG modules have "passive" Linkage, i.e., they don't generate +;; Guile modules (namespaces) but simply put all the bindings into the +;; current module. That's enough for such a simple test. +(dynamic-call "scm_init_li_typemaps_module" (dynamic-link "./libli_typemaps.so")) +(load "../schemerunme/li_typemaps.scm") + +(let ((lst (inoutr-int2 3 -2))) + (if (not (and (= (car lst) 3) (= (cadr lst) -2))) + (error "Error in inoutr-int2"))) + +(let ((lst (out-foo 4))) + (if (not (and (= (Foo-a-get (car lst)) 4) (= (cadr lst) 8))) + (error "Error in out-foo"))) + +(exit 0) diff --git a/Examples/test-suite/guile/list_vector_runme.scm b/Examples/test-suite/guile/list_vector_runme.scm new file mode 100644 index 0000000..546d8a1 --- /dev/null +++ b/Examples/test-suite/guile/list_vector_runme.scm @@ -0,0 +1,5 @@ +;; The SWIG modules have "passive" Linkage, i.e., they don't generate +;; Guile modules (namespaces) but simply put all the bindings into the +;; current module. That's enough for such a simple test. +(dynamic-call "scm_init_list_vector_module" (dynamic-link "./liblist_vector.so")) +(load "../schemerunme/list_vector.scm") diff --git a/Examples/test-suite/guile/multivalue_runme.scm b/Examples/test-suite/guile/multivalue_runme.scm new file mode 100644 index 0000000..d1d7fbf --- /dev/null +++ b/Examples/test-suite/guile/multivalue_runme.scm @@ -0,0 +1,7 @@ +;;;; Automatic test of multiple return values + +;; The SWIG modules have "passive" Linkage, i.e., they don't generate +;; Guile modules (namespaces) but simply put all the bindings into the +;; current module. That's enough for such a simple test. +(dynamic-call "scm_init_multivalue_module" (dynamic-link "./libmultivalue.so")) +(load "../schemerunme/multivalue.scm") diff --git a/Examples/test-suite/guile/name_runme.scm b/Examples/test-suite/guile/name_runme.scm new file mode 100644 index 0000000..831c206 --- /dev/null +++ b/Examples/test-suite/guile/name_runme.scm @@ -0,0 +1,5 @@ +;; The SWIG modules have "passive" Linkage, i.e., they don't generate +;; Guile modules (namespaces) but simply put all the bindings into the +;; current module. That's enough for such a simple test. +(dynamic-call "scm_init_name_module" (dynamic-link "./libname.so")) +(load "../schemerunme/name.scm") diff --git a/Examples/test-suite/guile/overload_complicated_runme.scm b/Examples/test-suite/guile/overload_complicated_runme.scm new file mode 100644 index 0000000..3c2b80d --- /dev/null +++ b/Examples/test-suite/guile/overload_complicated_runme.scm @@ -0,0 +1,21 @@ +;; The SWIG modules have "passive" Linkage, i.e., they don't generate +;; Guile modules (namespaces) but simply put all the bindings into the +;; current module. That's enough for such a simple test. +(dynamic-call "scm_init_overload_complicated_module" (dynamic-link "./liboverload_complicated.so")) + +(define-macro (check form) + `(if (not ,form) + (error "Check failed: " ',form))) + +(define (=~ a b) + (< (abs (- a b)) 1e-8)) + +;; Check first method +(check (=~ (foo 1 2 "bar" 4) 15)) + +;; Check second method +(check (=~ (foo 1 2) 4811.4)) +(check (=~ (foo 1 2 3.2) 4797.2)) +(check (=~ (foo 1 2 3.2 #\Q) 4798.2)) + +(exit 0) diff --git a/Examples/test-suite/guile/overload_copy_runme.scm b/Examples/test-suite/guile/overload_copy_runme.scm new file mode 100644 index 0000000..9b93aeb --- /dev/null +++ b/Examples/test-suite/guile/overload_copy_runme.scm @@ -0,0 +1,2 @@ +(dynamic-call "scm_init_overload_copy_module" (dynamic-link "./liboverload_copy.so")) +(load "../schemerunme/overload_copy.scm") diff --git a/Examples/test-suite/guile/overload_extend_runme.scm b/Examples/test-suite/guile/overload_extend_runme.scm new file mode 100644 index 0000000..cb0223d --- /dev/null +++ b/Examples/test-suite/guile/overload_extend_runme.scm @@ -0,0 +1,2 @@ +(dynamic-call "scm_init_overload_extend_module" (dynamic-link "./liboverload_extend.so")) +(load "../schemerunme/overload_extend.scm") diff --git a/Examples/test-suite/guile/overload_simple_runme.scm b/Examples/test-suite/guile/overload_simple_runme.scm new file mode 100644 index 0000000..993a5f3 --- /dev/null +++ b/Examples/test-suite/guile/overload_simple_runme.scm @@ -0,0 +1,5 @@ +;; The SWIG modules have "passive" Linkage, i.e., they don't generate +;; Guile modules (namespaces) but simply put all the bindings into the +;; current module. That's enough for such a simple test. +(dynamic-call "scm_init_overload_simple_module" (dynamic-link "./liboverload_simple.so")) +(load "../schemerunme/overload_simple.scm") diff --git a/Examples/test-suite/guile/overload_subtype_runme.scm b/Examples/test-suite/guile/overload_subtype_runme.scm new file mode 100644 index 0000000..7dfa2c1 --- /dev/null +++ b/Examples/test-suite/guile/overload_subtype_runme.scm @@ -0,0 +1,5 @@ +;; The SWIG modules have "passive" Linkage, i.e., they don't generate +;; Guile modules (namespaces) but simply put all the bindings into the +;; current module. That's enough for such a simple test. +(dynamic-call "scm_init_overload_subtype_module" (dynamic-link "./liboverload_subtype.so")) +(load "../schemerunme/overload_subtype.scm") diff --git a/Examples/test-suite/guile/pointer_in_out_runme.scm b/Examples/test-suite/guile/pointer_in_out_runme.scm new file mode 100644 index 0000000..de35227 --- /dev/null +++ b/Examples/test-suite/guile/pointer_in_out_runme.scm @@ -0,0 +1,5 @@ +;; The SWIG modules have "passive" Linkage, i.e., they don't generate +;; Guile modules (namespaces) but simply put all the bindings into the +;; current module. That's enough for such a simple test. +(dynamic-call "scm_init_pointer_in_out_module" (dynamic-link "./libpointer_in_out.so")) +(load "../schemerunme/pointer_in_out.scm") diff --git a/Examples/test-suite/guile/reference_global_vars_runme.scm b/Examples/test-suite/guile/reference_global_vars_runme.scm new file mode 100644 index 0000000..8cd31c3 --- /dev/null +++ b/Examples/test-suite/guile/reference_global_vars_runme.scm @@ -0,0 +1,3 @@ +; copied from python runme_.py +(dynamic-call "scm_init_reference_global_vars_module" (dynamic-link "./libreference_global_vars.so")) +(load "../schemerunme/reference_global_vars.scm") diff --git a/Examples/test-suite/guile/testsuite.scm b/Examples/test-suite/guile/testsuite.scm new file mode 100644 index 0000000..7f5fd71 --- /dev/null +++ b/Examples/test-suite/guile/testsuite.scm @@ -0,0 +1,37 @@ +;; Little helper functions and macros for the run tests + +(use-modules (ice-9 format)) + +(define (test-error error-format . args) + (display "Runtime check failed. ") + (apply format #t error-format args) + (newline) + (exit 1)) + +(define-macro (expect-true form) + `(if (not ,form) + (test-error "Expected true value of ~A" ',form))) + +(define-macro (expect-false form) + `(if ,form + (test-error "Expected false value of ~A" ',form))) + +(define-macro (expect-result expected-result-form equal? form) + `(let ((expected-result ,expected-result-form) + (result ,form)) + (if (not (,equal? result expected-result)) + (test-error "The result of ~A was ~A, expected ~A, which is not ~A" + ',form result expected-result ',equal?)))) + +(define-macro (expect-throw tag-form form) + `(let ((tag ,tag-form)) + (if (catch #t + (lambda () + ,form + #t) + (lambda (key . args) + (if (eq? key ,tag-form) + #f + (test-error "The form ~A threw to ~A (expected a throw to ~A)" + ',form key tag)))) + (test-error "The form ~A returned normally (expected a throw to ~A)")))) diff --git a/Examples/test-suite/guile/throw_exception_runme.scm b/Examples/test-suite/guile/throw_exception_runme.scm new file mode 100644 index 0000000..3775062 --- /dev/null +++ b/Examples/test-suite/guile/throw_exception_runme.scm @@ -0,0 +1,45 @@ +;; The SWIG modules have "passive" Linkage, i.e., they don't generate +;; Guile modules (namespaces) but simply put all the bindings into the +;; current module. That's enough for such a simple test. +(dynamic-call "scm_init_throw_exception_module" (dynamic-link "./libthrow_exception.so")) + +(define-macro (check-throw form) + `(catch 'swig-exception + (lambda () + ,form + (error "Check failed (returned normally): " ',form)) + (lambda (key result) + result))) + +(define-macro (check-throw-error form) + `(let ((result (check-throw ,form))) + (test-is-Error result))) + +(let ((foo (new-Foo))) + (let ((result (check-throw (Foo-test-int foo)))) + (if (not (eqv? result 37)) + (error "Foo-test-int failed, returned " result))) + (let ((result (check-throw (Foo-test-multi foo 1)))) + (if (not (eqv? result 37)) + (error "Foo-test-multi 1 failed, returned " result))) + (let ((result (check-throw (Foo-test-msg foo)))) + (if (not (and (string? result) + (string=? result "Dead"))) + (error "Foo-test-msg failed, returned " result))) + (let ((result (check-throw (Foo-test-multi foo 2)))) + (if (not (and (string? result) + (string=? result "Dead"))) + (error "Foo-test-multi 2 failed, returned " result))) + (check-throw-error (Foo-test-cls foo)) + (check-throw-error (Foo-test-multi foo 3)) + (check-throw-error (Foo-test-cls-ptr foo)) + (check-throw-error (Foo-test-cls-ref foo)) + ;; Namespace stuff + (let ((result (check-throw (Foo-test-enum foo)))) + (if (not (eqv? result (enum2))) + (error "Foo-test-enum failed, returned " result))) + (check-throw-error (Foo-test-cls-td foo)) + (check-throw-error (Foo-test-cls-ptr-td foo)) + (check-throw-error (Foo-test-cls-ref-td foo))) + +(exit 0) diff --git a/Examples/test-suite/guile/typedef_inherit_runme.scm b/Examples/test-suite/guile/typedef_inherit_runme.scm new file mode 100644 index 0000000..d75d421 --- /dev/null +++ b/Examples/test-suite/guile/typedef_inherit_runme.scm @@ -0,0 +1,2 @@ +(dynamic-call "scm_init_typedef_inherit_module" (dynamic-link "./libtypedef_inherit.so")) +(load "../schemerunme/typedef_inherit.scm") diff --git a/Examples/test-suite/guile/typename_runme.scm b/Examples/test-suite/guile/typename_runme.scm new file mode 100644 index 0000000..4243f69 --- /dev/null +++ b/Examples/test-suite/guile/typename_runme.scm @@ -0,0 +1,3 @@ +(dynamic-call "scm_init_typename_module" (dynamic-link "./libtypename.so")) +;;(dynamic-call "scm_init_types_module" (dynamic-link "./libtypes.so")) +(load "../schemerunme/typename.scm") diff --git a/Examples/test-suite/guile/unions_runme.scm b/Examples/test-suite/guile/unions_runme.scm new file mode 100644 index 0000000..867e8a3 --- /dev/null +++ b/Examples/test-suite/guile/unions_runme.scm @@ -0,0 +1,8 @@ +;;; This is the union runtime testcase. It ensures that values within a +;;; union embedded within a struct can be set and read correctly. + +;; The SWIG modules have "passive" Linkage, i.e., they don't generate +;; Guile modules (namespaces) but simply put all the bindings into the +;; current module. That's enough for such a simple test. +(dynamic-call "scm_init_unions_module" (dynamic-link "./libunions.so")) +(load "../schemerunme/unions.scm") |
