forked from funcool/promesa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.clj
68 lines (59 loc) · 1.98 KB
/
user.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
(ns user
(:require [clojure.tools.namespace.repl :as r]
[criterium.core :refer [quick-bench bench with-progress-reporting]]
[clojure.walk :refer [macroexpand-all]]
[clojure.pprint :refer [pprint]]
[clojure.test :as test]
[promesa.core :as p]
[promesa.protocols :as pt]
[promesa.util :as pu])
(:import java.util.concurrent.CompletableFuture
java.util.concurrent.CompletionStage
java.util.function.Function))
(defmacro run-quick-bench
[& exprs]
`(with-progress-reporting (quick-bench (do ~@exprs) :verbose)))
(defmacro run-quick-bench'
[& exprs]
`(quick-bench (do ~@exprs)))
(defmacro run-bench
[& exprs]
`(with-progress-reporting (bench (do ~@exprs) :verbose)))
(defmacro run-bench'
[& exprs]
`(bench (do ~@exprs)))
(defn- run-test
([] (run-test #"^promesa.tests.*"))
([o]
(r/refresh)
(cond
(instance? java.util.regex.Pattern o)
(test/run-all-tests o)
(symbol? o)
(if-let [sns (namespace o)]
(do (require (symbol sns))
(test/test-vars [(resolve o)]))
(test/test-ns o)))))
(defn -main
[& args]
(require 'promesa.tests.test-core)
(let [{:keys [fail]} (run-test)]
(if (pos? fail)
(System/exit fail)
(System/exit 0))))
;; (defn simple-promise-chain-5-raw
;; []
;; @(as-> (CompletableFuture/completedFuture 1) $
;; (p/then' $ inc)
;; (p/then' $ inc)
;; (p/then' $ inc)
;; (p/then' $ inc)
;; (p/then' $ inc)))
;; (defn simple-completable-chain-5-raw
;; []
;; @(as-> (CompletableFuture/completedFuture 1) $
;; (.thenApply ^CompletionStage $ ^Function (pu/->FunctionWrapper inc))
;; (.thenApply ^CompletionStage $ ^Function (pu/->FunctionWrapper inc))
;; (.thenApply ^CompletionStage $ ^Function (pu/->FunctionWrapper inc))
;; (.thenApply ^CompletionStage $ ^Function (pu/->FunctionWrapper inc))
;; (.thenApply ^CompletionStage $ ^Function (pu/->FunctionWrapper inc))))