diff --git a/examples/simple-counter/simple_counter_tb.utest b/examples/simple-counter/simple_counter_tb.utest index 7ce5af6..e01b5f4 100644 --- a/examples/simple-counter/simple_counter_tb.utest +++ b/examples/simple-counter/simple_counter_tb.utest @@ -1,27 +1,9 @@ ;; -*- scheme -*- -;;; Make lists combinations -;;; Example: (combinations '(1 2 3) '(a b)) -> '((1 a) (1 b) (2 a) (2 b) (3 a) (3 b)) -(define (combinations . lists) - (cond - ((null? lists) '()) - ((null? (cdr lists)) (car lists)) - (else - (fold (lambda (comb out) - (append out - (map (lambda (x) - (if (list? comb) - (cons x comb) - (list x comb))) - (car lists)))) - '() (apply combinations (cdr lists)))))) - ;;; Testbenches -(map - (lambda (l) - (let ((count (car l)) - (direction (cadr l))) - (utest/tb +(utest/map-comb + (count direction) + (utest/tb ((format "c~a_d~a" count direction) "More complex testbench for Simple Counter" (format "COUNT=~a\tDIRECTION=~a" count direction)) @@ -35,10 +17,8 @@ "simple_counter_tb" #:parameters `((COUNT ,count) (ITERATIONS ,(* count 3)) - (DIRECTION ,direction)))))) - - (combinations - (append '(10 100 1000 16 64 256) + (DIRECTION ,direction)))) + (append '(10 100 1000 16 64 256) (let ((state (seed->random-state 0))) (map (lambda (x) (+ 2 (random 200 state))) (iota 100)))) - '(1 -1 0))) + '(1 -1 0)) diff --git a/utest.scm b/utest.scm index 702e1c5..c901402 100755 --- a/utest.scm +++ b/utest.scm @@ -967,6 +967,18 @@ ((_ () body ...) (utest/tb (#f) body ...)))) +;;; +;;; Map combinations macro +;;; +(define-syntax utest/map-comb + (syntax-rules () + ((_ (args ...) (body ...) lists ...) + (apply + map + (lambda (args ...) (body ...)) + (transpose + (combinations lists ...)))))) + ;;; ;;; Delete working folders ;;;