diff options
author | Shiro Kawai <shiro@acm.org> | 2024-03-06 09:41:59 -1000 |
---|---|---|
committer | Shiro Kawai <shiro@acm.org> | 2024-03-06 09:41:59 -1000 |
commit | f73fe7e76c390d46e3329bee5e27aedde5bad767 (patch) | |
tree | cec87b81d2f452df7f48f3ea373f6ea5de7a51cd | |
parent | 9550396e5c7849018eb00b91ef31d56a45c071df (diff) |
Start adding srfi-252
It's still draft; things may change later.
-rw-r--r-- | lib/srfi/252.scm | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/lib/srfi/252.scm b/lib/srfi/252.scm new file mode 100644 index 000000000..24a0117c7 --- /dev/null +++ b/lib/srfi/252.scm @@ -0,0 +1,66 @@ +;;; +;;; SRFI-252 - Property testing +;;; +;;; Copyright (c) 2024 Shiro Kawai <shiro@acm.org> +;;; +;;; Redistribution and use in source and binary forms, with or without +;;; modification, are permitted provided that the following conditions +;;; are met: +;;; +;;; 1. Redistributions of source code must retain the above copyright +;;; notice, this list of conditions and the following disclaimer. +;;; +;;; 2. Redistributions in binary form must reproduce the above copyright +;;; notice, this list of conditions and the following disclaimer in the +;;; documentation and/or other materials provided with the distribution. +;;; +;;; 3. Neither the name of the authors nor the names of its contributors +;;; may be used to endorse or promote products derived from this +;;; software without specific prior written permission. +;;; +;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +;;; TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +;;; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +;;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +;;; + +(define-module srfi.252 + (use gauche.generator) + (use data.random) + (export + boolean-generator + bytevector-generator + char-generator + string-generator + symbol-generator) + ) +(select-module srfi.252) + +;; Generators + +(define-constant sequence-max-size 33) + +(define (boolean-generator) (gcons* #t #f (boolleans$))) + +(define (bytevector-generator) + (gcons* '#u8() + (sequences-of <u8vector> + (integers$ sequence-max-size) + (integers$ 256)))) + +(define (char-generator) (gcons* #\null (chars$ char-set:full))) + +(define (string-generator) + (gcons* "" "\x00;" + (strings-of (integers$ sequence-max-size) (chars$ char-set:full)))) + +(define (symbol-generator) + (gmap string->symbol (strings-of (integers$ sequence-max-size) + (chars$ char-set:full)))) |