ClojureScript

Add a spec generator for some?

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:

Description

Clojure has a spec generator for the core some? predicate:

$ clj
Clojure 1.9.0
user=> (require '[clojure.spec.alpha :as s])
nil
user=> (s/exercise some?)
([#{} #{}] [() ()] [(Fi/jZ) (Fi/jZ)] [() ()] [{} {}] [() ()] [() ()] [[3/4 [-1.2890625 #uuid "8b1ca800-9eaf-48d3-b0d8-eed5bf972f42"]] [3/4 [-1.2890625 #uuid "8b1ca800-9eaf-48d3-b0d8-eed5bf972f42"]]] [((-4.25 false) {6 \9}) ((-4.25 false) {6 \9})] [#{{#uuid "d589d5a1-513a-455b-8c29-fe1fe718f284" 2/7} -1 [-7 -2.0]} #{{#uuid "d589d5a1-513a-455b-8c29-fe1fe718f284" 2/7} -1 [-7 -2.0]}])

But ClojureScript is lacking this:

$ clj -m cljs.main -re node -r
ClojureScript 1.10.339
cljs.user=> (require '[clojure.spec.alpha :as s])
nil
cljs.user=> (require 'clojure.test.check.generators)
nil
cljs.user=> (s/exercise some?)
repl:13
throw e__6464__auto__;
^

Error: Unable to construct gen at: [] for: function cljs$core$some_QMARK_(x){
return !((x == null));
}
    at cljs$spec$alpha$gensub (/private/var/folders/60/ndky5jxj3v3gw_7j1dwq7msw0000gn/T/out521309304431570920698843305844530/cljs/spec/alpha.js:995:8)
    at Function.cljs.spec.alpha.gen.cljs$core$IFn$_invoke$arity$2 (/private/var/folders/60/ndky5jxj3v3gw_7j1dwq7msw0000gn/T/out521309304431570920698843305844530/cljs/spec/alpha.js:1031:31)
    at cljs$spec$alpha$gen (/private/var/folders/60/ndky5jxj3v3gw_7j1dwq7msw0000gn/T/out521309304431570920698843305844530/cljs/spec/alpha.js:1017:28)
    at Function.cljs.spec.alpha.exercise.cljs$core$IFn$_invoke$arity$3 (/private/var/folders/60/ndky5jxj3v3gw_7j1dwq7msw0000gn/T/out521309304431570920698843305844530/cljs/spec/alpha.js:5439:61)
    at cljs$spec$alpha$exercise (/private/var/folders/60/ndky5jxj3v3gw_7j1dwq7msw0000gn/T/out521309304431570920698843305844530/cljs/spec/alpha.js:5419:33)
    at Function.cljs.spec.alpha.exercise.cljs$core$IFn$_invoke$arity$2 (/private/var/folders/60/ndky5jxj3v3gw_7j1dwq7msw0000gn/T/out521309304431570920698843305844530/cljs/spec/alpha.js:5433:33)
    at cljs$spec$alpha$exercise (/private/var/folders/60/ndky5jxj3v3gw_7j1dwq7msw0000gn/T/out521309304431570920698843305844530/cljs/spec/alpha.js:5415:33)
    at Function.cljs.spec.alpha.exercise.cljs$core$IFn$_invoke$arity$1 (/private/var/folders/60/ndky5jxj3v3gw_7j1dwq7msw0000gn/T/out521309304431570920698843305844530/cljs/spec/alpha.js:5429:33)
    at cljs$spec$alpha$exercise (/private/var/folders/60/ndky5jxj3v3gw_7j1dwq7msw0000gn/T/out521309304431570920698843305844530/cljs/spec/alpha.js:5411:33)
    at repl:1:104
cljs.user=>

Implementation guidance:

Here is the generator in Clojure:

https://github.com/clojure/spec.alpha/blob/2329bb2d869ce59d92a401082587cc82edfce95a/src/main/clojure/clojure/spec/gen/alpha.clj#L136

This would be added to ClojureScript around here:

https://github.com/clojure/clojurescript/blob/6353a9b381144d6d0caa621322af9587922e7c07/src/main/cljs/cljs/spec/gen/alpha.cljs#L92

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: