Adding Correctness Conditions to Code Changes

Today I looked at the first PR on our new project repo. It added a new run script, but the README didn’t mention it. The proposed change was incomplete, because the documentation was out of sync. Did I comment on the PR? heck no. I want to fix this problem for all PRs, not just …

Read moreAdding Correctness Conditions to Code Changes

Quick reference: monads and test.check generators

Combine monads with test.check generators to build them up out of smaller generators with dependencies: (require ‘[clojure.test.check.generators :as gen])(require ‘[clojure.algo.monads :as m])(m/defmonad gen-m   [m-bind gen/bind    m-result gen/return]) (def vector-and-elem  (m/domonad gen-m    [n (gen/choose 1 10)     v (gen/vector gen/int n)     e (gen/element v)]    [v, e])) (gen/sample vector-and-elem);; ([[0 0] 0]     [[0 -1 1 0 -1 0 -1 1] 0]   …

Read moreQuick reference: monads and test.check generators

Testing akka actor termination

When testing akka code, I want to make sure a particular actor gets shut down within a time limit. I used to do it like this:  Thread.sleep(2.seconds) assertTrue(actorRef.isTerminated()) That isTerminated method is deprecated since Akka 2.2, and good thing too, since my test was wasting everyone’s time. Today I’m doing this instead: import akka.testkit.TestProbeval probe = …

Read moreTesting akka actor termination