PageRenderTime 45ms CodeModel.GetById 21ms RepoModel.GetById 0ms 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
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. (load "overload_simple.so")
  2. (define-macro (check test)
  3. `(if (not ,test) (error ',test)))
  4. (check (string=? (foo) "foo:"))
  5. (check (string=? (foo 3) "foo:int"))
  6. (check (string=? (foo 3.01) "foo:double"))
  7. (check (string=? (foo "hey") "foo:char *"))
  8. (define f (make <Foo>))
  9. (define b (make <Bar>))
  10. (define b2 (make <Bar> 3))
  11. (check (= (slot-ref b 'num) 0))
  12. (check (= (slot-ref b2 'num) 3))
  13. (check (string=? (foo f) "foo:Foo *"))
  14. (check (string=? (foo b) "foo:Bar *"))
  15. (check (string=? (foo f 3) "foo:Foo *,int"))
  16. (check (string=? (foo 3.2 b) "foo:double,Bar *"))
  17. ;; now check blah
  18. (check (string=? (blah 2.01) "blah:double"))
  19. (check (string=? (blah "hey") "blah:char *"))
  20. ;; now check spam member functions
  21. (define s (make <Spam>))
  22. (define s2 (make <Spam> 3))
  23. (define s3 (make <Spam> 3.2))
  24. (define s4 (make <Spam> "whee"))
  25. (define s5 (make <Spam> f))
  26. (define s6 (make <Spam> b))
  27. (check (string=? (slot-ref s 'type) "none"))
  28. (check (string=? (slot-ref s2 'type) "int"))
  29. (check (string=? (slot-ref s3 'type) "double"))
  30. (check (string=? (slot-ref s4 'type) "char *"))
  31. (check (string=? (slot-ref s5 'type) "Foo *"))
  32. (check (string=? (slot-ref s6 'type) "Bar *"))
  33. ;; now check Spam member functions
  34. (check (string=? (foo s 2) "foo:int"))
  35. (check (string=? (foo s 2.1) "foo:double"))
  36. (check (string=? (foo s "hey") "foo:char *"))
  37. (check (string=? (foo s f) "foo:Foo *"))
  38. (check (string=? (foo s b) "foo:Bar *"))
  39. ;; check static member funcs
  40. (check (string=? (Spam-bar 3) "bar:int"))
  41. (check (string=? (Spam-bar 3.2) "bar:double"))
  42. (check (string=? (Spam-bar "hey") "bar:char *"))
  43. (check (string=? (Spam-bar f) "bar:Foo *"))
  44. (check (string=? (Spam-bar b) "bar:Bar *"))
  45. (exit 0)