PageRenderTime 13ms CodeModel.GetById 1ms app.highlight 9ms RepoModel.GetById 2ms app.codeStats 0ms

/trunk/Examples/test-suite/chicken/overload_simple_runme_proxy.ss

#
Scheme | 56 lines | 41 code | 11 blank | 4 comment | 0 complexity | 116bd903509a845dfd89b2968bf9a329 MD5 | raw file
 1(load "overload_simple.so")
 2
 3(define-macro (check test)
 4  `(if (not ,test) (error ',test)))
 5
 6(check (string=? (foo) "foo:"))
 7(check (string=? (foo 3) "foo:int"))
 8(check (string=? (foo 3.01) "foo:double"))
 9(check (string=? (foo "hey") "foo:char *"))
10
11(define f (make <Foo>))
12(define b (make <Bar>))
13(define b2 (make <Bar> 3))
14
15(check (= (slot-ref b 'num) 0))
16(check (= (slot-ref b2 'num) 3))
17
18(check (string=? (foo f) "foo:Foo *"))
19(check (string=? (foo b) "foo:Bar *"))
20(check (string=? (foo f 3) "foo:Foo *,int"))
21(check (string=? (foo 3.2 b) "foo:double,Bar *"))
22
23;; now check blah
24(check (string=? (blah 2.01) "blah:double"))
25(check (string=? (blah "hey") "blah:char *"))
26
27;; now check spam member functions
28(define s (make <Spam>))
29(define s2 (make <Spam> 3))
30(define s3 (make <Spam> 3.2))
31(define s4 (make <Spam> "whee"))
32(define s5 (make <Spam> f))
33(define s6 (make <Spam> b))
34
35(check (string=? (slot-ref s 'type) "none"))
36(check (string=? (slot-ref s2 'type) "int"))
37(check (string=? (slot-ref s3 'type) "double"))
38(check (string=? (slot-ref s4 'type) "char *"))
39(check (string=? (slot-ref s5 'type) "Foo *"))
40(check (string=? (slot-ref s6 'type) "Bar *"))
41
42;; now check Spam member functions
43(check (string=? (foo s 2) "foo:int"))
44(check (string=? (foo s 2.1) "foo:double"))
45(check (string=? (foo s "hey") "foo:char *"))
46(check (string=? (foo s f) "foo:Foo *"))
47(check (string=? (foo s b) "foo:Bar *"))
48
49;; check static member funcs
50(check (string=? (Spam-bar 3) "bar:int"))
51(check (string=? (Spam-bar 3.2) "bar:double"))
52(check (string=? (Spam-bar "hey") "bar:char *"))
53(check (string=? (Spam-bar f) "bar:Foo *"))
54(check (string=? (Spam-bar b) "bar:Bar *"))
55
56(exit 0)