Skip to content

Commit 5d81fde

Browse files
committed
readme - tighten
1 parent ce5b371 commit 5d81fde

File tree

1 file changed

+49
-35
lines changed

1 file changed

+49
-35
lines changed

README.md

Lines changed: 49 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,48 @@
1-
# RCF – asynchronous Rich Comment Forms and REPL-first test macro for Clojure/Script
1+
# RCF – REPL-first async test macro for Clojure/Script
22

33
RCF turns your Rich Comment Forms into tests (in the same file as your functions). Send form or file to REPL to run tests and it squirts dopamine ✅✅✅. It's good, try it!
44

55
![](https://i.imgur.com/nBOOZq7.png)
66

77
Features
88
* Clojure/Script
9-
* Async tests
10-
* Zero boilerplate
11-
* Natural REPL workflow
12-
* No file watchers, no extra windows, no beeping, no latency
13-
* One key-chord to run tests, no hotkey configuring
9+
* async tests
10+
* zero boilerplate
11+
* natural REPL workflow
12+
* one key-chord to run tests, no hotkey configuring
13+
* same-file tests (examples are better than docstrings)
14+
* no file watchers, no extra windows, no beeping, no latency
15+
* notebook support – [example NextJournal notebook](https://nextjournal.com/dustingetz/missionary-relieve-backpressure)
16+
* it's fun! ✅✅✅
1417

15-
Deeper goal: **a notation for communication**
16-
* Documentation tool. RCF lets you share example usages next to the source code of the function (which is way better than docstrings). Figuring out what dense Clojure code does is actually really hard and RCF fixes that. [Example nextjournal notebook documentation using RCF](https://nextjournal.com/dustingetz/missionary-relieve-backpressure)
17-
* Pair programming tool. While pairing on Zoom, bang out some assertions quickly, right in the file you're working on. Watch your communication bandwidth improve.
18-
* Teaching tool. RCF helps beginners experiment and check their work.
19-
20-
RCF is specifically engineered to support [hyperfiddle/electric](https://github.com/hyperfiddle/electric), that we test, document and teach with RCF.
18+
RCF is specifically engineered to support [Electric Clojure](https://github.com/hyperfiddle/electric), which we test, document and teach with RCF.
2119

2220
Hype quotes:
2321
* "RCF has changed my habits with regards to tests. It is so much easier than flipping back and forth between files, you get my preferred work habits - work in a comment block until something works. But before RCF I never took the time to turn comment blocks into an automated test"
24-
* "I think people make the mistake of comparing this with other methods of inlining tests near their function definitions (which has been possible, though uncommon, for a long time). The integration with the REPL, low syntax/interface, reduces friction and makes testing more attractive as a language of communication and verification."
25-
* "I used RCF in a successful interview. RCF was a massive help in communication and a fast tool for thought whilst under the conditions of technical interview."
2622
* "I use RCF to do leetcode style questions as 'fun practice.' It certainly didn't feel fun before!"
23+
* "I think people make the mistake of comparing this with other methods of inlining tests near their function definitions. The integration with the REPL, low syntax/interface, reduces friction and makes testing more attractive as a language of communication and verification."
24+
* "I used RCF in a successful interview. RCF was a massive help in communication and a fast tool for thought whilst under the conditions of technical interview."
2725

2826
# Dependency
2927

30-
Project maturity: CLJ is stable, external users. CLJS is alpha
28+
Project maturity: CLJ is stable, CLJS is experimental, bb is experimental.
3129

3230
```clojure
33-
; stable
3431
{:deps {com.hyperfiddle/rcf {:mvn/version "20220926-202227"}}}
3532
```
3633

37-
Breaking changes:
34+
Changelog
35+
* :throws
36+
* babashka support (experimental)
37+
* **breaking** don't return final result return nil like comment
3838
* `20220926-202227` `!` is deprecated, use `tap` instead
3939
* `20220827-151056` async test forms no longer guaranteed return final result
4040
* `20220405` maven group-id renamed from `hyperfiddle` to `com.hyperfiddle` for security
4141
* 2021 Dec 18: clojurescript dependency is now under the :cljs alias, see #25
4242
* 2021 Oct 20: custom reporters now dispatch on qualified keywords, see #19
4343

44-
Experimental (master): the current development priority is improving complex async tests in
45-
ClojureScript, DX and some experiments with unification.
44+
Current dev priority is improving complex async tests in ClojureScript.
4645

47-
```Clojure
48-
; development - not currently published
49-
;{:deps {com.hyperfiddle/rcf {:git/url "https://github.com/hyperfiddle/rcf.git" :sha ...}}}
50-
```
5146
[![JVM](https://github.com/hyperfiddle/rcf/actions/workflows/tests_clj.yml/badge.svg?branch=master)](https://github.com/hyperfiddle/rcf/actions/workflows/tests_clj.yml)
5247
[![NodeJS](https://github.com/hyperfiddle/rcf/actions/workflows/tests_node.yml/badge.svg?branch=master)](https://github.com/hyperfiddle/rcf/actions/workflows/tests_node.yml)
5348
[![Browser](https://github.com/hyperfiddle/rcf/actions/workflows/tests_browser.yml/badge.svg?branch=master)](https://github.com/hyperfiddle/rcf/actions/workflows/tests_browser.yml)
@@ -64,7 +59,7 @@ It's an easy one-liner to turn on tests in your dev entrypoint:
6459

6560
(hyperfiddle.rcf/enable!)
6661
```
67-
Tests are run when you send a file or form to your Clojure/Script REPL. In Cursive, that's cmd-shift-L to load the file.
62+
Tests are run when you send a file or form to your Clojure/Script REPL.
6863

6964
```clojure
7065
(ns example
@@ -126,7 +121,8 @@ Loading src/example.cljc...
126121
```Clojure
127122
(ns example
128123
(:require [clojure.core.async :refer [chan >! go go-loop <! timeout close!]]
129-
[hyperfiddle.rcf :as rcf :refer [tests tap %]]
124+
[hyperfiddle.electric :as e]
125+
[hyperfiddle.rcf :as rcf :refer [tests tap % with]]
130126
[missionary.core :as m]))
131127

132128
(rcf/set-timeout! 100)
@@ -135,21 +131,38 @@ Loading src/example.cljc...
135131
"async tests"
136132
#?(:clj (tests
137133
(future
138-
(rcf/tap 1) (Thread/sleep 10) ; tap value to queue
139-
(rcf/tap 2) (Thread/sleep 200)
140-
(rcf/tap 3))
134+
(tap 1) (Thread/sleep 10) ; tap value to queue
135+
(tap 2) (Thread/sleep 200)
136+
(tap 3))
141137
% := 1 ; pop queue
142138
% := 2
143139
% := ::rcf/timeout)
144140
:cljs (tests
145141
(defn setTimeout [f ms] (js/setTimeout ms f))
146-
(rcf/tap 1) (setTimeout 10 (fn []
147-
(rcf/tap 2) (setTimeout 200 (fn []
148-
(rcf/tap 3)))))
142+
(tap 1) (setTimeout 10 (fn []
143+
(tap 2) (setTimeout 200 (fn []
144+
(tap 3)))))
149145
% := 1
150146
% := 2
151-
% := ::rcf/timeout))
147+
% := ::rcf/timeout)))
148+
149+
(tests
150+
"electric"
151+
(def !x (atom 0))
152+
(def dispose
153+
(e/run
154+
(let [x (e/watch !x)
155+
a (inc x)
156+
b (inc x)]
157+
(tap (+ a b)))))
158+
% := 2
159+
(swap! !x inc)
160+
% := 4
161+
(swap! !x inc)
162+
% := 6
163+
(dispose))
152164

165+
(tests
153166
"core.async"
154167
(def c (chan))
155168
(go-loop [x (<! c)]
@@ -160,8 +173,9 @@ Loading src/example.cljc...
160173
(go (>! c :hello) (>! c :world))
161174
% := :hello
162175
% := :world
163-
(close! c)
176+
(close! c))
164177

178+
(tests
165179
"missionary"
166180
(def !x (atom 0))
167181
(def dispose ((m/reactor (m/stream! (m/ap (! (inc (m/?< (m/watch !x)))))))
@@ -171,7 +185,7 @@ Loading src/example.cljc...
171185
(swap! !x inc)
172186
% := 2
173187
% := 3
174-
(dispose))
188+
(dispose)))
175189
```
176190

177191
# CI
@@ -194,7 +208,7 @@ Ran 1 tests containing 8 assertions.
194208

195209
# ClojureScript configuration
196210

197-
For CLJS tests to run, `rcf/enable!` must be true in both CLJ (shadow-cljs macroexpansion time) and CLJS (JS runtime). Successful runs will print green checkboxes in the browser console, not the REPL, because REPLs don't properly intercept the async println. (Please file an issue or DM us on slack if you can help us understand why.)
211+
For CLJS tests to run, `rcf/enable!` must be true **in both CLJ (shadow-cljs macroexpansion time) and CLJS (JS runtime)**. Reports may be printed to **browser console instead of the REPL**, because browser REPLs donn't intercept the async println.
198212

199213
```Clojure
200214
(ns dev-entrypoint

0 commit comments

Comments
 (0)