classes2.scm 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. (require <classes1>)
  2. ;; Test separate compilation of type alias of non-simple class.
  3. ;; Might as well make it a forward declaration.
  4. (define-alias cls-d <ClsD>)
  5. (define-class <ClsD> (<ClsB>)
  6. (d :: <int> init-form: 23))
  7. ; ((f (y :: <int>)) :: <int> (+ d y)))
  8. (define-class <ClsE> (<ClsC> <ClsD>)
  9. (e :: <int> init-form: 39)
  10. ((f (y :: int)) ::int throws: (java.lang.Exception)
  11. (+ 100 xx e y)))
  12. (define-class-using-syntax-rules <SimpleC> <SimpleB>
  13. (d :: <int> init-form: 23 init-keyword: d:)
  14. (e :: <int> init-form: 24))
  15. (define (make-simpleC ival) (make <SimpleC> i: ival))
  16. (define yy :: <int> 56)
  17. (define date-test-instance (make <DateTest>))
  18. (define-namespace date-test-ns <SimpleDateTest>)
  19. (define (make-date-test)
  20. (let ((d :: <SimpleDateTest> (date-test-ns:new)))
  21. d:year))
  22. ;; Test that we can make <TestCapture1> before <TestCapture1> is defined.
  23. (define (make-TestCapture1)
  24. (make <TestCapture1>))
  25. (define-simple-class <TestCapture1> ()
  26. (z :: <integer> init: 11)
  27. ((ff farg)
  28. (list
  29. (lambda (y) (list yy z y)))))
  30. (define-simple-class <TestCapture2> ()
  31. (z :: <integer> init: 12)
  32. ((ff farg)
  33. (list
  34. (lambda (y) (list yy y)))))
  35. ;; Test for Savannah bug #15151
  36. (define (getClassTest o) (slot-ref o 'class))
  37. (define (classes2-capture-test-a x)
  38. (let ((obj
  39. (object ()
  40. (action (list x (lambda (e) (- yy 10)))))))
  41. (slot-ref obj 'action)))
  42. (define (classes2-capture-test-b x)
  43. (let ((obj
  44. (object ()
  45. (y)
  46. (action (lambda (e) (+ yy 10))))))
  47. (slot-ref obj 'action)))
  48. (define my-id-instance-2 :: my-id-class-2
  49. (let ((ii :: my-id-class-2 (my-id-class-2)))
  50. ii))
  51. ;; Based on bug-report from Andrea Bernardini 2015-04-27:
  52. (define thunk (lambda (x) "thunk Initialized"))
  53. (define thunk-init
  54. (lambda (f)
  55. (set! thunk f)))
  56. (thunk-init (lambda (x) x))