From a7d0e687e86222e3b2d1de4eb3299d935105cf4d Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Thu, 17 Aug 2017 12:13:57 +0100 Subject: [PATCH] [functional-tests] start a (generators) library --- functional-tests/generators.scm | 18 ++++++++++++++++++ functional-tests/thin-xml.scm | 19 ++++--------------- 2 files changed, 22 insertions(+), 15 deletions(-) create mode 100644 functional-tests/generators.scm diff --git a/functional-tests/generators.scm b/functional-tests/generators.scm new file mode 100644 index 0000000..f2981e5 --- /dev/null +++ b/functional-tests/generators.scm @@ -0,0 +1,18 @@ +(library + (generators) + + (export make-const-generator + make-uniform-generator) + + (import (rnrs) + (srfi s27 random-bits)) + + (define (make-const-generator n) + (lambda () n)) + + (define (make-uniform-generator low hi) + (assert (<= low hi)) + + (let ((range (- hi low))) + (lambda () + (+ low (random-integer range)))))) diff --git a/functional-tests/thin-xml.scm b/functional-tests/thin-xml.scm index c679318..c439e62 100644 --- a/functional-tests/thin-xml.scm +++ b/functional-tests/thin-xml.scm @@ -3,23 +3,12 @@ (export generate-xml) (import (rnrs) (list-utils) + (generators) (xml) (fmt fmt) (only (srfi s1 lists) iota) (srfi s27 random-bits)) - ;;;---------------------------------------- - - (define (make-const-generator n) - (lambda () n)) - - (define (make-uniform-generator low hi) - (assert (<= low hi)) - - (let ((range (- hi low))) - (lambda () - (+ low (random-integer range))))) - (define (div-down n d) (floor (/ n d))) @@ -30,9 +19,9 @@ (creation-time . 0) (snap-time . 0)) (tag 'range_mapping `((origin-begin . 0) - (data-begin . ,data-offset) - (length . ,nr-mappings) - (time . 1))))) + (data-begin . ,data-offset) + (length . ,nr-mappings) + (time . 1))))) (define (generate-xml max-thins max-mappings) (let ((nr-thins ((make-uniform-generator 1 max-thins)))