Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow whitespace between comment and arrow #7

Merged
merged 2 commits into from
Dec 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/com/mjdowney/rich_comment_tests.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
(let [foo inc]
(= (foo 1) (inc 1))) ;=> true

;; Allows space between comment and arrow
(+ 1 1)
;; => 2

; This comment shouldn't be attached to anything

; Test results can be multi-line
Expand Down Expand Up @@ -121,11 +125,14 @@
(+ 1 1) ;=> 2

(+ 1 1)
;;=> 2"
;;=> 2

(+ 1 1)
;; => 2"
[test-sexpr-zloc]
(let [nodes-following-assertion (rest (iterate z/right* test-sexpr-zloc))
; A string like ";=> _" or ";=>> _"
result-comment? #(re-matches #"\s*;+=>{1,2}.+\n" %)]
; A string like ";=> _" or ";=>> _" or ";; => _"
result-comment? #(re-matches #"\s*;+\s?=>{1,2}.+\n" %)]
(when-let [[fst-line & rest]
(->> nodes-following-assertion
(take-while z/whitespace-or-comment?)
Expand All @@ -134,7 +141,7 @@
; stop searching at the first double line break
(take-while (complement #{"\n"}))
; strip leading ;s from comments
(map #(string/replace-first % #"^\s*;+" ""))
(map #(string/replace-first % #"^\s*;+\s?" ""))
seq)]
(let [[_ type' fst-line] (re-matches #"(?s)(=>{1,2})(.+)" fst-line)]
[(symbol type')
Expand Down Expand Up @@ -176,12 +183,12 @@
(-> *1 :context-strings first)
;=> ";; For example, let's add two numbers.\n"

;; Select the fourth test in the first comment block, which uses a different
;; Select the fifth test in the first comment block, which uses a different
;; expectation type.
(->> (z/of-file *file* {:track-position? true})
rct-zlocs
(mapcat rct-data-seq)
(drop 3)
(drop 4)
first
:expectation-type)
;=> '=>>
Expand Down