Skip to content

Instantly share code, notes, and snippets.

Dustin Getz dustingetz

View GitHub Profile
View match.clj
[:db/add [:idos.cpc/email "asdf@qwer"] :idos.cpc/email "asdf@qwer"]
(def invalid?
^:& [map? #(<= (count %) 1)]
#{[_ [a v] a v]
[_ _ :db/id _]}}))
View microtest.clj
(ns user.test
(:refer-clojure :exclude [test])
[meander.epsilon :as m]
[taoensso.timbre :refer [error]]))
(def tests-enabled true)
(defmacro test [& body]
View do-via.cljc
#?(:cljs (:require-macros [])))
(defn tag-type [tag]
(some->> (re-matches #"^([A-Z][-a-z]*)(.*)$" (name tag)) second keyword))
(defn typed-tag? [tag]
(not (nil? (tag-type tag))))
(defn typed-action? [val]
View datomic stage .clj
(ns user.stage
[datomic.api :as d]))
(defn with [$ tx]
(:db-after (d/with $ tx)))
(datomic.api/create-database "datomic:mem://app-db")

I am tired of black box magic test frameworks with long command line incantations and opaque source code that soaks up weeks of attention to understand, so I really want something lightweight like this to become popular. I don't yet know the gap between this and production test functionality, and don't have much attention to spend on this, what are your ideas?

I especially love Brandon Bloom's idea of (defmacro tests [body]) which can erase the tests at compile time depending on build target. Does this mean we can finally co-locate our tests with our functions, like Rich comment blocks?

(ns contrib.test
    [clojure.spec.alpha :as s]
    [taoensso.timbre :refer [warn error info]]))
View .md
    (def s (r/atom 0))

    (defn foo []
      [:input {:type "text" 
               :value @s 
               :on-click #(reset! s (.-target.value %)}]) ; unstable closure reference
    (defn change [e] (reset! s (.-target.value e)) ; you're suggesting we name it
(defn foo! [i]
  (rand-nth (concat
              (range 20)
              [{:cognitect.anomalies/anomaly {:cognitect.anomalies/category :cognitect.anomalies/unavailable}}
               {:cognitect.anomalies/anomaly {:cognitect.anomalies/category :cognitect.anomalies/busy}}
               {:cognitect.anomalies/anomaly {:cognitect.anomalies/category :cognitect.anomalies/forbidden}}])))

(map foo! (range 15))

Unbalanced if with effect

(defn- pprint-list [alis]
  (if-not (pprint-reader-macro alis)
    (pprint-simple-list alis)))

When without effect

(defn- diff-associative-key
View redux.js
var Mocha = require('mocha')
var assert = require('assert')
var _ = require('lodash')
var mocha = new Mocha()
mocha.suite.emit('pre-require', this, 'solution', mocha)
describe('Test suite', function() {
it('should work', function() {
You can’t perform that action at this time.