Skip to content

Commit 35c8345

Browse files
committed
Improving tests for hints
1 parent d19acfb commit 35c8345

File tree

2 files changed

+33
-21
lines changed

2 files changed

+33
-21
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
(ns clojure.test-clojure.storm-test-code.hints
2+
(:import (clojure.testfixtures Component MyView MyView$Builder)
3+
(java.util.concurrent Executors)))
4+
5+
(def form-1
6+
"Returns a function that executes the inline .build call (previously failing)."
7+
(fn []
8+
(-> (Component/newBuilder)
9+
(.setMyView ^MyView$Builder
10+
(.build (MyView/newBuilder)))
11+
.build)))
12+
13+
(def form-2
14+
"Returns a function that executes the threaded -> form (was expected to succeed)."
15+
(fn []
16+
(-> (Component/newBuilder)
17+
(.setMyView ^MyView$Builder
18+
(-> (MyView/newBuilder)
19+
.build))
20+
.build)))
21+
22+
(def form-3
23+
"Returns a function that executes a form that needs the type hint befor the (fn ...) macro to succed"
24+
(fn []
25+
(.submit (Executors/newFixedThreadPool 10) ^Callable (fn [] 42))))
26+
27+
28+
Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,10 @@
11
(ns clojure.test-clojure.storm-typehint-bug
22
(:require
3-
[clojure.test :refer [deftest is testing]])
4-
(:import (clojure.testfixtures Component MyView MyView$Builder)))
5-
6-
(def form-1
7-
"Returns a function that executes the inline .build call (previously failing)."
8-
(fn []
9-
(-> (Component/newBuilder)
10-
(.setMyView ^MyView$Builder
11-
(.build (MyView/newBuilder)))
12-
.build)))
13-
14-
(def form-2
15-
"Returns a function that executes the threaded -> form (was expected to succeed)."
16-
(fn []
17-
(-> (Component/newBuilder)
18-
(.setMyView ^MyView$Builder
19-
(-> (MyView/newBuilder)
20-
.build))
21-
.build)))
3+
[clojure.test :refer [deftest is testing]]
4+
[clojure.test-clojure.storm-test-code.hints :as hints]))
225

236
(deftest wrong-type-hint-falls-back-to-reflection-test
247
(testing "Flow-Storm instrumentation matches Clojure's fallback for incorrect hints"
25-
(is (thrown? java.lang.ClassCastException (form-1)))
26-
(is (some? (form-2)))))
8+
(is (thrown? java.lang.ClassCastException (hints/form-1)))
9+
(is (some? (hints/form-2)))
10+
(is (some? (hints/form-3)))))

0 commit comments

Comments
 (0)