The great merge
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4141 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
6fcc22a1f8
commit
516036631c
1508 changed files with 125983 additions and 44037 deletions
2
SWIG/Examples/test-suite/guile/.cvsignore
Normal file
2
SWIG/Examples/test-suite/guile/.cvsignore
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
*wrap*
|
||||
*-guile
|
||||
44
SWIG/Examples/test-suite/guile/Makefile
Normal file
44
SWIG/Examples/test-suite/guile/Makefile
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
#######################################################################
|
||||
# $Header$
|
||||
# Makefile for guile test-suite
|
||||
#######################################################################
|
||||
|
||||
LANGUAGE = guile
|
||||
VARIANT = _passive
|
||||
SCRIPTSUFFIX = _runme.scm
|
||||
|
||||
C_TEST_CASES = long_long list_vector pointer_in_out multivalue
|
||||
|
||||
include ../common.mk
|
||||
|
||||
# Overridden variables here
|
||||
|
||||
# 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 $*\_runme.scm ]; then ( \
|
||||
env LD_LIBRARY_PATH=$(DYNAMIC_LIB_PATH):$$LD_LIBRARY_PATH guile -l $*\_runme.scm;) \
|
||||
fi;
|
||||
|
||||
# Clean
|
||||
%.clean:
|
||||
@rm -f $*-guile
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile guile_clean
|
||||
4
SWIG/Examples/test-suite/guile/README
Normal file
4
SWIG/Examples/test-suite/guile/README
Normal file
|
|
@ -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.
|
||||
|
||||
13
SWIG/Examples/test-suite/guile/casts_runme.scm
Normal file
13
SWIG/Examples/test-suite/guile/casts_runme.scm
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
;; 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_test_module" (dynamic-link "./libcasts.so"))
|
||||
|
||||
(define x (new-B))
|
||||
|
||||
;; This fails in 1.3a5 because the SWIG/Guile runtime code gets the
|
||||
;; source and the target of a cast the wrong way around.
|
||||
|
||||
(A-hello x)
|
||||
|
||||
(exit 0)
|
||||
9
SWIG/Examples/test-suite/guile/char_constant_runme.scm
Normal file
9
SWIG/Examples/test-suite/guile/char_constant_runme.scm
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
;; 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_test_module" (dynamic-link "./libchar_constant.so"))
|
||||
|
||||
(if (and (char? (CHAR-CONSTANT))
|
||||
(string? (STRING-CONSTANT)))
|
||||
(exit 0)
|
||||
(exit 1))
|
||||
19
SWIG/Examples/test-suite/guile/imports_runme.scm
Normal file
19
SWIG/Examples/test-suite/guile/imports_runme.scm
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
;;; 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"))
|
||||
|
||||
(define x (new-B))
|
||||
|
||||
;; This fails in 1.3a5 because the SWIG runtime code does not know
|
||||
;; that x (an instance of class B) can be passed to methods of class A.
|
||||
|
||||
(A-hello x)
|
||||
|
||||
(exit 0)
|
||||
28
SWIG/Examples/test-suite/guile/list_vector_runme.scm
Normal file
28
SWIG/Examples/test-suite/guile/list_vector_runme.scm
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
;; 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_test_module" (dynamic-link "./liblist_vector.so"))
|
||||
|
||||
(define-macro (check form)
|
||||
`(if (not ,form)
|
||||
(error "Check failed: " ',form)))
|
||||
|
||||
(check (= (sum-list '(1 3 4 6 7)) 21))
|
||||
(check (= (sum-vector #(2 4 6 7 9)) 28))
|
||||
(check (equal? (one-to-seven-list) '(1 2 3 4 5 6 7)))
|
||||
(check (equal? (one-to-seven-vector) #(1 2 3 4 5 6 7)))
|
||||
|
||||
(check (= (sum-list2 '(1 3 4 6 7)) 21))
|
||||
(check (= (sum-vector2 #(2 4 6 7 9)) 28))
|
||||
(check (equal? (one-to-seven-list2) '(1 2 3 4 5 6 7)))
|
||||
(check (equal? (one-to-seven-vector2) #(1 2 3 4 5 6 7)))
|
||||
|
||||
(check (= (sum-lists '(1 2 3) '(4 5 6) '(7 8 9)) 45))
|
||||
(check (= (sum-lists2 '(1 2 3) '(4 5 6) '(7 8 9)) 45))
|
||||
(check (equal? (call-with-values produce-lists list)
|
||||
'(#(0 1 2 3 4)
|
||||
#(0 1 4 9 16)
|
||||
#(0.0 1.5 3.0 4.5 6.0))))
|
||||
|
||||
|
||||
(exit 0)
|
||||
24
SWIG/Examples/test-suite/guile/multivalue_runme.scm
Normal file
24
SWIG/Examples/test-suite/guile/multivalue_runme.scm
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
;;;; 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_test_module" (dynamic-link "./libmultivalue.so"))
|
||||
|
||||
(let ((quotient/remainder (divide-l 37 5)))
|
||||
(if (not (equal? quotient/remainder '(7 2)))
|
||||
(exit 1)))
|
||||
|
||||
(let ((quotient-remainder-vector (divide-v 41 7)))
|
||||
(if (not (equal? quotient-remainder-vector #(5 6)))
|
||||
(exit 1)))
|
||||
|
||||
(call-with-values (lambda ()
|
||||
(divide-mv 91 13))
|
||||
(lambda (quotient remainder)
|
||||
(if (not (and (= quotient 7)
|
||||
(= remainder 0)))
|
||||
(exit 1))))
|
||||
|
||||
(exit 0)
|
||||
|
||||
10
SWIG/Examples/test-suite/guile/name_runme.scm
Normal file
10
SWIG/Examples/test-suite/guile/name_runme.scm
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
;; 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_test_module" (dynamic-link "./libname.so"))
|
||||
|
||||
(foo-2)
|
||||
bar-2
|
||||
Baz-2
|
||||
|
||||
(exit 0)
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
;; 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)))
|
||||
|
||||
;; 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)
|
||||
56
SWIG/Examples/test-suite/guile/overload_simple_runme.scm
Normal file
56
SWIG/Examples/test-suite/guile/overload_simple_runme.scm
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
;; 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"))
|
||||
|
||||
(if (not (string=? (foo 3) "foo:int"))
|
||||
(error "foo(int)"))
|
||||
|
||||
(if (not (string=? (foo 3.01) "foo:double"))
|
||||
(error "foo(double)"))
|
||||
|
||||
(if (not (string=? (foo "hello") "foo:char *"))
|
||||
(error "foo(char *)"))
|
||||
|
||||
(let ((f (new-Foo))
|
||||
(b (new-Bar))
|
||||
(s (new-Spam)))
|
||||
(if (not (string=? (foo f) "foo:Foo *"))
|
||||
(error "foo(Foo *)"))
|
||||
(if (not (string=? (foo b) "foo:Bar *"))
|
||||
(error "foo(Bar *)"))
|
||||
;; Test member functions
|
||||
(if (not (string=? (Spam-foo s 3) "foo:int"))
|
||||
(error "Spam::foo(int)"))
|
||||
(if (not (string=? (Spam-foo s 3.01) "foo:double"))
|
||||
(error "Spam::foo(double)"))
|
||||
(if (not (string=? (Spam-foo s "hello") "foo:char *"))
|
||||
(error "Spam::foo(char *)"))
|
||||
(if (not (string=? (Spam-foo s f) "foo:Foo *"))
|
||||
(error "Spam::foo(Foo *)"))
|
||||
(if (not (string=? (Spam-foo s b) "foo:Bar *"))
|
||||
(error "Spam::foo(Bar *)"))
|
||||
;; Test static member functions
|
||||
(if (not (string=? (Spam-bar 3) "bar:int"))
|
||||
(error "Spam::bar(int)"))
|
||||
(if (not (string=? (Spam-bar 3.01) "bar:double"))
|
||||
(error "Spam::bar(double)"))
|
||||
(if (not (string=? (Spam-bar "hello") "bar:char *"))
|
||||
(error "Spam::bar(char *)"))
|
||||
(if (not (string=? (Spam-bar f) "bar:Foo *"))
|
||||
(error "Spam::bar(Foo *)"))
|
||||
(if (not (string=? (Spam-bar b) "bar:Bar *"))
|
||||
(error "Spam::bar(Bar *)"))
|
||||
;; Test constructors
|
||||
(if (not (string=? (Spam-type-get (new-Spam)) "none"))
|
||||
(error "Spam()"))
|
||||
(if (not (string=? (Spam-type-get (new-Spam 3)) "int"))
|
||||
(error "Spam(int)"))
|
||||
(if (not (string=? (Spam-type-get (new-Spam 3.4)) "double"))
|
||||
(error "Spam(double)"))
|
||||
(if (not (string=? (Spam-type-get (new-Spam "hello")) "char *"))
|
||||
(error "Spam(char *)"))
|
||||
(if (not (string=? (Spam-type-get (new-Spam b)) "Bar *"))
|
||||
(error "Spam(Bar *)")))
|
||||
|
||||
(exit 0)
|
||||
12
SWIG/Examples/test-suite/guile/overload_subtype_runme.scm
Normal file
12
SWIG/Examples/test-suite/guile/overload_subtype_runme.scm
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
;; 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"))
|
||||
|
||||
(if (not (= (spam (new-Foo)) 1))
|
||||
(error "foo"))
|
||||
|
||||
(if (not (= (spam (new-Bar)) 2))
|
||||
(error "bar"))
|
||||
|
||||
(exit 0)
|
||||
18
SWIG/Examples/test-suite/guile/pointer_in_out_runme.scm
Normal file
18
SWIG/Examples/test-suite/guile/pointer_in_out_runme.scm
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
;; 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"))
|
||||
|
||||
(define-macro (check form)
|
||||
`(if (not ,form)
|
||||
(error "Check failed: " ',form)))
|
||||
|
||||
(define p (produce-int-pointer 47 11))
|
||||
|
||||
(check (= (consume-int-pointer p) 47))
|
||||
|
||||
(define q (frobnicate-int-pointer p))
|
||||
|
||||
(check (= (consume-int-pointer q) 11))
|
||||
|
||||
(exit 0)
|
||||
41
SWIG/Examples/test-suite/guile/unions_runme.scm
Normal file
41
SWIG/Examples/test-suite/guile/unions_runme.scm
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
;;; 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"))
|
||||
|
||||
;; Create new instances of SmallStruct and BigStruct for later use
|
||||
(define small (new-SmallStruct))
|
||||
(SmallStruct-jill-set small 200)
|
||||
|
||||
(define big (new-BigStruct))
|
||||
(BigStruct-smallstruct-set big small)
|
||||
(BigStruct-jack-set big 300)
|
||||
|
||||
;; Use SmallStruct then BigStruct to setup EmbeddedUnionTest.
|
||||
;; Ensure values in EmbeddedUnionTest are set correctly for each.
|
||||
(define eut (new-EmbeddedUnionTest))
|
||||
|
||||
;; First check the SmallStruct in EmbeddedUnionTest
|
||||
(EmbeddedUnionTest-number-set eut 1)
|
||||
(EmbeddedUnionTest-uni-small-set (EmbeddedUnionTest-uni-get eut)
|
||||
small)
|
||||
(let ((Jill1 (SmallStruct-jill-get
|
||||
(EmbeddedUnionTest-uni-small-get
|
||||
(EmbeddedUnionTest-uni-get eut)))))
|
||||
(if (not (= Jill1 200))
|
||||
(begin
|
||||
(display "Runtime test 1 failed.")
|
||||
(exit 1))))
|
||||
|
||||
(let ((Num1 (EmbeddedUnionTest-number-get eut)))
|
||||
(if (not (= Num1 1))
|
||||
(begin
|
||||
(display "Runtime test 2 failed.")
|
||||
(exit 1))))
|
||||
|
||||
;; that should do
|
||||
|
||||
(exit 0)
|
||||
Loading…
Add table
Add a link
Reference in a new issue