{"size": 1514, "ext": "rktl", "max_stars_repo_path": "gui-test/tests/gracket/testing.rktl", "max_stars_repo_name": "jjsimpso/gui", "max_stars_repo_stars_event_min_datetime": "2015-03-17T22:11:52.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-12T15:09:34.000Z", "max_issues_repo_path": "gui-test/tests/gracket/testing.rktl", "max_issues_repo_name": "jjsimpso/gui", "max_issues_repo_issues_event_min_datetime": "2015-01-09T15:53:25.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T16:21:29.000Z", "max_forks_repo_path": "gui-test/tests/gracket/testing.rktl", "max_forks_repo_name": "jjsimpso/gui", "max_forks_repo_forks_event_min_datetime": "2015-01-08T13:03:07.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-26T21:49:09.000Z"}
{"max_stars_count": 65, "max_issues_count": 231, "max_forks_count": 89, "avg_line_length": 23.65625, "max_line_length": 86, "alphanum_fraction": 0.5792602378}

;; GRacket automatic testing basic functions and macros

(require mzlib/class)

(define SECTION #t)

(define errs null)
(define test-count 0)

(define (test expect name got)
  (set! test-count (add1 test-count))
  (unless (equal? expect got)
    (let ([s (format "~a: expected ~e; got ~e" name expect got)])
      (fprintf (current-error-port) "ERROR: ~a\n" s)
      (set! errs (cons s errs)))))

(define-syntax mismatch
  (lambda (stx)
    (syntax-case stx ()
      [(_ expr)
       (syntax
	(test 'was-mismatch 'mismtach
	      (with-handlers ([exn:fail:contract?
			       (lambda (x)
                                 (printf "~a\n" (exn-message x))
				 'was-mismatch)]
			      [exn:fail? values])
		expr)))])))

(define-syntax st
  (lambda (stx)
    (syntax-case stx ()
      [(_ val obj method . args)
       (syntax
	(test val 'method (send obj method . args)))])))

(define-syntax stv
  (lambda (stx)
    (syntax-case stx ()
      [(_ . args)
       (syntax (st (void) . args))])))

(define-syntax stvals
  (lambda (stx)
    (syntax-case stx ()
      [(_ vals obj method . args)
       (syntax
	(test vals 'method (call-with-values (lambda () (send obj method . args)) list)))])))

(define (report-errs)
  (flush-output)
  (sleep 1)
  (newline)
  (if (null? errs)
      (printf "Passed all ~a tests\n" test-count)
      (begin
	(fprintf (current-error-port) "~a Error(s) in ~a tests\n" (length errs) test-count)
	(for-each
	 (lambda (s)
	   (fprintf (current-error-port) "~a\n" s))
	 (reverse errs)))))

