Commits

certainty  committed 6a7f49d

added sequence-generator added hgignore

  • Participants
  • Parent commits 499d49f

Comments (0)

Files changed (4)

+syntax: glob
+
+*.so
+*.import.so
+*.import.scm

File data-generators-impl.scm

             (ht (make-hash-table)))
            ((>= i size) ht)
          (hash-table-set! ht (key-gen) (value-gen)))))))
+
+(define-syntax gen->sequence
+  (syntax-rules ()
+    ((_ amount body0 ...)
+     (lambda (proc)
+       (do ((i 1 (add1 i)))
+           ((>= i amount))
+         (proc (begin body0 ...)))))))
+
+(define (run-sequence seq proc) (seq proc))

File data-generators.scm

    gen-bool gen-char gen-real gen-pair-of gen-list-of gen-alist-of gen-tuple-of gen-vector-of gen-string-of
    gen-fixnum gen-hash-table-of gen-sample-of
    make-sizer sizer/lb sizer/ub
-   between at-most at-least with-size)
+   between at-most at-least with-size gen->sequence run-sequence)
   (import chicken scheme)
   (use (prefix random-bsd bsd:)
        (only ports with-output-to-string)

File tests/run.scm

 (test-group "with-size"
     (test-assert "fixed size" (= 2 (length  (with-size 2 (gen-list-of gen-fixnum)))))
     (test-assert "range" (between? (length  (with-size (2 . 4) (gen-list-of gen-fixnum))) 2 4)))
+
+(test-group "gen->sequence"
+    (test-assert "generates a procedure" (procedure? (gen->sequence 2 (gen-list-of gen-fixnum))))
+    (let ((runs 1)
+          (seq (gen->sequence 3 (gen-list-of gen-fixnum))))
+      (test "applies proc amount times"
+            3
+            (begin
+              (seq (lambda (value) (set! runs (add1 runs))))
+              runs))))