Fork me on GitHub
#clojurescript
<
2016-07-10
>
denisj06:07:17

Is anyone here doing any work with cljs on node.js i.e. lein cljsbuild compiler option :target :nodejs and have any suggestions to get same devtools/debug experience as in browser. add (js-debugger) and just breakpoint, source mapping etc

xcthulhu18:07:35

How do I write my own generator for cljs.spec?

xcthulhu19:07:36

I have data structures like {0 0.0, 1 0.1, 2 0.2, 3 0.3, 4 0.4, 5 1.0} (maps of integers from 0 to 5, where one of the values must be 1.0 and all of the values must be within [0,1]) I can generate these things with this function:

(defn generate-random-map
  "Return a random structured map"
  []
  (let [values (sort (repeatedly 6 rand))
        pivot-value (last values)]
    (into {} (map-indexed vector (map #(/ % pivot-value) values)))))

misha19:07:57

@xcthulhu try also #C1B1BB2Q3

eyelidlessness20:07:53

i think i've found a cljs.test bug, can anyone confirm?

(def ^:dynamic *foo* nil)

(deftest async-binding-before
  (async done
    (binding [*foo* {}]
      (is (some? *foo*))
      (done))))

(deftest async-binding-after
  (async done
    (is (nil? *foo*))
    (done)))
Result:
FAIL in (async-binding-after) (:)
expected: (nil? *foo*)
  actual: (not (nil? {}))

eyelidlessness21:07:11

it reproduced against master as well, so i filed a ticket http://dev.clojure.org/jira/browse/CLJS-1705

niwinz21:07:40

done should be called asynchronously...

eyelidlessness21:07:27

in my test where i discovered the issue, it was. i provided the minimal repro case

niwinz21:07:28

in any case it dos not explains the issue..

eyelidlessness21:07:41

okay that is odd. so i originally encountered it in a test that depends on core async. the binding was inside a go block, and never unbound. i then tried to isolate the bug with a minimal test case, which i did write synchronously and seemingly it was reproduced. but when i wrap the done call in a js/setTimeout it no longer reproduces. so i may've found two bugs in one.

niwinz21:07:41

I also have found similar situation in go blocks (some time ago) that binding are corrupted

niwinz21:07:25

so maybe the bug exists

eyelidlessness21:07:12

well there is certainly a bug somewhere. in no case should binding corrupt vars

darwin22:07:28

long story short: binding may not work as expected when dealing with async calls