Skip to content

ApollonDeParnasse/generate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

generate

  • This packages includes a host random data generators for almost every Emacs Lisp data type.
  • This package also includes a wrapper for the ert-deftest macro called generate-ert-deftest-n-times.
  • Finally this package includes two new test-runners: `generate-run-tests-batch’ and `generate-run-tests-batch-and-exit’. Those functions drop in replacement for `ert-run-tests-batch’ and `ert-run-tests-batch-and-exit’.

Why?

Naming Conventions

generate-random-x:

  • no arguments, e.g., generate-random-vector, generate-random-string, generate-random-boolean

generate-x-of-n-y:

  • one argument, N, the number of y’s that you want in type x, e.g., generate-list-of-n-strings, generate-list-of-n-symbols, generate-list-of-n-lisp-timestamp-ranges

generate-x-y:

optional keywords arguments, e.g., [:max-length INTEGER] [:min-length INTEGER] [:exact-length INTEGER], generate-list-of-nat-numbers, generate-list-of-floats, generate-list-of-nat-numbers-in-range

customs

(defcustom generate-lisp-timestamp-range-size generate--SECONDS-IN-A-YEAR
  "The size of the range from which random timestamps will be taken."
  :group 'generate
  :type 'natnum)

macros

test-runner

generate-ert-deftest-n-times

;;;###autoload
(cl-defmacro generate-ert-deftest-n-times (name () &body docstring-keys-and-body)
  "Define NAME (a symbol) as a `ert-deftest' n times where n = NUM-RUNS.
NUM-RUNS can be specified as a keyword argument in addition to
the normal values of DOCSTRING-KEYS-AND-BODY.
If NUM-RUNS is not specified, your test will be defined 100 times.

\(fn NAME () [DOCSTRING] [:expected-result RESULT-TYPE] \
[:tags \\='(TAG...)] [:num-runs INTEGER] BODY...)"
  (declare (debug (&define [&name "test@" symbolp]
                           sexp [&optional stringp]
                           [&rest keywordp sexp]
                           def-body))
           (doc-string 3)
           (indent 2))
  (let ((run-symbol (gensym)))
    (cl-destructuring-bind
        (&key
         (documentation nil documentation-supplied-p)
         (expected-result nil expected-result-supplied-p)
         (tags nil tags-supplied-p)
         (num-runs 100)
         (body nil))
        (generate--parse-keys-and-body docstring-keys-and-body)
      `(cl-macrolet ((skip-when (form) `(ert--skip-when ,form))
                     (skip-unless (form) `(ert--skip-unless ,form)))
         (dotimes (,run-symbol ,num-runs)
           (ert-set-test (intern (format "%s-%s-%s" ',name generate--TEST-IDENTIFIER ,run-symbol))
                         (make-ert-test
                          :name (intern (format "%s-%s-%s" ',name generate--TEST-IDENTIFIER ,run-symbol))
                          ,@(when documentation-supplied-p
                              `(:documentation ,documentation))
                          ,@(when expected-result-supplied-p
                              `(:expected-result-type ,expected-result))
                          ,@(when tags-supplied-p
                              `(:tags ,tags))
                          :body (lambda () ,body nil)
                          :file-name ,(or (macroexp-file-name) buffer-file-name))))))))

Utilities

generators

numbers

generate-random-float-between-0-and-1

(defun generate-random-float-between-0-and-1 ()
  "Returns a float that is greater than 0 and less than 1."
  (funcall (-compose #'generate--convert-calc-value-into-lisp #'math-random-float)))

generate-random-nat-number-in-range

(cl-defun generate-random-nat-number-in-range ((min max))
  "Returns a random number that is greater than or equal to MIN less than MAX.
In other words, use an exclusive range: [MIN, MAX)"
  (if (eql min max)
      min
    (generate--non-zero-bounded-modular-addition (list min max) 0 (generate--random-nat-number))))

generate-two-random-nat-numbers-in-range

(cl-defun generate-two-random-nat-numbers-in-range ((min max))
  "Returns two random numbers that are greater than or equal to MIN less than MAX."
  (thunk-let* ((rand-one (generate-random-nat-number-in-range (list min max)))
               (distance-from-min (- rand-one min))
               (distance-from-max (- max rand-one))
               (min-max (if (> distance-from-max distance-from-min) (list (1+ rand-one) max) (list min (1- rand-one))))
               (rand-two (generate-random-nat-number-in-range min-max)))
    (if (eql min max)
        (list min min)
      (list rand-one rand-two))))

generate-two-sorted-random-nat-numbers-in-range

(defalias 'generate-two-sorted-random-nat-numbers-in-range (-compose #'sort #'generate-two-random-nat-numbers-in-range)  "Returns two sorted random numbers.
Each number will be that are greater than or equal to MIN less than MAX.

\(fn RANGE)")

generate-random-nat-number

(defalias 'generate-random-nat-number (apply-partially #'generate-random-nat-number-in-range generate--NATURALNUMBERS) "Returns a random natural number.")

generate-random-nat-number-twice

(defalias 'generate-random-nat-number-twice (apply-partially #'generate--times-no-args-twice #'generate-random-nat-number)
  "Returns two random natural numbers.")

generate-random-nat-number-string

(defalias 'generate-random-nat-number-string (-compose #'number-to-string #'generate-random-nat-number) "Returns a random natural number as a string.")

generate-random-negative-number

(defalias 'generate-random-negative-number (apply-partially #'generate-random-nat-number-in-range generate--NEGATIVENUMS) "Returns a random negative number.")

generate-random-float

(defalias 'generate-random-float (-compose #'generate--divide-by-random-value #'generate--random-nat-number-in-range-255)  "Returns a random float.")

generate-random-float-string

(defalias 'generate-random-float-string (-compose #'number-to-string #'generate-random-float) "Returns a random float as a string.")

meta generators

generate-call-function-random-times

(defun generate-call-function-random-times (func)
  "Call a FUNC a random amount of times.

\(fn FUNCTION)"
  (generate--times-no-args (generate--random-nat-number-in-range-10) func))

generate-call-each-function-random-times

(defalias 'generate-call-each-function-random-times (apply-partially #'mapcar #'generate-call-function-random-times) "Call each FUNC in LIST a random amount of times.
The results will be collected into a list.

\(fn LIST)")

generate-call-random-function

(defalias 'generate-call-random-function (-compose #'funcall #'generate-seq-take-random-value-from-seq) "Take a random function from LIST, call it and then return the result.

\(fn LIST)")

generate-call-random-function-n-times

(defun generate-call-random-function-n-times (n list)
  "Take a random function from LIST and call it N times.

\(fn INTEGER LIST)"
  (funcall (-compose (apply-partially #'generate--times-no-args n) #'generate-seq-take-random-value-from-seq) list))

generate-call-random-function-random-times

(defalias 'generate-call-random-function-random-times (-compose #'generate-call-function-random-times #'generate-seq-take-random-value-from-seq) "Take a random function from LIST and call it a random amount of times.
The results will be collected into a list.

\(fn LIST)")

generate-apply-random-function-to-single-arg

(defun generate-apply-random-function-to-single-arg (list args)
  "Take a random function from LIST and apply it on ARGS.

\(fn LIST LIST)"
  (funcall (-compose (lambda (func) (apply func args)) #'generate-seq-take-random-value-from-seq) list))

generate-apply-random-function-to-rest-args

(defun generate-apply-random-function-to-rest-args (list &rest args)
  "Take a random function from LIST and funcall it with ARGS.

\(fn LIST LIST)"
  (funcall (-compose (lambda (func) (apply func args)) #'generate-seq-take-random-value-from-seq) list))

generate-call-n-random-functions

(defun generate-call-n-random-functions (n funcs)
  "Take N random FUNCS from LIST and call them."
  (funcall (-compose (apply-partially #'-map #'funcall) (apply-partially #'-take n) #'generate-shuffle-list) funcs))

generate-random-cl-constantly

  • just
(defalias 'generate-random-cl-constantly (-compose (-juxt #'cl-constantly #'identity) #'number-to-string #'generate--random-nat-number) "Returns a random cl-constantly and the value that it will return when called.")

generate-default-convert-n-gen-to-random

(defun generate-default-convert-n-gen-to-random (generator-function)
  "Converts a GENERATOR-FUNCTION into a random generator.
GENERATOR-FUNCTION should only take one argument, N, the number of values
that will be generated."
  (-compose generator-function #'generate--random-nat-number-in-range-1-to-25))

generate-default-convert-n-gen-to-random-with-arg

(defalias 'generate-default-convert-n-gen-to-random-with-arg (generate--convert-n-gen-to-random-with-arg #'generate--random-nat-number-in-range-1-to-25)
  "Converts a GENERATOR-FUNCTION into a random generator.
GENERATOR-FUNCTION should only take two arguments.
The first argument should correspond to the the number of values
that will be generated. The second argument can be anything.")

ranges

generate-nat-number-range

(defun generate-nat-number-range (size)
  "Returns a random n SIZE range.

\(fn INTEGER)"
  (funcall (-juxt #'identity (apply-partially #'+ size))
           (generate--random-nat-number)))

generate-random-nat-number-range

(defalias 'generate-random-nat-number-range (generate-default-convert-n-gen-to-random #'generate-nat-number-range))

seq

extensions

generate-seq-take-random-value

(defalias 'generate-seq-take-random-value (-compose #'generate--seq-take-one #'generate-seq-shuffle) "Returns a list with one random value from SEQ.

\(fn SEQ)")

generate-seq-take-random-value-from-seq

  • alist of nat-numbers
(defalias 'generate-seq-take-random-value-from-seq (-compose #'seq-first #'generate-seq-take-random-value) "Returns one random value from SEQ.

\(fn SEQ)")

generate-seq-two-random-values

(defalias 'generate-seq-two-random-values (-compose #'generate--seq-take-two #'generate-seq-shuffle) "Returns a list with two random values from SEQ.

\(fn SEQ)")

generate-seq-random-chunk-length

(defun generate-seq-random-chunk-length (seq)
  "Returns a random chunk length for SEQ.
The value is guaranteed to be greater than
or equal to 1 and less than the length of SEQ."
  (let ((max-length (max 1 (floor (seq-length seq) 2))))
    (if (equal max-length 1) 1 (generate--random-nat-number-between-1-and max-length))))

generate-seq-random-chunk-of-size-n

(defun generate-seq-random-chunk-of-size-n (chunk-length seq)
  "Returns a random chunk of size CHUNK-LENGTH from SEQ."
  (let* ((chunks (seq-split seq chunk-length))
         (correct-chunks (seq-filter (-rpartial #'length= chunk-length) chunks)))
    (generate-seq-take-random-value-from-seq correct-chunks)))

generate-seq-random-chunk

(defalias 'generate-seq-random-chunk (-compose #'generate--applify-seq-random-chunk-of-size-n (-juxt #'generate-seq-random-chunk-length #'identity)) "Returns a random chunk of from SEQ.

The length of chunk will be greater than or equal to 1
and less than the length of SEQ.

\(fn SEQ)")

generate-seq-random-position

(defalias 'generate-seq-random-position (-compose #'generate--random-nat-number-between-0-and #'seq-length) "Returns a random position from SEQ.

\(fn SEQ)")

generate-seq-split-random

(defalias 'generate-seq-split-random (-compose #'generate--applify-seq-split (-juxt #'identity #'generate-seq-random-chunk-length)) "Splits a SEQ into random chunks of random size.

\(fn SEQ)")

generate-seq-n-random-values

(defun generate-seq-n-random-values (n seq)
  "Returns N random values from SEQ."
  (funcall (-compose (-rpartial #'seq-take n) #'generate-seq-shuffle) seq))

generate-seq-random-values

(defun generate-seq-random-values (seq)
  "Returns a random number of values from SEQ."
  (funcall (-compose (-rpartial #'generate-seq-n-random-values seq) #'generate-seq-random-chunk-length) seq))

generate-seq-random-value-with-position

(defalias 'generate-seq-random-value-with-position (-compose (-juxt #'generate--applify-seq-elt-flipped #'seq-first) (-juxt #'generate-seq-random-position #'identity)) "Returns a random item with its position from SEQ.

\(fn SEQ)")

generate-seq-take-infinite

base
(cl-defgeneric generate-seq-take-infinite (n seq)
  "Take N values from SEQ.
When n is larger than the length of SEQ, we loop back around."
  (funcall (-compose (-rpartial #'seq-take n) #'-cycle) seq))
vector
(cl-defmethod generate-seq-take-infinite (n (seq vector))
  "Take N values from SEQ.
When n is larger than the length of SEQ, we loop back around."
  (funcall (-compose #'seq--into-vector (-rpartial #'seq-take n) #'-cycle) seq))
string
(cl-defmethod generate-seq-take-infinite (n (seq string))
  "Take N values from SEQ.
When n is larger than the length of SEQ, we loop back around."
  (funcall (-compose #'seq--into-string (-rpartial #'seq-take n) #'-cycle) seq))

generate-seq-shuffle

base implementation
(cl-defgeneric generate-seq-shuffle (seq)
  "Returns a shuffled SEQ."
  (generate-shuffle-list seq))
for vectors
(cl-defmethod generate-seq-shuffle ((seq vector))
  "Returns a shuffled SEQ (vector)."
  (funcall (-compose #'seq--into-vector #'generate-shuffle-list #'seq--into-list) seq))
for strings
(cl-defmethod generate-seq-shuffle ((seq string))
  "Returns a shuffled SEQ (string)."
  (funcall (-compose #'seq--into-string #'generate-shuffle-list #'seq--into-list) seq))

generate-seq-subseq-infinite

(defun generate-seq-subseq-infinite (seq start end)
  "Return the elements of SEQ from START to END.
END is exclusive.  If END is omitted,
it defaults to the length of the sequence.
If START or END is negative, we counts from the end.
If END is greater than the length of the list,
we wrap back around."
  (cond
   ((or (cl-minusp start) (cl-minusp end))
    (error "Positions can not be negative"))
   ((> start end)
    (error "Start can not be greater than end"))
   (t
    (let* ((length (seq-length seq)))
      (if (> end length)
          (funcall (-compose (-rpartial #'seq-subseq start end) (-rpartial #'generate-seq-take-infinite seq) (apply-partially #'+ length) (apply-partially #'- end)) length)
        (seq-subseq seq start end))))))

generate-seq-n-random-infinite-subseqs

(defun generate-seq-n-random-infinite-subseqs (n seq)
  "Returns N random subseqs from SEQ.
The length of the subseqs from may be longer
than the length of SEQ."
  (let* ((lengths (generate-data :exact-length n :item-transformer (apply-partially #'generate--non-zero-bounded-modular-addition generate--FIVERANGE 1)))
         (sum-of-lengths (-sum lengths))
         (lengths-butlast (generate--seq-butlast lengths))
         (sum-of-lengths-butlast (-sum lengths))
         (seq-to-slice-length (seq-length seq))
         (slice-lengths (if (< sum-of-lengths seq-to-slice-length) (append lengths-butlast (list (- seq-to-slice-length sum-of-lengths-butlast))) lengths))
         (slice-ends (or (generate--seq-cdr (-running-sum slice-lengths))))
         (first-slice-end (seq-first slice-ends))
         (initial-value (list (list (generate-seq-subseq-infinite seq 0 first-slice-end)) first-slice-end)))
    (seq-first (seq-reduce (apply-partially #'generate--seq-n-random-subseqs-reducer seq) slice-ends initial-value))))

generate-seq-split-infinite

(defun generate-seq-split-infinite (length seq)
  "Split SEQ into a list of sub-sequences.
LENGTH will be the length of each sub-sequence.
If LENGTH is greater than the actual length
of the list, we wrap back around."
  (let* ((start-index (1- (seq-length seq)))
         (seq-to-reduce (generate--seq-butlast seq))
         (initial-value (generate-seq-subseq-infinite seq (* start-index length) (* (1+ start-index) length))))
    (generate--seq-reduce-right-indexed
     (lambda (_ acc index)
       (append (list (generate-seq-subseq-infinite seq (* index length) (* (1+ index) length))) acc))
     seq-to-reduce
     (list initial-value))))

generate-seq-n-random-chunks-of-size-x

(defun generate-seq-n-random-chunks-of-size-x (length n seq)
  "Returns N random chunks from SEQ.
Each chunk will be LENGTH long."
  (funcall (-compose (apply-partially #'generate-seq-take-infinite n) #'generate-seq-shuffle #'generate-seq-split-infinite) length seq))

generate-seq-take-infinite-shuffled

(defalias 'generate-seq-take-infinite-shuffled (-compose #'generate-seq-shuffle #'generate-seq-take-infinite))

generate-seq-n-random-chunks-of-random-size

(defun generate-seq-n-random-chunks-of-random-size (n seq)
  "Returns N random chunks from SEQ."
  (funcall (-compose (-rpartial #'generate-seq-n-random-chunks-of-size-x n seq) #'generate-seq-random-chunk-length) seq))

map

extensions

generate-map-random-key

(defalias 'generate-map-random-key (-compose #'generate-seq-take-random-value-from-seq #'map-keys) "Returns one random key from MAP.

\(fn MAP)")
(defalias 'generate-seq-map-random-map-key (apply-partially #'seq-map #'generate-map-random-key) "Returns one random key from each map in SEQ.

\(fn MAP)")

generate-map-random-value

(defalias 'generate-map-random-value (-compose #'generate--applify-map-elt (-juxt #'identity #'generate-map-random-key)) "Returns one random value from MAP.

\(fn MAP)")

generate-map-random-pair

(defalias 'generate-map-random-pair (-compose (-juxt #'cadr #'generate--applify-map-elt) (-juxt #'identity #'generate-map-random-key)) "Returns one random key-value pair from MAP.

\(fn MAP)")

generate-map-on

(defun generate--map-on (op keys-func values-func map)
  "Apply KEYS-FUNC to the MAP keys.
Apply VALUES-FUNC to the MAP values.
Finally, apply OP to MAP."
  (funcall (-compose op (-juxt (-compose keys-func #'map-keys) (-compose values-func #'map-values))) map))

generate-data

(cl-defun generate-data (&key (item-transformer #'identity) (list-transformer #'generate-shuffle-list)
                              min-length max-length exact-length)
  "Return a random list.
The length of the list can be optionally specified
using :MIN-LENGTH and :MAX-LENGTH or simply :EXACT-LENGTH.
If EXACT-LENGTH and MIN-LENGTH or MAX-LENGTH are used together,
an error will be signaled.  :ITEM-TRANSFORMER must be a unary
function.  The function will called on each number
in the random list.  :LIST-TRANSFORMER will be called
with the random list as its only argument.
:LIST-TRANSFORMER will always been called after :ITEM-TRANSFORMER
has transformed each item of the list."
  (when (and min-length max-length (> min-length max-length))
    (error "Min-length must be less than max-length"))
  (when (and exact-length min-length)
    (error "Exact-length and min-length can not be used together"))
  (when (and exact-length max-length)
    (error "Exact-length and max-length can not be used together"))
  (let* ((min-items (or exact-length min-length 1))
         (max-items (or exact-length max-length 50))
         (range-length (generate-random-nat-number-in-range (list min-items max-items)))
         (list-items (generate--random-nat-number-list range-length)))
    (funcall (-on list-transformer (apply-partially #'mapcar item-transformer)) list-items)))

strings

generate-n-alpha-string-characters

(defun generate-n-alpha-string-characters (character-count)
  "Returns a random list of alphabetic string characters.
The length of the list will be equal
to CHARACTER-COUNT."
  (generate-data :exact-length character-count :item-transformer #'generate--get-next-lower-alpha-string))

generate-n-length-word

(defun generate-n-length-word (character-count)
  "Returns a random word whose length will be equal to CHARACTER-COUNT.
\(fn INTEGER)"
  (generate-data :exact-length character-count :item-transformer #'generate--get-next-lower-alpha-string :list-transformer #'generate--applify-concat))

generate-random-word

(defalias 'generate-random-word (apply-partially #'generate-data :item-transformer #'generate--get-next-lower-alpha-string :list-transformer #'generate--applify-concat :min-length 2) "Returns a random word.")

generate-random-string

(defalias 'generate-random-string #'generate-random-word
  "Returns a random string. Alias for `generate-random-word'.")

generate-list-of-n-words

(defun generate-list-of-n-words (word-count)
  "Returns a random list of words.
The number of words will be equal to WORD-COUNT."
  (-let* (((word-lengths character-count) (funcall (-compose (-juxt #'identity #'-sum) #'generate-shuffle-list #'-iota) word-count (generate-random-nat-number-in-range (list 3 6))))
          (string-of-characters (generate-n-length-word character-count))
          (words (generate--list-of-n-words-helper word-lengths string-of-characters)))
    (if (length> words word-count) (butlast words) words)))

generate-list-of-n-strings

(defalias 'generate-list-of-n-strings #'generate-list-of-n-words
  "Returns a random list of words.
The number of words will be equal
to WORD-COUNT. Alias for `generate-list-of-n-words'.")

generate-random-list-of-words

(defalias 'generate-random-list-of-words (generate-default-convert-n-gen-to-random #'generate-list-of-n-words) "Returns a random list of words.")

generate-random-list-of-strings

(defalias 'generate-random-list-of-strings #'generate-random-list-of-words
  "Returns a random list of words.
Alias for `generate-random-list-of-words'.")

generate-random-sentence

(defun generate-random-sentence ()
  "Returns a random sentence."
  (concat (s-join " " (generate-random-list-of-words)) "."))

generate-random-list-of-unique-strings

(defalias 'generate-random-list-of-unique-strings (-compose #'-uniq #'generate-random-list-of-words)
  "Returns a random list of strings.
Each string is guranteed to be unique.")

generate-list-of-n-sentences

(defun generate-list-of-n-sentences (n)
  "Returns a list of N sentences."
  (funcall (-compose #'car #'generate--list-of-n-sentences-base) n))

generate-random-list-of-sentences

(defun generate-random-list-of-sentences ()
  "Returns a random list of sentences."
  (funcall (-compose #'car #'generate--random-list-of-sentences-base)))

generate-string-with-n-lines

(defun generate-string-with-n-lines (n)
  "Returns a string with N lines."
  (funcall (-compose #'car #'generate--string-with-n-lines-base) n))

generate-random-multiline-string

(defalias 'generate-random-multiline-string (-compose #'car #'generate--random-multiline-string-base)  "Returns a random string.
The string is guranteed to have multiple lines.")

lists

(defalias 'generate-list-of-nat-numbers #'generate-data "Returns a random list of natural numbers.
The length of the list can be optionally
specified using :MIN-LENGTH and
:MAX-LENGTH or simply :EXACT-LENGTH.

\(fn [:max-length INTEGER] [:min-length INTEGER] [:exact-length INTEGER])")

(defalias 'generate-list-of-nat-number-strings (apply-partially #'generate-data :item-transformer #'number-to-string) "Returns a random list of strings.
Each string will be a natural number.
The length of the list can be optionally
specified using :MIN-LENGTH and
:MAX-LENGTH or simply :EXACT-LENGTH.

\(fn [:max-length INTEGER] [:min-length INTEGER] [:exact-length INTEGER])")

(defalias 'generate-list-of-floats-between-0-and-1 (apply-partially #'generate-data :list-transformer (-compose #'generate--divide-list-values-by-max-list-value #'generate-seq-shuffle)) "Returns a random list of floats.
Each float will be greater than or equal to
zero and less than 1.  The length of the list
can be optionally specified using :MIN-LENGTH
and :MAX-LENGTH or simply :EXACT-LENGTH.

\(fn [:max-length INTEGER] [:min-length INTEGER] [:exact-length INTEGER])")

(defalias 'generate-list-of-floats (apply-partially #'generate-data :list-transformer (-compose #'generate--divide-list-values-by-random-value #'generate-seq-shuffle)) "Returns a random list of floats.
The length of the list can be optionally
specified using :MIN-LENGTH and :MAX-LENGTH
or simply :EXACT-LENGTH.

\(fn [:max-length INTEGER] [:min-length INTEGER] [:exact-length INTEGER])")

(defalias 'generate-random-list-of-lists-nat-numbers (apply-partially #'generate-data :list-transformer #'generate-seq-split-random) "Returns a random list of lists of natural numbers.")

generate-list-of-nat-numbers-in-range

(cl-defun generate-list-of-nat-numbers-in-range (range &key (list-transformer #'generate-shuffle-list) min-length max-length exact-length)
  "Returns a list with COUNT numbers.
Each number will be within the bounds of RANGE.
LIST-TRANSFORMER can be used to transform the
list itself.  MIN-LENGTH, MAX-LENGTH and EXACT-LENGTH
can be used to control the size of the list.  If
EXACT-LENGTH and MIN-LENGTH or MAX-LENGTH
are used together, an error will be signaled."
  (generate-data :list-transformer list-transformer
                 :item-transformer (apply-partially #'generate--non-zero-bounded-modular-addition range 0)
                 :exact-length exact-length
                 :min-length min-length
                 :max-length max-length))

Aliases

generate–list-of-n-nat-numbers-in-range-5
(defalias 'generate--list-of-n-nat-numbers-in-range-5 (apply-partially #'generate-list-of-nat-numbers-in-range generate--FIVERANGE))
generate–list-of-n-nat-numbers-in-range-10
(defalias 'generate--list-of-n-nat-numbers-in-range-10 (apply-partially #'generate-list-of-nat-numbers-in-range generate--TENRANGE))
generate–list-of-nat-numbers-in-range-25
(defalias 'generate--list-of-nat-numbers-in-range-25 (apply-partially #'generate-list-of-nat-numbers-in-range generate--ONETOTWENTYFIVE))

generate-list-of-n-random-values

(defalias 'generate-list-of-n-random-values (generate--list-of-n-random-values generate--LIST-ITEM-TRANSFORMERS))

vectors

(defalias 'generate-vector-of-n-nat-numbers (-compose #'generate--applify-vector #'generate-list-of-nat-numbers) "Returns a random vector of natural numbers.
The length of the vector can be optionally
specified using :MIN-LENGTH and :MAX-LENGTH
or simply :EXACT-LENGTH.

\(fn [:max-length INTEGER] [:min-length INTEGER] [:exact-length INTEGER])")

(defalias 'generate-vector-of-floats-between-0-and-1 (-compose #'generate--applify-vector #'generate-list-of-floats-between-0-and-1) "Returns a random vector of floats.
Each float will be greater than or equal to zero and less than 1.
The length of the vector can be optionally
specified using :MIN-LENGTH and :MAX-LENGTH
or simply :EXACT-LENGTH.
\(fn [:max-length INTEGER] [:min-length INTEGER] [:exact-length INTEGER])")

(defalias 'generate-vector-of-floats (-compose #'generate--applify-vector #'generate-list-of-floats) "Returns a random vector of floats.
The length of the vector can be optionally specified
using :MIN-LENGTH and :MAX-LENGTH
or simply :EXACT-LENGTH.

\(fn [:max-length INTEGER] [:min-length INTEGER] [:exact-length INTEGER])")

(defalias 'generate-random-vector-of-strings (-compose #'generate--applify-vector #'generate-random-list-of-strings) "Returns a random vector of strings.")

(defalias 'generate-random-vector-of-lists-nat-numbers (apply-partially #'generate-data :list-transformer (-compose #'generate--applify-vector #'generate-seq-split-random)) "Returns a random vector of lists of natural numbers.")

alists - make sure the string generators are correct

(defalias 'generate-random-alist-of-nat-numbers (apply-partially #'generate-data :list-transformer (-compose #'generate--applify-zip (-juxt #'seq-reverse #'generate-seq-shuffle))) "Returns a random alist.
Both the keys and the values will be natural numbers.")

(defalias 'generate-random-alist-of-strings (apply-partially #'generate-data :item-transformer #'generate--get-next-lower-alpha-string :list-transformer (-compose #'generate--applify-zip (-juxt #'seq-reverse #'generate-seq-shuffle))) "Returns a random alist.
Both the keys and the values will be strings.")

(defalias 'generate-random-alist-of-string-nat-number-cons (apply-partially #'generate-data :item-transformer #'generate--get-next-lower-alpha-character :list-transformer (-compose #'generate--applify-zip (-juxt (-compose #'generate--seq-map-char-to-string #'seq-reverse) #'generate-seq-shuffle))) "Returns a random alist.
The keys will be strings and the
values will be natural numbers.")

(defalias 'generate-random-alist-of-nat-number-string-cons (apply-partially #'generate-data :item-transformer #'generate--get-next-lower-alpha-character :list-transformer (-compose #'generate--applify-zip (-juxt #'seq-reverse (-compose #'generate--seq-map-char-to-string #'generate-seq-shuffle)))) "Returns a random alist.
The keys will be natural numbers
and the values will be strings.")

generate-list-of-n-alists

plists

(defalias 'generate-random-plist-of-nat-numbers (-compose #'generate--map-into-plist #'generate-random-alist-of-nat-numbers) "Returns a random plist.
Both the keys and the values will be natural numbers.")

(defalias 'generate-random-plist-of-strings (-compose #'generate--map-into-plist #'generate-random-alist-of-strings) "Returns a random plist
Both the keys and the values will be strings.")

(defalias 'generate-random-plist-of-string-nat-number-pairs (-compose #'generate--map-into-plist #'generate-random-alist-of-string-nat-number-cons) "Returns a random plist.
The keys will be strings and the
values will be natural numbers.")

(defalias 'generate-random-plist-of-nat-number-string-pairs (-compose #'generate--map-into-plist #'generate-random-alist-of-nat-number-string-cons) "Returns a random plist.
The keys will be natural numbers
and the values will be strings.")

hash-table

(defalias 'generate-random-hash-table-of-nat-numbers (-compose #'generate--map-into-hash-table #'generate-random-alist-of-nat-numbers) "Returns a random hash-table
Both the keys and the values will be natural numbers.")

(defalias 'generate-random-hash-table-of-strings (-compose #'generate--map-into-hash-table #'generate-random-alist-of-strings) "Returns a random hash-table.
Both the keys and the values will be strings.")

(defalias 'generate-random-hash-table-of-string-nat-number-pairs (-compose #'generate--map-into-hash-table #'generate-random-alist-of-string-nat-number-cons) "Returns a random hash-table.
The keys will be strings and the
values will be natural numbers.")

(defalias 'generate-random-hash-table-of-nat-number-string-pairs (-compose #'generate--map-into-hash-table #'generate-random-alist-of-nat-number-string-cons) "Returns a random hash-table.
The keys will be natural numbers
and the values will be strings.")

cons

(defalias 'generate-random-con-of-nat-numbers (apply-partially #'generate-data :exact-length 2 :list-transformer #'generate--random-con-from-list) "Returns a random cons cell.
 The car and the cdr will be natural numbers.")

(defalias 'generate-random-con-of-floats (apply-partially #'generate-data :exact-length 2 :list-transformer (-compose #'generate--random-con-from-list #'generate--divide-list-values-by-max-list-value)) "Returns a random cons cell.
The car and the cdr will be floats.")

(defalias 'generate-random-con-of-strings (apply-partially #'generate-data :exact-length 2 :item-transformer #'generate--get-next-lower-alpha-string :list-transformer #'generate--random-con-from-list) "Returns a random cons cell.
The car and the cdr will be strings.")

(defalias 'generate-random-string-nat-number-con (apply-partially #'generate-data :exact-length 2 :item-transformer #'generate--get-next-lower-alpha-character :list-transformer (-compose #'generate--applify-cons (-juxt (-compose #'char-to-string #'-first-item) #'-second-item) #'generate-seq-two-random-values)) "Returns a random cons cell.
The car will be string.
The cdr will be a natural number.")

(defalias 'generate-random-nat-number-string-con (apply-partially #'generate-data :exact-length 2 :item-transformer #'generate--get-next-lower-alpha-character :list-transformer (-compose #'generate--applify-cons (-juxt #'-first-item (-compose #'char-to-string #'-second-item)) #'generate-seq-two-random-values)) "Returns a random cons cell.
The car will be a natural number
The cdr will be a string.")

(defalias 'generate-random-string-vector-of-nat-numbers-con (apply-partially #'generate-data :exact-length 2 :item-transformer #'generate--get-next-lower-alpha-character :list-transformer (-compose #'generate--applify-cons (-juxt (-compose #'char-to-string #'-first-item) (-compose #'generate--applify-vector #'cdr)))) "Returns a random cons cell.
The car will be a string.
The cdr will b a vector.")

symbols

generate-random-symbol

(defalias 'generate-random-symbol (-compose #'make-symbol #'generate-random-word) "Returns a random symbol.")

generate-list-of-n-symbols

(defalias 'generate-list-of-n-symbols (-compose (apply-partially #'mapcar #'make-symbol) #'generate-list-of-n-words)  "Returns a list with N symbols.")

generate-random-list-of-symbols

(defalias 'generate-random-list-of-symbols (-compose (apply-partially #'mapcar #'make-symbol) #'generate-random-list-of-unique-strings) "Returns a random list of symbols.")

booleans

generate-random-boolean

(defalias 'generate-random-boolean (apply-partially #'generate-seq-take-random-value-from-seq (list t nil))
  "Returns a random boolean.")

generate-list-of-n-booleans

(defun generate-list-of-n-booleans (n)
  "Returns a list with N booleans."
  (generate-data :item-transformer #'math-oddp :exact-length n))

time

generate-random-12-hour-time-string

(defun generate-random-12-hour-time-string ()
  "Returns a random time string in 12-hour format."
  (format "%s:%s" (generate--random-nat-number-between-1-and-13) (generate--number-to-padded-string (generate--random-nat-number-between-zero-and-60))))

generate-random-24-hour-time-string

(defun generate-random-24-hour-time-string ()
  "Returns a random time string in 24-hour format."
  (funcall (-compose #'generate--join-time-values #'generate--seq-map-format-pad #'list) (generate--random-nat-number-between-zero-and-24) (generate--random-nat-number-between-zero-and-60)))

generate-random-time-string

(defalias 'generate-random-time-string (apply-partially #'generate-call-random-function (list #'generate-random-24-hour-time-string #'generate-random-12-hour-time-string)))

generate-random-lisp-timestamp

(cl-defun generate-random-lisp-timestamp (&optional (range-size generate-lisp-timestamp-range-size))
  "Returns a random Lisp timestamp.
RANGE-SIZE can be used to widen or shrink the range.
It will be used to create the range of times from
which the timestamp will be selected.
Each timestamp will be in the
\(TICKS . HZ) format."
  (generate--lisp-timestamp-helper (floor range-size 2) (floor range-size 2)))

generate-random-lisp-timestamp-range

(cl-defun generate-random-lisp-timestamp-range (&optional (range-size generate-lisp-timestamp-range-size))
  "Returns a random Lisp timestamp range.
RANGE-SIZE can be used to widen or shrink the range.
It will be used to create the range of times from
which the timestamp will be selected.
Each timestamp will be in the
\(TICKS . HZ) format."
  (generate--lisp-timestamp-range-helper (floor range-size 2) (floor range-size 2)))

generate-random-lisp-timestamp-range-with-duration

(defalias 'generate-random-lisp-timestamp-range-with-duration (-compose #'generate--lisp-timestamp-range-duration-helper #'generate-random-lisp-timestamp-range))

generate-list-of-n-lisp-timestamps

(cl-defun generate-list-of-n-lisp-timestamps (n &key (range-size generate-lisp-timestamp-range-size) (order 'random))
  "Returns N timestamps.
RANGE-SIZE can be used to widen or shrink the range.
Timestamps will be in the (TICKS . HZ) format.
ORDER can optionally be used to set the order
of the list.  The value of order should be `asc',
`desc' or `random'.  By default, the list will be unordered."
  (generate--list-of-n-lisp-timestamps-helper n (floor range-size 2) (floor range-size 2) order))

generate-random-list-of-lisp-timestamps

(defalias 'generate-random-list-of-lisp-timestamps (generate-default-convert-n-gen-to-random #'generate-list-of-n-lisp-timestamps) "Returns a random list of lisp timestamps.
Timestamps will be in the (TICKS . HZ) format.")

generate-list-of-n-lisp-timestamp-ranges

(cl-defun generate-list-of-n-lisp-timestamp-ranges (n &key (range-size generate-lisp-timestamp-range-size) (order 'random))
  "Returns N timestamp ranges.
RANGE-SIZE can be used to widen or shrink the range.
Timestamps will be in the (TICKS . HZ) format.
ORDER can optionally be used to set the order
of the list.  The value of order should be `asc',
`desc' or `random'.  By default, the list will be unordered."
  (generate--list-of-n-lisp-timestamp-ranges-helper n (floor range-size 2) (floor range-size 2) order))

dates

generate-random-full-dash-date-string

(defalias 'generate-random-full-dash-date-string (apply-partially #'generate--create-random-full-date-string "-") "Returns a random date
The parts are joined with dashes.
Format will be one of the following:
YYYY-M-D
YYYY-MM-DD
M-D-YYYY
MM-DD-YYYY
D-M-YYYY
DD-MM-YYYY")

generate-random-short-slash-date-string

(defalias 'generate-random-short-slash-date-string (apply-partially #'generate--create-random-short-date-string "/") "Returns a random short date.
The parts are joined with slashes.
Format will be one of the following:
YY/M
YY/MM
M/YY
MM/YY
YYYY/M
YYYY/MM
M/YYYY
MM/YYYY")

generate-random-short-dash-date-string

(defalias 'generate-random-short-dash-date-string (apply-partially #'generate--create-random-short-date-string "-") "Returns a random short date.
The parts will be joined with dashes.
Format will be one of the following:
YY-M
YY-MM
M-YY
MM-YY
YYYY-M
YYYY-MM
M-YYYY
MM-YYYY ")

generate-random-date-string

(defalias 'generate-random-date-string (apply-partially #'generate-call-random-function (list #'generate-random-full-dash-date-string #'generate-random-full-slash-date-string #'generate-random-short-dash-date-string #'generate-random-short-slash-date-string)))

identifiers

generate-random-regular-phone-number

(defalias 'generate--create-random-regular-phone-number (-compose (apply-partially #'s-join "-") (apply-partially #'seq-map (apply-partially #'s-join "")) (-juxt (apply-partially #'-take 3) (-rpartial #'-slice 3 6) (apply-partially #'-take-last 4))) "Helper used to convert LIST into a random U.S. style phone number.")
(defalias 'generate-random-regular-phone-number (apply-partially #'generate-data :min-length 10 :max-length 10 :item-transformer #'generate--get-next-num-between-zero-and-nine-string :list-transformer #'generate--create-random-regular-phone-number) "Returns a random U.S. style phone number.")

generate-random-1-800-number

(defalias 'generate--create-random-1-800-number (-compose (apply-partially #'concat "1-800-") (apply-partially #'s-join "-") (apply-partially #'seq-map (apply-partially #'s-join "")) (-juxt (apply-partially #'-take 3) (apply-partially #'-take-last 4))) "Helper used to convert LIST into a random 1-800 number.")

(defalias 'generate-random-1-800-number (apply-partially #'generate-data :min-length 7 :max-length 7 :item-transformer #'generate--get-next-num-between-zero-and-nine-string :list-transformer #'generate--create-random-1-800-number) "Returns a random 1-800 number.")

generate-random-phone-number

(defalias 'generate-random-phone-number (apply-partially #'generate-call-random-function (list #'generate-random-regular-phone-number #'generate-random-1-800-number)) "Returns a random phone number.")

generate-random-card-number

(defalias 'generate--create-random-card-number (-compose (apply-partially #'s-join "-") (apply-partially #'seq-map (apply-partially #'s-join "")) (-rpartial #'seq-split 4)) "Helper used to convert LIST into a card number string.")
(defalias 'generate-random-card-number (apply-partially #'generate-data :min-length 16 :max-length 16 :item-transformer #'generate--get-next-num-between-zero-and-nine-string :list-transformer #'generate--create-random-card-number) "Returns a random 16-digit card number.")

generate-random-string-of-lower-alphanums

(defalias 'generate-random-string-of-lower-alphanums (apply-partially #'generate--random-identifier-string #'generate--get-next-lower-alpha-string) "Create a random alphanumeric identifier string.
All alphabetic characters will be in lowercase.")

generate-random-string-of-upper-alphanums

(defalias 'generate-random-string-of-upper-alphanums (apply-partially #'generate--random-identifier-string #'generate--get-next-upper-alpha-string) "Create a random alphanumeric identifier string.
All alphabetic characters will be uppercase.")

buffers

generate-with-buffer-with-text

(defmacro generate-with-buffer-with-text (buffer-text &rest body)
  "Run BODY in a temporary buffer with holding BUFFER-TEXT."
  (declare (indent 1) (debug t))
  `(with-temp-buffer
     (insert ,buffer-text)
     (goto-char (point-min))
     ,@body))

org-mode

org-table

table generation

generate-org-table-without-hlines
(defalias 'generate-org-table-without-hlines (-compose #'car #'generate--org-table-without-hlines) "Use ROWS, COLUMNS and VAL-GENERATOR to create an org-table.
ROWS and COLUMNS should be integers. VAL-GENERATOR
should take one argument, a list that will contain
the current row and column number.
The returned table will not have hlines.

\(fn FUNCTION VAL-GENERATOR ROWS COLUMNS)")
generate-org-table-with-hlines
(defalias 'generate-org-table-with-hlines (-compose #'car #'generate--org-table-with-hlines) "Use ROWS, COLUMNS and VAL-GENERATOR to create an org-table.
ROWS and COLUMNS should be integers. VAL-GENERATOR
should take one argument, a list that will contain
the current row and column number.
The returned table will have hlines.

\(fn FUNCTION VAL-GENERATOR ROWS COLUMNS)")
generate-org-table
(defalias 'generate-org-table (-compose #'car #'generate--org-table) "Use ROWS, COLUMNS and VAL-GENERATOR to create an org-table.
ROWS and COLUMNS should be integers.
VAL-GENERATOR should take one argument,
a list that will contain the current row and column
number.  The returned table may or may
not have hlines.

\(fn FUNCTION VAL-GENERATOR ROWS COLUMNS)")

buffers with table

generate-with-buffer-with-org-table-without-hlines
(cl-defmacro generate-with-buffer-with-org-table-without-hlines (org-table-args &rest body)
  "Use ORG-TABLE-ARGS and use them to create a buffer with a table.
The table will not have hlines.
BODY will be executed in the buffer
with the point at the beginning
of the table."
  (declare (indent 1) (debug t))
  (generate--with-buffer-with-org-table-helper #'generate-org-table-without-hlines org-table-args body))
generate-with-buffer-with-org-table-with-hlines
(cl-defmacro generate-with-buffer-with-org-table-with-hlines (org-table-args &rest body)
  "Use ORG-TABLE-ARGS and use them to create a buffer with a table.
The table will not have hlines.
BODY will be executed in the buffer
with the point at the beginning
of the table."
  (declare (indent 1) (debug t))
  (generate--with-buffer-with-org-table-helper #'generate-org-table-with-hlines org-table-args body))
generate-with-buffer-with-org-table
(cl-defmacro generate-with-buffer-with-org-table (org-table-args &rest body)
  "Use ORG-TABLE-ARGS and use them to create a buffer with a table.
The table may or may not have hlines.
BODY will be executed in the buffer
with the point at the beginning
of the table."
  (declare (indent 1) (debug t))
  (generate--with-buffer-with-org-table-helper #'generate-org-table org-table-args body))

timestamps

regular

single strings
inactive timestamps strings
generate-inactive-org-timestamp-string
(defalias 'generate-inactive-org-timestamp-string (generate--create-org-timestamp-generator t))
generate-random-inactive-org-timestamp-string
(defalias 'generate-random-inactive-org-timestamp-string (-compose #'generate-inactive-org-timestamp-string #'generate-random-boolean) "Returns an inactive org timestamp string.
The timestamp may or may not have
a start time.")
active timestamps strings
generate-active-org-timestamp-string
(defalias 'generate-active-org-timestamp-string (generate--create-org-timestamp-generator nil))
generate-random-active-org-timestamp-string
(defalias 'generate-random-active-org-timestamp-string  (-compose #'generate-active-org-timestamp-string #'generate-random-boolean) "Returns an active org timestamp.
The timestamp may or may not have
a start time.")
generate-org-timestamp-string
(defun generate-org-timestamp-string (&optional with-time)
  "Returns a random org timestamp.
If WITH-TIME is t, the timestamp
will have a start time."
  (funcall (generate--create-org-timestamp-generator (generate-random-boolean)) with-time))
generate-random-org-timestamp-string
(defalias 'generate-random-org-timestamp-string (-compose #'generate-org-timestamp-string #'generate-random-boolean) "Returns a random org timestamp.
The timestamp may or may not be inactive.
The timestamp may or may not have a
start time.")
list of strings
inactive timestamps
generate-list-of-n-inactive-org-timestamp-strings
(defalias 'generate-list-of-n-inactive-org-timestamp-strings (generate--create-org-timestamp-generator t :listp t))
generate-random-list-of-inactive-org-timestamp-strings
(defalias 'generate-random-list-of-inactive-org-timestamp-strings (generate-default-convert-n-gen-to-random (lambda (count) (generate-list-of-n-inactive-org-timestamp-strings count (generate-random-boolean)))) "Returns a list of inactive org timestamp strings.
The timestamps may or may not have
a start time.")
active timestamps
generate-list-of-n-active-org-timestamp-strings
(defalias 'generate-list-of-n-active-org-timestamp-strings (generate--create-org-timestamp-generator nil :listp t))
generate-random-list-of-active-org-timestamp-strings
(defalias 'generate-random-list-of-active-org-timestamp-strings (generate-default-convert-n-gen-to-random (lambda (count) (generate-list-of-n-active-org-timestamp-strings count (generate-random-boolean)))) "Returns a list of active org timestamp strings.
The timestamps may or may not have
a start time.")
generate-list-of-n-org-timestamp-strings
(defun generate-list-of-n-org-timestamp-strings (n &optional with-time)
  "Returns a list with N org timestamp strings.
If WITH-TIME is t, the timestamp
will have a start time."
  (funcall (generate--create-org-timestamp-generator (generate-random-boolean) :listp t) n with-time))
generate-random-list-of-org-timestamp-strings
(defalias 'generate-random-list-of-org-timestamp-strings (generate-default-convert-n-gen-to-random (lambda (count) (generate-list-of-n-org-timestamp-strings count (generate-random-boolean))))
  "Returns a random list of org timestamp strings.")

single org-elements

generate-inactive-org-timestamp-element
(defalias 'generate-inactive-org-timestamp-element (generate--create-org-timestamp-generator t :transformer #'org-timestamp-from-time :type "element"))
generate-random-inactive-org-timestamp-element
(defalias 'generate-random-inactive-org-timestamp-element (-compose #'generate-inactive-org-timestamp-element #'generate-random-boolean) "Returns a random inactive org timestamp element.
The timestamp may or may not have a start time.")
generate-active-org-timestamp-element
(defalias 'generate-active-org-timestamp-element (generate--create-org-timestamp-generator nil :transformer #'org-timestamp-from-time :type "element"))
generate-random-active-org-timestamp-element
(defalias 'generate-random-active-org-timestamp-element (-compose #'generate-active-org-timestamp-element #'generate-random-boolean) "Returns a random active org timestamp element.
The timestamp may or may not have a start time.")
generate-org-timestamp-element
(defun generate-org-timestamp-element (with-time)
  "Returns a random org timestamp element.
If WITH-TIME is t, the timestamp
will have a start time."
  (funcall (generate--create-org-timestamp-generator (generate-random-boolean) :transformer #'org-timestamp-from-time :type "element") with-time))
generate-random-org-timestamp-element
(defalias 'generate-random-org-timestamp-element (-compose #'generate-org-timestamp-element #'generate-random-boolean) "Returns a random org timestamp.
The timestamp may or may not be inactive.
The timestamp may or may not have a
start time.")

list of org-elements

inactive timestamps
generate-list-of-n-inactive-org-timestamp-elements
(defalias 'generate-list-of-n-inactive-org-timestamp-elements (generate--create-org-timestamp-generator t :listp t :transformer #'org-timestamp-from-time :type "element"))
generate-random-list-of-inactive-org-timestamp-elements
(defalias 'generate-random-list-of-inactive-org-timestamp-elements (generate-default-convert-n-gen-to-random (lambda (count) (generate-list-of-n-inactive-org-timestamp-elements count (generate-random-boolean)))) "Returns a list of inactive org timestamp elements.
The timestamps may or may not have
a start time.")
active timestamps
generate-list-of-n-active-org-timestamp-elements
(defalias 'generate-list-of-n-active-org-timestamp-elements (generate--create-org-timestamp-generator nil :listp t :transformer #'org-timestamp-from-time :type "element"))
generate-random-list-of-active-org-timestamp-elements
(defalias 'generate-random-list-of-active-org-timestamp-elements (generate-default-convert-n-gen-to-random (lambda (count) (generate-list-of-n-active-org-timestamp-elements count (generate-random-boolean)))) "Returns a list of active org timestamp elements.
The timestamps may or may not have
a start time.")
generate-list-of-n-org-timestamp-elements
(defun generate-list-of-n-org-timestamp-elements (n &optional with-time)
  "Returns a list with N org timestamp elements.
If WITH-TIME is t, the timestamp
will have a start time."
  (funcall (generate--create-org-timestamp-generator (generate-random-boolean) :listp t :transformer #'org-timestamp-from-time :type "element") n with-time))
generate-random-list-of-org-timestamp-elements
(defalias 'generate-random-list-of-org-timestamp-elements (generate-default-convert-n-gen-to-random (lambda (count) (generate-list-of-n-org-timestamp-elements count (generate-random-boolean)))) "Returns a random list of org timestamp elements.")

state change notes

list of notes

generate–list-of-n-org-state-change-notes
(defun generate--list-of-n-org-state-change-notes (from to timestamps)
  "Returns a list of N org state change notes.
FROM and TO can be used to set the from state
and to state of each change note. A org state
change note will be created for each timestamp
in TIMESTAMPS."
  (mapcar (lambda (timestamp) (format "- State \"%s\"       from \"%s\"       %s" to from timestamp)) timestamps))
generate-list-of-n-org-state-change-notes
(cl-defun generate-list-of-n-org-state-change-notes (n &key (from "TODO") (to "DONE") (order 'desc))
  "Returns a list of N org state change notes.
:[:from STRING] and [:to STRING] can be used to
set the from state and to state of each change
note."
  (generate--list-of-n-org-state-change-notes from to (generate-list-of-n-inactive-org-timestamp-strings n t order)))
generate-random-list-of-org-state-change-notes
(defalias 'generate-random-list-of-org-state-change-notes (generate-default-convert-n-gen-to-random #'generate-list-of-n-org-state-change-notes) "Returns a random list of org state change notes.")
generate-block-of-n-org-state-change-notes
(defalias 'generate-block-of-n-org-state-change-notes (-compose (-partial #'s-join "\n") #'generate-list-of-n-org-state-change-notes) "Returns a block of text with N org state change notes.")
generate-random-block-of-org-state-change-notes
(defalias 'generate-random-block-of-org-state-change-notes (generate-default-convert-n-gen-to-random #'generate-block-of-n-org-state-change-notes) "Returns a random block of org state change notes.")

errors

generate-random-void-function-error

(defalias 'generate-random-void-function-error (generate--random-void-x-error 'void-function))

generate-random-void-variable-error

(defalias 'generate-random-void-variable-error (generate--random-void-x-error 'void-variable))

generate-random-wrong-type-argument

(defun generate-random-wrong-type-argument-error ()
  "Returns a random wrong-type-argument error."
  (let* ((random-val (generate-random-value))
         (pred (funcall (-compose (apply-partially #'-first (lambda (func) (not (funcall func random-val)))) #'generate-shuffle-list) generate--PREDICATES)))
    (list 'wrong-type-argument pred random-val)))

generate-arith-error

(defalias 'generate-arith-error (cl-constantly (list 'arith-error nil)) "Returns a random arith-error.")

generate-random-error

(defalias 'generate-random-error (apply-partially #'generate-call-random-function generate--ERROR-GENERATORS) "Returns a random error.")

backtrace

generate-random-backtrace-frame

(defun generate-random-backtrace-frame ()
  "Returns a random backtrace frame."
  (let* ((evald (generate-random-boolean))
         (fun (generate-random-symbol))
         (args (generate-random-list-of-symbols))
         (locals (generate-random-alist))
         (flags (generate-seq-take-random-value-from-seq (list :debug-on-exit :source-available nil)))
         (pos (generate-random-nat-number)))
    (backtrace-make-frame
     :evald evald
     :fun fun
     :args args
     :flags flags
     :locals locals
     :buffer nil
     :pos pos)))

generate-list-of-n-backtrace-frames

(defun generate-list-of-n-backtrace-frames (n)
  "Returns a list with N random backtrace frames."
  (let* ((list-of-evalds (generate-list-of-n-booleans n))
         (list-of-funs (generate-list-of-n-symbols n))
         (list-of-args (generate-list-of-n-symbols n))
         (list-of-locals (generate-list-of-n-alists n))
         (list-of-flags (generate-seq-take-infinite-shuffled n (list :debug-on-exit :source-available nil)))
         (list-of-positions (sort (generate-list-of-nat-numbers :exact-length n))))
    (seq-map-indexed (lambda (pos i) (backtrace-make-frame
                                      :evald (nth i list-of-evalds)
                                      :fun (nth i list-of-funs)
                                      :args (nth i list-of-args)
                                      :flags (nth i list-of-flags)
                                      :locals (nth i list-of-locals)
                                      :buffer nil
                                      :pos pos))
                     list-of-positions)))

generate-random-list-of-backtrace-frames

(defalias 'generate-random-list-of-backtrace-frames (generate-default-convert-n-gen-to-random #'generate-list-of-n-backtrace-frames) "Returns a random list of backtrace frames.")

ert

should

generate-passing-should-form

(defalias 'generate-passing-should-form (generate--should-form-for-type-x :passing t :assert-symbol 'should)
  "Returns a random passing should form.")

generate-passing-should-not-form

(defalias 'generate-passing-should-not-form (generate--should-form-for-type-x :passing t :assert-symbol 'should-not)
  "Returns a random passing should-not form.")

generate-failing-should-form

(defalias 'generate-failing-should-form (generate--should-form-for-type-x :passing nil :assert-symbol 'should)
  "Returns a random failing should form.")

generate-failing-should-not-form

(defalias 'generate-failing-should-not-form (generate--should-form-for-type-x :passing nil :assert-symbol 'should-not)
  "Returns a random failing should-not form.")

generate-random-passing-should

(defalias 'generate-random-passing-should (apply-partially #'generate-call-random-function (list #'generate-passing-should-form
                                                                                                 #'generate-passing-should-not-form))
  "Returns a random passing should form.
The actual asserter will be either `should' or `should-not'.")

generate-random-failing-should

(defalias 'generate-random-failing-should (apply-partially #'generate-call-random-function (list #'generate-failing-should-form
                                                                                                 #'generate-failing-should-not-form))
  "Returns a random failing should form.
The actual asserter will be either `should' or `should-not'.")

generate-random-should

(defalias 'generate-random-should (apply-partially #'generate-call-random-function (list #'generate-passing-should-form
                                                                                         #'generate-passing-should-not-form
                                                                                         #'generate-failing-should-form
                                                                                         #'generate-failing-should-not-form))
  "Returns a random should form.
The actual asserter will be either `should' or `should-not'.
The form itself may be a passing form or a failing form.")

generate-list-of-n-passing-should-forms

(defun generate-list-of-n-passing-should-forms (n)
  "Returns a list of N passing shoulds forms."
  (let* ((vals (generate-list-of-n-random-values n))
         (should-count (generate--random-nat-number-between-0-and n))
         (should-not-count (- n should-count))
         (shoulds (generate-seq-take-infinite should-count (list (list t 'should))))
         (should-nots (generate-seq-take-infinite should-not-count (list (list t 'should-not))))
         (all-should-args (generate-append-and-shuffle shoulds should-nots)))
    (-zip-with #'generate--list-of-n-passing-should-forms-helper vals all-should-args)))

generate-list-of-n-should-forms-with-a-fail

(defun generate-list-of-n-should-forms-with-a-fail (n)
  "Returns a list of N shoulds forms.
One of those forms will be a failing form."
  (let* ((passing-forms (generate-list-of-n-passing-should-forms (1- n)))
         (failing-form (generate-random-failing-should)))
    (generate-append-and-shuffle passing-forms (list failing-form))))

generate-random-list-of-should-forms-with-a-fail

(defalias 'generate-random-list-of-should-forms-with-a-fail (generate-default-convert-n-gen-to-random #'generate-list-of-n-should-forms-with-a-fail)
  "Returns a random list of should forms.
One of those forms will be a failing form.")

generate-random-list-of-passing-should-forms

(defalias 'generate-random-list-of-passing-should-forms (generate-default-convert-n-gen-to-random #'generate-list-of-n-passing-should-forms)
  "Returns a random list of passing should forms.")

ert-test-result

generate-ert-test-result-object

(cl-defun generate-ert-test-result-object (outcome duration)
  "Returns an ert-test-result object.
OUTCOME must be a valid ert-test outcome.
DURATION must be a number."
  (thunk-let* ((passing-should-forms (generate-random-list-of-passing-should-forms))
               (random-ert-skipped-condition (generate--ert-test-skipped-condition (generate-seq-take-random-value-from-seq passing-should-forms)))
               (list-of-should-forms-with-a-fail (generate-random-list-of-should-forms-with-a-fail))
               (should-forms-with-a-fail (car list-of-should-forms-with-a-fail))
               (failing-should (cadr should-forms-with-a-fail))
               (random-ert-failed-condition (generate--ert-test-failed-condition failing-should))
               (backtrace-frames (generate-random-list-of-backtrace-frames))
               (random-message (generate-random-sentence)))
    (pcase outcome
      (:passed-expected (make-ert-test-passed :messages ""
                                              :should-forms passing-should-forms
                                              :duration duration))
      (:passed-unexpected (make-ert-test-passed :messages ""
                                                :should-forms passing-should-forms
                                                :duration duration))
      (:skipped (make-ert-test-skipped :messages ""
                                       :should-forms passing-should-forms
                                       :duration duration
                                       :condition random-ert-skipped-condition
                                       :backtrace backtrace-frames
                                       :infos nil))
      (:failed-unexpected (make-ert-test-failed :messages random-message
                                                :should-forms should-forms-with-a-fail
                                                :duration duration
                                                :condition random-ert-failed-condition
                                                :backtrace backtrace-frames
                                                :infos nil))
      (:failed-expected (make-ert-test-failed :messages random-message
                                              :should-forms should-forms-with-a-fail
                                              :duration duration
                                              :condition random-ert-failed-condition
                                              :backtrace backtrace-frames
                                              :infos nil)))))

generate-ert-test

(cl-defun generate-ert-test (test-name &key documentation tags file-name expected-result-type)
  "Returns an ert-test object named TEST-NAME.
DOCUMENTATION, TAGS, FILE-NAME and EXPECTED-RESULT-TYPE
are optional values that can be used to further customize
the ert-test object."
  (let ((test-symbol (intern test-name))
        (test-func-body (generate-random-should)))
    (make-ert-test
     :name test-symbol
     :tags (or tags '())
     :documentation (or documentation (generate-random-sentence))
     :body (lambda () test-func-body nil)
     :expected-result-type (or expected-result-type ':passed)
     :file-name (or file-name (generate-random-file-name)))))

file

generate-random-file-extension

(defalias 'generate-random-file-extension (apply-partially #'generate-seq-take-random-value-from-seq generate--FILE-EXTENSIONS) "Returns a random file extension.")

generate-random-file-name

(defun generate-random-file-name ()
  "Returns a random file name."
  (concat (generate-random-word) "." (generate-random-file-extension)))

misc

generate-random-punctuation

(defalias 'generate-random-punctuation (apply-partially #'generate-seq-take-random-value-from-seq generate--PUNCTUATION) "Returns a random member of generate-PUNCTUATION.")

generate-random-color

(defalias 'generate-random-color (-compose (-applify #'color-rgb-to-hex) (apply-partially #'generate-list-of-floats-between-0-and-1 :exact-length 3)))

generate-list-of-n-colors

(defun generate-list-of-n-colors (n)
  "Returns a list of N colors.
Values are hexadecimals."
  (let* ((float-count (* n 3))
         (floats (generate-list-of-floats-between-0-and-1 :exact-length float-count)))
    (funcall (-compose (apply-partially #'mapcar (-applify #'color-rgb-to-hex)) #'-partition) 3 floats)))

generate-random-list-of-colors

(defalias 'generate-random-list-of-colors (generate-default-convert-n-gen-to-random #'generate-list-of-n-colors))

composite generators

numbers

generate-random-number

(defalias 'generate-random-number (apply-partially #'generate-call-random-function generate--NUMBER-GENS) "Returns a random number.")

generate-list-of-n-numbers

(defalias 'generate-list-of-n-numbers (-rpartial #'generate-call-random-function-n-times generate--NUMBER-GENS) "Returns a random list of number.
The list will have N numbers.


\(fn N)")

generate-random-number-type-twice

(defalias 'generate-random-number-type-twice (apply-partially #'generate-call-random-function-n-times 2 generate--NUMBER-GENS) "Returns two random numbers.")

generate-random-list-of-numbers

(defalias 'generate-random-list-of-numbers (apply-partially #'generate-call-random-function-random-times generate--NUMBER-GENS) "Returns a random list of numbers.")

lists

generate-random-list

(defalias 'generate-random-list (apply-partially #'generate-call-random-function generate--LIST-GENS) "Returns a random list.")

generate-list-of-n-lists

(defalias 'generate-list-of-n-lists (-rpartial #'generate-call-random-function-n-times generate--LIST-GENS) "Returns a random list of list.
The list will have N lists.


\(fn N)")

generate-random-list-type-twice

(defalias 'generate-random-list-type-twice (apply-partially #'generate-call-random-function-n-times 2 generate--LIST-GENS) "Returns two random lists.")

generate-random-list-of-lists

(defalias 'generate-random-list-of-lists (apply-partially #'generate-call-random-function-random-times generate--LIST-GENS) "Returns a random list of lists.")

vectors

generate-random-vector

(defalias 'generate-random-vector (apply-partially #'generate-call-random-function generate--VECTOR-GENS) "Returns a random vector.")

generate-list-of-n-vectors

(defalias 'generate-list-of-n-vectors (-rpartial #'generate-call-random-function-n-times generate--VECTOR-GENS) "Returns a random list of vector.
The list will have N vectors.


\(fn N)")

generate-random-vector-type-twice

(defalias 'generate-random-vector-type-twice (apply-partially #'generate-call-random-function-n-times 2 generate--VECTOR-GENS) "Returns two random vectors.")

generate-random-list-of-vectors

(defalias 'generate-random-list-of-vectors (apply-partially #'generate-call-random-function-random-times generate--VECTOR-GENS) "Returns a random list of vectors.")

alists

generate-random-alist

(defalias 'generate-random-alist (apply-partially #'generate-call-random-function generate--ALIST-GENS) "Returns a random alist.")

generate-list-of-n-alists

(defalias 'generate-list-of-n-alists (-rpartial #'generate-call-random-function-n-times generate--ALIST-GENS) "Returns a random list of alist.
The list will have N alists.


\(fn N)")

generate-random-alist-type-twice

(defalias 'generate-random-alist-type-twice (apply-partially #'generate-call-random-function-n-times 2 generate--ALIST-GENS) "Returns two random alists.")

generate-random-list-of-alists

(defalias 'generate-random-list-of-alists (apply-partially #'generate-call-random-function-random-times generate--ALIST-GENS) "Returns a random list of alists.")

plists

generate-random-plist

(defalias 'generate-random-plist (apply-partially #'generate-call-random-function generate--PLIST-GENS) "Returns a random plist.")

generate-list-of-n-plists

(defalias 'generate-list-of-n-plists (-rpartial #'generate-call-random-function-n-times generate--PLIST-GENS) "Returns a random list of plist.
The list will have N plists.


\(fn N)")

generate-random-plist-type-twice

(defalias 'generate-random-plist-type-twice (apply-partially #'generate-call-random-function-n-times 2 generate--PLIST-GENS) "Returns two random plists.")

generate-random-list-of-plists

(defalias 'generate-random-list-of-plists (apply-partially #'generate-call-random-function-random-times generate--PLIST-GENS) "Returns a random list of plists.")

hash-tables

generate-random-hash-table

(defalias 'generate-random-hash-table (apply-partially #'generate-call-random-function generate--HASH-TABLE-GENS) "Returns a random hash-table.")

generate-list-of-n-hash-tables

(defalias 'generate-list-of-n-hash-tables (-rpartial #'generate-call-random-function-n-times generate--HASH-TABLE-GENS) "Returns a random list of hash-table.
The list will have N hash-tables.


\(fn N)")

generate-random-hash-table-type-twice

(defalias 'generate-random-hash-table-type-twice (apply-partially #'generate-call-random-function-n-times 2 generate--HASH-TABLE-GENS) "Returns two random hash-tables.")

generate-random-list-of-hash-tables

(defalias 'generate-random-list-of-hash-tables (apply-partially #'generate-call-random-function-random-times generate--HASH-TABLE-GENS) "Returns a random list of hash-tables.")

seqs

generate-random-seq

(defalias 'generate-random-seq (apply-partially #'generate-call-random-function generate--SEQ-GENS) "Returns a random seq.")

generate-list-of-n-seqs

(defalias 'generate-list-of-n-seqs (-rpartial #'generate-call-random-function-n-times generate--SEQ-GENS) "Returns a random list of seq.
The list will have N seqs.


\(fn N)")

generate-random-seq-type-twice

(defalias 'generate-random-seq-type-twice (apply-partially #'generate-call-random-function-n-times 2 generate--SEQ-GENS) "Returns two random seqs.")

generate-random-list-of-seqs

(defalias 'generate-random-list-of-seqs (apply-partially #'generate-call-random-function-random-times generate--SEQ-GENS) "Returns a random list of seqs.")

maps

generate-random-map

(defalias 'generate-random-map (apply-partially #'generate-call-random-function generate--MAP-GENS) "Returns a random map.")

generate-list-of-n-maps

(defalias 'generate-list-of-n-maps (-rpartial #'generate-call-random-function-n-times generate--MAP-GENS) "Returns a random list of map.
The list will have N maps.


\(fn N)")

generate-random-map-type-twice

(defalias 'generate-random-map-type-twice (apply-partially #'generate-call-random-function-n-times 2 generate--MAP-GENS) "Returns two random maps.")

generate-random-list-of-maps

(defalias 'generate-random-list-of-maps (apply-partially #'generate-call-random-function-random-times generate--MAP-GENS) "Returns a random list of maps.")

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages