File tree Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Original file line number Diff line number Diff line change 1521
1521
" >>" )))
1522
1522
1523
1523
(prefer-method print-method IDeferred IDeref)
1524
+ (prefer-method print-method IDeferred CompletionStage)
1524
1525
1525
1526
1526
1527
Original file line number Diff line number Diff line change 1
1
(ns manifold.deferred-test
2
- (:refer-clojure
3
- :exclude (realized? future loop ))
2
+ (:refer-clojure :exclude (realized? future loop ))
4
3
(:require
5
- [manifold.utils :as utils]
6
4
[clojure.test :refer :all ]
7
5
[manifold.test-utils :refer :all ]
8
6
[manifold.deferred :as d]
9
7
[manifold.executor :as ex])
10
- (:import (java.util.concurrent CompletableFuture)))
8
+ (:import
9
+ (java.util.concurrent
10
+ CompletableFuture
11
+ CompletionStage)
12
+ (manifold.deferred IDeferred)))
11
13
12
14
(defmacro future ' [& body]
13
15
`(d/future
403
405
(d/success! d 1 )
404
406
(is (= 1 @@result)))))
405
407
408
+ ; ; Promesa adds CompletionStage to the print-method hierarchy, which can cause
409
+ ; ; problems if neither is preferred over the other
410
+ (deftest promesa-print-method-test
411
+ (testing " print-method hierarchy compatibility with promesa" )
412
+ (try
413
+ (let [print-method-dispatch-vals (-> print-method methods keys set)]
414
+ (is (= IDeferred
415
+ (get print-method-dispatch-vals IDeferred ::missing )))
416
+ (is (= ::missing
417
+ (get print-method-dispatch-vals CompletionStage ::missing )))
418
+
419
+ (let [d (d/deferred )]
420
+ (is (instance? IDeferred d))
421
+ (is (instance? CompletionStage d))
422
+
423
+ (testing " no conflicts - CompletionStage not dispatchable"
424
+ (pr-str d))
425
+
426
+ (testing " no conflicts - preferred hierarchy established"
427
+ (defmethod print-method CompletionStage [o ^java.io.Writer w]
428
+ :noop )
429
+
430
+ (pr-str d))))
431
+
432
+ (finally
433
+ (remove-method print-method CompletionStage))))
You can’t perform that action at this time.
0 commit comments