Skip to content

Commit

Permalink
[Fix #386] Support (while true) pattern (#391)
Browse files Browse the repository at this point in the history
Closes #386
  • Loading branch information
vemv authored May 22, 2021
1 parent c481832 commit 63ed637
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cases/testcases/while_true/green.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(ns testcases.while-true.green)

(defn foo []
(while true
(println 1)))
5 changes: 5 additions & 0 deletions cases/testcases/while_true/red.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(ns testcases.while-true.red)

(defn foo []
(while 1
(println 1)))
2 changes: 2 additions & 0 deletions changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

* Support `(is false)` pattern
* Closes https://github.com/jonase/eastwood/issues/384
* Support `(while true)` pattern
* Closes https://github.com/jonase/eastwood/issues/386

#### Bugfixes

Expand Down
7 changes: 7 additions & 0 deletions resource/eastwood/config/clojure.clj
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@
:within-depth 2
:reason "Allow as-> to have constant tests without warning"})

(disable-warning
{:linter :constant-test
:if-inside-macroexpansion-of #{'clojure.core/while}
:within-depth 3
:qualifier true
:reason "Allow `(while true)` idiom"})

(disable-warning
{:linter :wrong-arity
:function-symbol 'clojure.core/eduction
Expand Down
11 changes: 11 additions & 0 deletions test/eastwood/lint_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,17 @@ relative to a specific macroexpansion"
#{'testcases.let.green} {:some-warnings false}
#{'testcases.let.red} {:some-warnings true})))

(deftest while-true-test
(testing "The `(while true)` idiom is supported"
(are [input expected] (testing input
(is (= (assoc expected :some-errors false)
(-> eastwood.lint/default-opts
(assoc :namespaces input)
(eastwood.lint/eastwood))))
true)
#{'testcases.while-true.green} {:some-warnings false}
#{'testcases.while-true.red} {:some-warnings true})))

(deftest is-false-test
(testing "The `(is false)` idiom is supported"
(are [input expected] (testing input
Expand Down

0 comments on commit 63ed637

Please sign in to comment.