PageRenderTime 47ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/full-test.scm

http://github.com/pablomarx/Thomas
Scheme | 126 lines | 83 code | 5 blank | 38 comment | 0 complexity | c59c9849502ce1dcb45be249e7b18226 MD5 | raw file
  1. ;* Copyright 1992 Digital Equipment Corporation
  2. ;* All Rights Reserved
  3. ;*
  4. ;* Permission to use, copy, and modify this software and its documentation is
  5. ;* hereby granted only under the following terms and conditions. Both the
  6. ;* above copyright notice and this permission notice must appear in all copies
  7. ;* of the software, derivative works or modified versions, and any portions
  8. ;* thereof, and both notices must appear in supporting documentation.
  9. ;*
  10. ;* Users of this software agree to the terms and conditions set forth herein,
  11. ;* and hereby grant back to Digital a non-exclusive, unrestricted, royalty-free
  12. ;* right and license under any changes, enhancements or extensions made to the
  13. ;* core functions of the software, including but not limited to those affording
  14. ;* compatibility with other hardware or software environments, but excluding
  15. ;* applications which incorporate this software. Users further agree to use
  16. ;* their best efforts to return to Digital any such changes, enhancements or
  17. ;* extensions that they make and inform Digital of noteworthy uses of this
  18. ;* software. Correspondence should be provided to Digital at:
  19. ;*
  20. ;* Director, Cambridge Research Lab
  21. ;* Digital Equipment Corp
  22. ;* One Kendall Square, Bldg 700
  23. ;* Cambridge MA 02139
  24. ;*
  25. ;* This software may be distributed (but not offered for sale or transferred
  26. ;* for compensation) to third parties, provided such third parties agree to
  27. ;* abide by the terms and conditions of this notice.
  28. ;*
  29. ;* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
  30. ;* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
  31. ;* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
  32. ;* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  33. ;* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  34. ;* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
  35. ;* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  36. ;* SOFTWARE.
  37. ; $Id: full-test.scm,v 1.2 1992/09/21 21:26:17 birkholz Exp $
  38. (define (display-simple-condition condition)
  39. (display (dylan-call dylan:condition-format-string condition))
  40. (do ((args (dylan-call dylan:condition-format-arguments condition)
  41. (cdr args)))
  42. ((null? args))
  43. (display " ") (write (car args))))
  44. (define (display-condition condition)
  45. (newline)
  46. (let ((condition-type (get-type condition)))
  47. (cond
  48. ((eq? condition-type <simple-error>)
  49. (display ";Error: ") (display-simple-condition condition))
  50. ((eq? condition-type <simple-warning>)
  51. (display ";Warning: ") (display-simple-condition condition))
  52. ((eq? condition-type <type-error>)
  53. (display ";Error: ")
  54. (write (dylan-call dylan:type-error-value condition))
  55. (display " is not an instance of ")
  56. (display (class.debug-name
  57. (dylan-call dylan:type-error-expected-type
  58. condition))))
  59. (else
  60. (display ";Unhandled dylan condition: ")
  61. (write condition)))))
  62. (define (make-expression preamble compiled-output)
  63. `(BEGIN
  64. ,@preamble
  65. (LET* ((!MULTIPLE-VALUES (VECTOR '()))
  66. (!RESULT ,compiled-output))
  67. (IF (EQ? !RESULT !MULTIPLE-VALUES)
  68. (LET RESULT-LOOP
  69. ((COUNT 1)
  70. (RESULTS (VECTOR-REF !MULTIPLE-VALUES 0)))
  71. (IF (PAIR? RESULTS)
  72. (LET ((RESULT (CAR RESULTS)))
  73. (NEWLINE)
  74. (DISPLAY ";Value[")(DISPLAY COUNT)(DISPLAY "]: ")
  75. (WRITE RESULT)
  76. (RESULT-LOOP (+ 1 COUNT) (CDR RESULTS)))
  77. (NEWLINE)))
  78. (BEGIN
  79. (NEWLINE)(DISPLAY ";Value: ")(WRITE !RESULT)(NEWLINE))))))
  80. (define (test file)
  81. (with-input-from-file file
  82. (lambda ()
  83. (let loop ((module-variables '()))
  84. (let ((sexpr (read)))
  85. (if (eof-object? sexpr)
  86. (begin
  87. (newline)
  88. (newline))
  89. (begin
  90. (pp sexpr)
  91. (loop
  92. ;; Return from here with new module-variables.
  93. (call-with-current-continuation
  94. (lambda (error-exit)
  95. (dylan::catch-all-conditions
  96. (lambda ()
  97. (dylan::handler-bind
  98. <condition> ; type
  99. (make-dylan-callable ; function
  100. (lambda (condition next-handler)
  101. next-handler
  102. (display-condition condition)
  103. (newline)
  104. (error-exit module-variables)))
  105. (make-dylan-callable ; test
  106. (lambda (condition)
  107. condition
  108. #T))
  109. (make-dylan-callable ; description
  110. (lambda (stream)
  111. (display "error handler from full-test.scm"
  112. stream)))
  113. (lambda ()
  114. (compile-expression
  115. sexpr '!MULTIPLE-VALUES module-variables
  116. (lambda (new-vars preamble compiled-output)
  117. (implementation-specific:eval
  118. (make-expression preamble compiled-output))
  119. (append new-vars module-variables)))))))))))))))))
  120. (define (test-dylan-examples) (test "dylan-examples.dyl"))