Liking cljdoc? Tell your friends :D

instacheck.core


assoc-in-grammarclj/s

source

ebnf->genclj/s

(ebnf->gen ebnf)
(ebnf->gen ctx ebnf)

Takes an EBNF text string, grammar, parser, or file and returns a test.check generator. If the start is specified then this the name of the rule to use as the starting rule of the grmmar. If start is not specified then the first rule in the grammar file is used as the starting rule.

Takes an EBNF text string, grammar, parser, or file and returns
a test.check generator. If the start is specified then this the name
of the rule to use as the starting rule of the grmmar. If start is
not specified then the first rule in the grammar file is used as the
starting rule.
sourceraw docstring

ebnf-generateclj/s

(ebnf-generate ebnf & [opts])

Returns a single sample value from the generator. Like test.check/generate but but takes an ebnf grammar definition and uses an optional opts map to specify weights, size and seed.

Returns a single sample value from the generator. Like
test.check/generate but but takes an ebnf grammar definition and
uses an optional opts map to specify weights, size and seed.
sourceraw docstring

ebnf-sample-seqclj/s

(ebnf-sample-seq ebnf & [opts])

Returns an infinite sequence of generated values based on the ebnf definition. Like test.check/sample-seq but takes an ebnf grammar definition and uses an optional opts map to specify weights and max-size.

Returns an infinite sequence of generated values based on the ebnf
definition. Like test.check/sample-seq but takes an ebnf grammar
definition and uses an optional opts map to specify weights and
max-size.
sourceraw docstring

get-in-grammarclj/s

source

grammar->generator-defs-sourceclj/s

source

grammar->generator-func-sourceclj/s

source

grammar->generator-objclj/s

(grammar->generator-obj {:keys [start] :as ctx} grammar)

Return a a new generator object based on the context and instacheck grammar object.

Return a a new generator object based on the context and instacheck
grammar object.
sourceraw docstring

grammar->nsclj/s

(grammar->ns ctx grammar & [extra-requires])

Translate a grammar to namespaced Clojure file. Optional third argument specifies a list of additional namespace requires to add to the ns definition. :namespace must be specified in ctx with the namespace name to use (e.g. 'myproj.generators'). If :function is specified in ctx then a single generator factory function will be generated in the namespace with the value of :function as the name, otherwise each generator will be defined as a separate function.

Translate a grammar to namespaced Clojure file. Optional third
argument specifies a list of additional namespace requires to add to
the ns definition. :namespace must be specified in ctx with the
namespace name to use (e.g. 'myproj.generators'). If :function is
specified in ctx then a single generator factory function will be
generated in the namespace with the value of :function as the name,
otherwise each generator will be defined as a separate function.
sourceraw docstring

grammar->parserclj/s

source

instacheckclj/s

(instacheck check-fn ebnf-or-gen & [opts])

Instacheck a function with randomly generated test cases. The check-fn will be called repeatedly with random strings that are generated based on the ebnf-or-gen. The ebnf-or-gen parameter is either something that ebnf->gen can turn into a generator (EBNF string, grammar, parser) or a plain test.check generator. The check-fn should perform a test based on the string and return a nil or false if fails the test or any other value to indicate that it passes the test. If a failure is detected then the shrinking process will performed. The return value is the quick-check return status.

The optional opts parameter can be used to specify the following quick-check options:

  • iterations: number of iterations to check before success (default: 10)
  • max-size: maximum size for all internal generators (default: 200)
  • seed: starting seed for generating test cases
  • report-fn: function to call with a report after each iteration

If the ebnf-or-gen parameter is not already a generator, then the opts parameter can also contain a weights configuration that will be used with ebnf->gen to create the generator for use with quick-check.

Instacheck a function with randomly generated test cases. The
check-fn will be called repeatedly with random strings that are
generated based on the ebnf-or-gen. The ebnf-or-gen parameter is
either something that ebnf->gen can turn into a generator (EBNF
string, grammar, parser) or a plain test.check generator. The
check-fn should perform a test based on the string and return a nil
or false if fails the test or any other value to indicate that it
passes the test. If a failure is detected then the shrinking process
will performed. The return value is the quick-check return status.

The optional opts parameter can be used to specify the following
quick-check options:
  - iterations: number of iterations to check before success (default: 10)
  - max-size:   maximum size for all internal generators (default: 200)
  - seed:       starting seed for generating test cases
  - report-fn:  function to call with a report after each iteration

If the ebnf-or-gen parameter is not already a generator, then the
opts parameter can also contain a weights configuration that will be
used with ebnf->gen to create the generator for use with
quick-check.
sourceraw docstring

load-grammarclj/s

source

load-parserclj/s

source

parseclj/s

source

parse-wtrekclj/s

(parse-wtrek parser text & [id])

Uses parser to parse a text string and returns a map with the parsed tree (:parsed) and a path-log wtrek from the parse (:wtrek). The wtrek weights are set to the number of times each path in the grammar was followed/used to parse the text.

Uses parser to parse a text string and returns a map with the
parsed tree (:parsed) and a path-log wtrek from the parse (:wtrek).
The wtrek weights are set to the number of times each path in the
grammar was followed/used to parse the text.
sourceraw docstring

parse-wtreksclj/s

(parse-wtreks parser texts-ids)

Takes a sequence of [text id] pairs and uses parse-wtrek to generator the following structure:

{:parts [{:id ID
          :parsed PARSED
          :wtrek  {PATH WEIGHT ...}}
          ...]
 :full-wtrek {PATH WEIGHT ...}}

The :parts value is a vector of the parse-wtrek result for each texts-ids. The :full-wtrek has merged weight counts from all :parts :wtrek values.

Takes a sequence of [text id] pairs and uses parse-wtrek to
generator the following structure:

    {:parts [{:id ID
              :parsed PARSED
              :wtrek  {PATH WEIGHT ...}}
              ...]
     :full-wtrek {PATH WEIGHT ...}}

The :parts value is a vector of the parse-wtrek result for each
texts-ids. The :full-wtrek has merged weight counts from all :parts
:wtrek values.
sourceraw docstring

parser->grammarclj/s

source

path-log-wtrekclj/s

source

save-weightsclj/s

source

trekclj/s

source

update-generator-objclj/s

(update-generator-obj obj {:keys [weights start]})

Return a new generator object with runtime properties adjusted (those that don't require eval of the function source again). Only weights and start rule are supported currently.

Return a new generator object with runtime properties adjusted
(those that don't require eval of the function source again). Only
weights and start rule are supported currently.
sourceraw docstring

update-in-grammarclj/s

source

wtrekclj/s

source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close