On 2/23/18 3:36 PM, 'Paulo Matos' via Racket Users wrote:

On 23/02/18 15:13, 'Paulo Matos' via Racket Users wrote:
That's true, thanks for pointing it out. I only just noticed you could
generate test-suites and test-cases at runtime with make-testcase and
make-testsuite. Therefore I will actually be doing this without a macro.
However, it's always very useful to attempt this macro katas. :)


I will take that back. There is a make-test-suite but not a
make-test-case. Since test-case is syntax, I don't think there's a way
to programmatically create a list of test-cases, put them in a test
suite and later run them.

I tried
#lang racket

(require rackunit)

(define (make-suite n)
  (make-test-suite
   (format "Testsuite of ~a tests" n)
   (for/list ([i (in-range n)])
     (test-case (format "test ~a" i)
                (check = i i)))))

(define s (make-suite 100))

(require rackunit/text-ui)
(run-tests s)

But this doesn't actually work. I think I really need to stick to the
macro stuff.

You can write `make-suite` like this:

  (define (make-suite n)
    (test-suite
      (format "Testsuite of ~a tests" n)
      (for ([i (in-range n)])
        (test-case (format "test ~a" i)
          (check = i i)))))

Ryan

--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to