PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/schemerunme/li_typemaps_proxy.scm

#
Lisp | 45 lines | 20 code | 6 blank | 19 comment | 0 complexity | 753ae387ff2e830f1404efda22ba7560 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. (define-macro (check func val test)
  2. (cons 'begin
  3. (map
  4. (lambda (x)
  5. `(if (not (,test (,(string->symbol (string-append x func)) ,val) ,val))
  6. (error ,(string-append "Error in test " x func))))
  7. (list "in-" "inr-" "out-" "outr-" "inout-" "inoutr-"))))
  8. (define (=~ a b)
  9. (< (abs (- a b)) 1e-5))
  10. (check "bool" #t and)
  11. (check "int" -2 =)
  12. (check "long" -32 =)
  13. (check "short" -15 =)
  14. (check "uint" 75 =)
  15. (check "ushort" 123 =)
  16. (check "ulong" 462 =)
  17. ;(check "uchar" 16 =)
  18. ;(check "schar" -53 =)
  19. (check "float" 4.3 =~)
  20. (check "double" -175.42 =~)
  21. (check "longlong" 1634 =)
  22. (check "ulonglong" 6432 =)
  23. ;; The checking of inoutr-int2 and out-foo is done in the individual
  24. ;; language runme scripts, since chicken returns multiple values
  25. ;; and must be checked with call-with-values, while guile just returns a list
  26. ;(call-with-values (lambda () (inoutr-int2 3 -2))
  27. ; (lambda (a b)
  28. ; (if (not (and (= a 3) (= b -2)))
  29. ; (error "Error in inoutr-int2"))))
  30. ;(call-with-values (lambda () (out-foo 4))
  31. ; (lambda (a b)
  32. ; (if (not (and (= (slot-ref a 'a) 4) (= b 8)))
  33. ; (error "Error in out-foo"))))
  34. ;(let ((lst (inoutr-int2 3 -2)))
  35. ; (if (not (and (= (car lst) 3) (= (cadr lst) -2)))
  36. ; (error "Error in inoutr-int2")))
  37. ;(let ((lst (out-foo 4)))
  38. ; (if (not (and (= (slot-ref (car lst) 'a) 4) (= (cadr lst) 8)))
  39. ; (error "Error in out-foo")))