Add some chicken test-suite entries for overloaded functions
(which now work correctly) and update the chicken documentation git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7146 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
c70b62fee2
commit
c5f25b9168
10 changed files with 348 additions and 14 deletions
|
|
@ -0,0 +1,8 @@
|
|||
(require 'tinyclos)
|
||||
(load "../../../Lib/chicken/multi-generic.scm")
|
||||
(load-library 'overload-copy "./overload_copy.so")
|
||||
|
||||
(define f (make <Foo>))
|
||||
(define g (make <Foo> f))
|
||||
|
||||
(exit 0)
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
(require 'tinyclos)
|
||||
(load "../../../Lib/chicken/multi-generic.scm")
|
||||
(load-library 'overload-extend "./overload_extend.so")
|
||||
|
||||
(define f (make <Foo>))
|
||||
|
||||
(if (not (= (test f 3) 1))
|
||||
(error "test integer bad"))
|
||||
|
||||
(if (not (= (test f "hello") 2))
|
||||
(error "test string bad"))
|
||||
|
||||
(if (not (= (test f 3.5 2.5) 6.0))
|
||||
(error "test reals bad"))
|
||||
|
||||
(exit 0)
|
||||
|
|
@ -1,24 +1,46 @@
|
|||
(require 'tinyclos)
|
||||
(load "../../../Lib/chicken/multi-generic.scm")
|
||||
(load-library 'overload_simple "overload_simple.so")
|
||||
|
||||
(define-macro (check test)
|
||||
`(if (not ,test) (error ,'test)))
|
||||
`(if (not ,test) (error ',test)))
|
||||
|
||||
(check (string=? (foo) "foo:"))
|
||||
(check (string=? (foo 3) "foo:int"))
|
||||
(exit 0)
|
||||
(check (string=? (foo 3.01) "foo:double"))
|
||||
(check (string=? (foo "hey") "foo:char *"))
|
||||
|
||||
(define f (make <Foo>))
|
||||
(define b (make <Bar>))
|
||||
(define s (make <Spam>))
|
||||
(define b2 (make <Bar> 3))
|
||||
|
||||
(check (= (slot-ref b 'num) 0))
|
||||
(check (= (slot-ref b2 'num) 3))
|
||||
|
||||
(check (string=? (foo f) "foo:Foo *"))
|
||||
(check (string=? (foo b) "foo:Bar *"))
|
||||
(check (string=? (foo f 3) "foo:Foo *,int"))
|
||||
(check (string=? (foo 3.2 b) "foo:double,Bar *"))
|
||||
|
||||
;; now check blah
|
||||
(check (string=? (blah 2.01) "blah:double"))
|
||||
(check (string=? (blah "hey") "blah:char *"))
|
||||
|
||||
;; now check spam member functions
|
||||
(define s (make <Spam>))
|
||||
(define s2 (make <Spam> 3))
|
||||
(define s3 (make <Spam> 3.2))
|
||||
(define s4 (make <Spam> "whee"))
|
||||
(define s5 (make <Spam> f))
|
||||
(define s6 (make <Spam> b))
|
||||
|
||||
(check (string=? (slot-ref s 'type) "none"))
|
||||
(check (string=? (slot-ref s2 'type) "int"))
|
||||
(check (string=? (slot-ref s3 'type) "double"))
|
||||
(check (string=? (slot-ref s4 'type) "char *"))
|
||||
(check (string=? (slot-ref s5 'type) "Foo *"))
|
||||
(check (string=? (slot-ref s6 'type) "Bar *"))
|
||||
|
||||
;; now check Spam member functions
|
||||
(check (string=? (foo s 2) "foo:int"))
|
||||
(check (string=? (foo s 2.1) "foo:double"))
|
||||
|
|
@ -27,10 +49,10 @@
|
|||
(check (string=? (foo s b) "foo:Bar *"))
|
||||
|
||||
;; check static member funcs
|
||||
(check (string=? (bar 3) "bar:int"))
|
||||
(check (string=? (bar 3.2) "bar:double"))
|
||||
(check (string=? (bar "hey") "bar:char *"))
|
||||
(check (string=? (bar f) "bar:Foo *"))
|
||||
(check (string=? (bar b) "bar:Bar *"))
|
||||
(check (string=? (Spam-bar 3) "bar:int"))
|
||||
(check (string=? (Spam-bar 3.2) "bar:double"))
|
||||
(check (string=? (Spam-bar "hey") "bar:char *"))
|
||||
(check (string=? (Spam-bar f) "bar:Foo *"))
|
||||
(check (string=? (Spam-bar b) "bar:Bar *"))
|
||||
|
||||
(exit 0)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
(load-library 'overload-subtype "./overload_subtype.so")
|
||||
|
||||
(define f (make <Foo>))
|
||||
(define b (make <Bar>))
|
||||
|
||||
(if (not (= (spam f) 1))
|
||||
(error "Error in foo"))
|
||||
|
||||
(if (not (= (spam b) 2))
|
||||
(error "Error in bar"))
|
||||
|
||||
(exit 0)
|
||||
|
|
@ -11,11 +11,16 @@ struct Foo {
|
|||
|
||||
class Bar {
|
||||
public:
|
||||
Bar(int i = 0) {}
|
||||
Bar(int i = 0) { num = i; }
|
||||
|
||||
static int foo(int a=0, int b=0) {return 0;}
|
||||
|
||||
int num;
|
||||
};
|
||||
|
||||
char *foo() {
|
||||
return (char *) "foo:";
|
||||
}
|
||||
char *foo(int) {
|
||||
return (char*) "foo:int";
|
||||
}
|
||||
|
|
@ -37,6 +42,12 @@ char *foo(Bar *) {
|
|||
char *foo(void *) {
|
||||
return (char *) "foo:void *";
|
||||
}
|
||||
char *foo(Foo *, int) {
|
||||
return (char *) "foo:Foo *,int";
|
||||
}
|
||||
char *foo(double, Bar *) {
|
||||
return (char *) "foo:double,Bar *";
|
||||
}
|
||||
|
||||
char *blah(double) {
|
||||
return (char *) "blah:double";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue