module3.scm 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. (module-static #t)
  2. (require <module1>)
  3. (module-export dvar-test-1 factorial-4 check-fluid-let *VAR* check-thunk
  4. namespace-syntax-call list-length-4 my-compare test3-import2
  5. test3-import1 get3-mod0-v2 set3-mod0-v2 counter-test-result
  6. pa-new pa-getter pa-setter pa-length iarr-set mB test1-import0
  7. macro2 all-zeros misc-ints)
  8. (define (get3-mod0-v1) :: <object> mod0-v1)
  9. (define (set3-mod0-v1 x) (set! mod0-v1 x))
  10. (define (get3-mod0-v2) :: <object> mod0-v2)
  11. (define (set3-mod0-v2 x) (set! mod0-v2 x))
  12. (define (test3-import1)
  13. (let ((gv1 (get3-mod0-v1)))
  14. (set3-mod0-v1 (- gv1 9))
  15. (list gv1 mod0-v1 mod0-v2 (mod0-f1) (mod0-m1))))
  16. ;; This didn't use to compile, because of macro expansion problems.
  17. (define (test3-import2)
  18. (mod0-m1))
  19. (define factorial-4 (my-factorial 4))
  20. (define (list-length-4 arg)
  21. (list-length-2 arg))
  22. ;; Test for Savannah bug #4289
  23. (define (pa-getter data index)
  24. (let ((getter (primitive-array-get <java.lang.Object>)))
  25. (getter data index)))
  26. (define (pa-setter data index val)
  27. (let ((setter (primitive-array-set <java.lang.Object>)))
  28. (setter data index val)))
  29. (define (pa-length data)
  30. (let ((lengther (primitive-array-length <java.lang.Object>)))
  31. (lengther data)))
  32. (define (pa-new size)
  33. (let ((newer (primitive-array-new <java.lang.Object>)))
  34. (newer size)))
  35. (define (namespace-syntax-call)
  36. (namespace-syntax-test))
  37. ;; Test for Savannah bug #5651
  38. (define (iarr-set (array :: <int[]>) (index :: <int>) (value :: <int>))
  39. (let ((setter (primitive-array-set <int>)))
  40. (setter array index value)))
  41. (define-variable dvar1
  42. (with-compile-options warn-undefined-variable: #f
  43. (+ (get-mod0-v1) 1))) ;; 11
  44. (define-variable dvar2)
  45. (define-variable dvar3 13)
  46. (define dvar-test-1
  47. (with-compile-options warn-undefined-variable: #t
  48. (list dvar1 dvar2 dvar3)))
  49. (define-namespace timestamp "class:MyTimestamp")
  50. ;; This also works: (define-alias timestamp <MyTimestamp>)
  51. ;; but not (intentionally): (define-alias timestamp "class:MyTimestamp")
  52. (define (my-compare a b)
  53. ((as timestamp a):myCompareTo (as <MyTimestamp> b)))
  54. ;; Test for Savannah bug #11578
  55. (define *VAR* 'A)
  56. (define (get-var) *VAR*)
  57. (define (check-fluid-let sym)
  58. (fluid-let ((*VAR* sym))
  59. (get-var)))
  60. ;; Based on Savannah bug#11822, contributed by Dean Ferreyra.
  61. ;; (Other parts of this testcase are in module1.scm and obj-test.scm.)
  62. (define-namespace simpleAux <simpleAux>)
  63. (define-syntax mB
  64. (syntax-rules ()
  65. ((_ type name)
  66. (mA type
  67. ((fn o)
  68. (simpleAux:init o)
  69. (list (slot-ref o 'x) name))))))
  70. ;; Andre van Tonder <andre@het.brown.edu> example in posting 2011-04-19.
  71. (define counter-test-result
  72. (let* ((a (counter-macro))
  73. (b (counter)))
  74. (list a b)))
  75. ;; Test for Savannah bug #34004: Nullpointer exception in compiler
  76. (define (call-thunk thunk::procedure)
  77. (thunk))
  78. (define (call-call-thunk x)
  79. (call-thunk (lambda () x)))
  80. (define (check-thunk)
  81. (call-call-thunk 1))
  82. (define-syntax macro1
  83. (syntax-rules ()
  84. ((macro1 name)
  85. (define-syntax name
  86. (syntax-rules ()
  87. ((name) dvar3))))))
  88. (macro1 macro2)
  89. (define (all-zeros) '#1=(0 . #1#))
  90. (define misc-ints
  91. (vector 2147483648 21474836482147483648 #x7fffffff #x80000000 -1073741825 -1073741824 -1073741823))