Open oakmac opened 2 months ago
And this case where the docstring is missing:
(defn add-or-replace-circle
"Adds a Circle to the board. Returns the id of the new Circle.
If there is already a Circle on the board on that square, it will be replaced."
[board-state {:keys [square] :as circle-config}]
(let [square->circles-map (get-circles-by-square board-state)]
(if-let [current-circle (get square->circles-map square)]
(do
(remove-circle-by-id board-state (:id current-circle))
(add-circle board-state (assoc circle-config :id (:id current-circle))))
(add-circle board-state circle-config))))
(defn add-or-replace-circle
"
"
[board-state {:keys [square] :as circle-config}]
(let [square->circles-map (get-circles-by-square board-state)]
(if-let [current-circle (get square->circles-map square)]
(do
(remove-circle-by-id board-state (:id current-circle))
(add-circle board-state (assoc circle-config :id (:id current-circle))))
(add-circle board-state circle-config))))
Another test case (view raw as .eno format)
--Input (->> @foo :bar vals (filter my-pred?)) --Input
--Expected (->> @foo :bar vals (filter my-pred?)) --Expected
--Input (defn get-circles-by-square "Returns a Map of Circles with their square as the key." [board-state] (let [circles (->> @board-state :items vals (filter circle-item?))] (zipmap (map :square circles) circles))) --Input
--Expected (defn get-circles-by-square "Returns a Map of Circles with their square as the key." [board-state] (let [circles (->> @board-state :items vals (filter circle-item?))] (zipmap (map :square circles) circles))) --Expected
Another test case:
--Input (js-obj "foo" bar "biz" #() ;; aaa "baz" nil ) --Input
--Expected (js-obj "foo" bar "biz" #() ;; aaa "baz" nil) --Expected
Another test case:
(ns com.oakmac.chessboard2.util.base58)
(def base58-chars
"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")
(def default-length 12)
(defn random-base58
"returns a random base58 string"
([]
(random-base58 default-length))
([len]
(apply str (take len (repeatedly #(rand-nth base58-chars))))))
Fixed with PR #46
(defn zomg!
"I am a function docstring."
[some-map]
(let [{:keys [x y]} some-map]
;; gobble gobble
(when-not (even? x)
(let [a "a"]
;; banana
(foo bar :alpha "alpha"
:bravo "bravo")))))
;; aaa
;; bbb
Fixed with PR #47
The FIXME: add square
comment gets adjusted here. I think it should stay aligned with the above form?
(defn on-touch-start
"This function fires on every 'touchstart' event inside the root DOM element"
[board-state js-evt]
(let [;; call their onTouchSquare function if provided
on-touchsquare-result (when (fn? onTouchSquare)
(let [js-board-info (js-obj "orientation" orientation
"position" (clj->js position))]
;; FIXME: add square, piece here
;; what else?
(onTouchSquare square piece js-board-info)))]
;; begin dragging if configured
(when (and piece
(or (true? draggable) (true? touchDraggable)))
(begin-dragging! board-state square piece clientX clientY))))
I ran across this test case while creating the cli tooling:
Is currently formatted to:
I expect:
(ie: no change from the input)