-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix various false positives for
clojure.core.async/go
Closes #411
- Loading branch information
Showing
7 changed files
with
155 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
test-third-party-deps/testcases/core_async_example/alt.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
(ns testcases.core-async-example.alt | ||
(:require | ||
[clojure.core.async :refer [alt! go timeout]])) | ||
|
||
(defn sample | ||
"https://github.com/jonase/eastwood/issues/411" | ||
[trade-ch] | ||
(go | ||
(let [timeout-ch (timeout 1000) | ||
trade 100] | ||
(-> (alt! | ||
[[trade-ch trade]] :sent | ||
timeout-ch :timed-out) | ||
print)))) |
8 changes: 8 additions & 0 deletions
8
test-third-party-deps/testcases/core_async_example/assert.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
(ns testcases.core-async-example.assert | ||
(:require | ||
[clojure.core.async :refer [go]])) | ||
|
||
(defn sample [] | ||
(go | ||
(assert false) | ||
(assert true))) |
66 changes: 66 additions & 0 deletions
66
test-third-party-deps/testcases/core_async_example/misc.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
(ns testcases.core-async-example.misc | ||
(:require | ||
[clojure.core.async :refer [go]] | ||
[clojure.spec.alpha :as spec] | ||
[clojure.test :refer [are assert-expr deftest do-report is join-fixtures testing use-fixtures]]) | ||
(:import | ||
(java.io PrintWriter))) | ||
|
||
(defn sample1 [] | ||
(go | ||
(spec/and ::foo ::bar))) | ||
|
||
(defn sample2 [] | ||
(go | ||
(spec/keys :req [::foo]))) | ||
|
||
(defn sample3 [] | ||
(go | ||
(spec/coll-of int?))) | ||
|
||
(defmethod assert-expr 'truthy? | ||
[msg [pred v]] | ||
`(do-report (if ~v | ||
{:type :pass, :message ~msg} | ||
{:type :fail, :message ~msg}))) | ||
|
||
(defn func [f] "") | ||
|
||
(defn throws-exception [] | ||
(throw (ex-info "" {}))) | ||
|
||
;; https://github.com/jonase/eastwood/issues/116 | ||
(deftest exercises-thrown | ||
(go | ||
(is (thrown? Exception (throws-exception))))) | ||
|
||
;; https://github.com/jonase/eastwood/issues/313 | ||
(deftest exercises-truthy | ||
(go | ||
(is (truthy? 42)))) | ||
|
||
;; https://github.com/jonase/eastwood/issues/207 | ||
(deftest b-test | ||
(go | ||
(is (instance? String (func +))))) | ||
|
||
(defn sample4 [] | ||
(go | ||
(is false))) | ||
|
||
(defn sample5 [] | ||
(go | ||
(cond-> 1 | ||
true inc))) | ||
|
||
(defn sample6 [stream ^PrintWriter pw] | ||
(go | ||
(with-out-str | ||
(-> pw (.print "foo")) | ||
(spit stream 42) | ||
1))) | ||
|
||
(defn sample7 [stream] | ||
(go | ||
(while true | ||
(throw (ex-info "." {}))))) |