1. David Krentzlin
  2. data-generators

Commits

certainty  committed 4fa758c

added gen-keyword

  • Participants
  • Parent commits 1c356d6
  • Branches default

Comments (0)

Files changed (3)

File data-generators-impl.scm

View file
  • Ignore whitespace
 
 (define gen-symbol gen-symbol-of)
 
+(define gen-keyword-of
+  (case-lambda
+    (()
+     (gen-keyword-of (gen-char char-set:letter+digit)))
+    ((char-gen)
+     (gen-transform string->keyword (gen-string-of char-gen)))))
+
+(define gen-keyword gen-keyword-of)
+
 (define gen-vector-of
   (case-lambda
     ((gen) (gen-vector-of gen (gen-current-default-size)))

File data-generators.scm

View file
  • Ignore whitespace
    generator <- gen-for-each register-generator-for-type! gen
    gen-constant  gen-int8 gen-uint8 gen-int16 gen-uint16 gen-int32 gen-uint32 gen-int64 gen-uint64 fixnums even-fixnums odd-fixnums flonums
    gen-bool booleans gen-series gen-char chars gen-fixnum gen-even-fixnum gen-odd-fixnum gen-real gen-sample gen-sample-of gen-pair-of gen-tuple-of
-   gen-list-of gen-alist-of gen-vector-of gen-string-of gen-symbol-of gen-symbol gen-hash-table-of gen-record gen-values-of gen-transform
+   gen-list-of gen-alist-of gen-vector-of gen-string-of gen-symbol-of gen-symbol gen-keyword-of gen-keyword gen-hash-table-of gen-record gen-values-of gen-transform
    with-size range size-spec->gen)
   (import chicken scheme)
   (use (prefix random-bsd bsd:)

File tests/run.scm

View file
  • Ignore whitespace
             (test-assert "produces a symbol"
                          (symbol? (<- (gen-symbol-of)))))
 
+(test-group "gen-keyword"
+            (test-assert "produces keyword"
+                         (keyword? (<- (gen-keyword)))))
+
 (test-group "gen-hash-table-of"
     (test-assert "produces a hash-table"
                  (hash-table? (<- (gen-hash-table-of (gen-fixnum) (gen-fixnum)))))