Skip to content

Instantly share code, notes, and snippets.

(defun test-full-path (project-root test-home)
(concat
(replace-regexp-in-string
(concat (expand-file-name project-root) "src/clojure")
(concat project-root test-home)
(file-name-sans-extension (buffer-file-name)))
"_expectations.clj"))
(defun find-expectations ()
(interactive)
(defun src-full-path (project-root file-name)
(concat
(replace-regexp-in-string
(concat (expand-file-name project-root) "test/clojure/expectations")
(concat project-root "src/clojure")
(file-name-directory file-name))
(replace-regexp-in-string
"_expectations"
""
(file-name-nondirectory file-name))))
(defun duplicate-line ()
(interactive)
(let* ((cursor-column (current-column)))
(move-beginning-of-line 1)
(kill-line)
(yank)
(open-line 1)
(next-line 1)
(yank)
(move-to-column cursor-column)))
(defun grep-in-project ()
(interactive)
(er/mark-clj-word)
(let* ((project-root (locate-dominating-file
(file-name-directory (buffer-file-name)) "project.clj")))
(if project-root
(grep (concat "grep -nH -e "
(buffer-substring-no-properties (region-beginning) (region-end))
" -R " project-root))
(message (concat "no project.clj found at or below " (buffer-file-name))))))
(defun grep-in (project-root)
(interactive (list (read-directory-name "Project Root: "
(locate-dominating-file
default-directory
"project.clj"))))
(er/mark-clj-word)
(grep (concat "grep -nH -e "
(buffer-substring-no-properties (region-beginning) (region-end))
" -R " project-root)))
(scenario
(let [i (atom 0)]
(expect 0 @i)
(swap! i inc)
(expect 1 @i)
(swap! i inc)
(expect 2 @i)))
(expect 0 (let [i (atom 0)]
@i))
(expect 1 (let [i (atom 0)]
(swap! i inc)
@i))
(expect 2 (let [i (atom 0)]
(swap! i inc)
(swap! i inc)
(given [x y] (expect x y)
0 (let [i (atom 0)]
@i)
1 (let [i (atom 0)]
(swap! i inc)
@i)
(let [i (atom 0)]
(swap! i inc)
(given [x] x
(expect 0 (let [i (atom 0)]
@i))
(expect 1 (let [i (atom 0)]
(swap! i inc)
@i))
(expect 2 (let [i (atom 0)]
(swap! i inc)
(given [x do-work] (expect x (let [i (atom 0)]
do-work))
0 @i
1 (do (swap! i inc)
@i)
2 (do (swap! i inc)
(swap! i inc)
@i))