xtmtest   macro


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/runtime/scheme.xtm

Implementation

;; some tests are supposed to fail compilation (type check catch for example)
;; by passing 'copmile-should-fail as expected-result the failure will be marked as success
(define-macro (xtmtest form call . expected-result)
  `(let ((func-sym (quote ,(car call)))
         (exp-res ,(if (null? expected-result)
                       #f
                       (car expected-result))))
     (print-with-colors 'cyan 'default #t (print "xtmtest "))
     (print-with-colors 'black 'cyan #t (print "" func-sym ""))
     (println)
     (catch (if (and (symbol? exp-res)
                     (equal? exp-res 'compile-should-fail))
                (xtmtest-update-test-result func-sym 'correct ',call #f #f)
                (xtmtest-update-test-result func-sym 'no-compile ',call #f #f))
            (eval ',form (interaction-environment))
            (catch (xtmtest-update-test-result func-sym 'compile ',call #f #f)
                   (let ((result (eval ',call (interaction-environment))))
                     (if (or (not exp-res) (equal? exp-res result))
                         (xtmtest-update-test-result func-sym 'correct ',call exp-res result)
                         (xtmtest-update-test-result func-sym 'incorrect ',call exp-res result)))))))


Back to Index

Similar Entries

  • xtmtest    macro
  • xtmtest-compile    macro
  • xtmtest-compile    macro
  • xtmtest-print-results    scheme
  • xtmtest-print-results    scheme
  • xtmtest-reset-results    scheme
  • xtmtest-reset-results    scheme
  • xtmtest-result    macro
  • xtmtest-result    macro
  • xtmtest-result-body    scheme
  • xtmtest-result-body    scheme
  • xtmtest-run-tests    scheme
  • xtmtest-run-tests    scheme
  • xtmtest-update-test-result    scheme
  • xtmtest-update-test-result    scheme
  • xtmtest-with-fixture    macro
  • xtmtest-with-fixture-body    scheme
  • xtmtest-with-fixture-body    scheme