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 15211521 " >>" )))
15221522
15231523(prefer-method print-method IDeferred IDeref)
1524+ (prefer-method print-method IDeferred CompletionStage)
15241525
15251526
15261527
Original file line number Diff line number Diff line change 11(ns manifold.deferred-test
2- (:refer-clojure
3- :exclude (realized? future loop ))
2+ (:refer-clojure :exclude (realized? future loop ))
43 (:require
5- [manifold.utils :as utils]
64 [clojure.test :refer :all ]
75 [manifold.test-utils :refer :all ]
86 [manifold.deferred :as d]
97 [manifold.executor :as ex])
10- (:import (java.util.concurrent CompletableFuture)))
8+ (:import
9+ (java.util.concurrent
10+ CompletableFuture
11+ CompletionStage)
12+ (manifold.deferred IDeferred)))
1113
1214(defmacro future ' [& body]
1315 `(d/future
403405 (d/success! d 1 )
404406 (is (= 1 @@result)))))
405407
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