Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Added further tests for marker protocols as defined in CLJ-966

Signed-off-by: Stuart Halloway <>
  • Loading branch information...
commit 7a36ea0330024c9fbc07d931c5d640a3e1235114 1 parent 2bc8b1f
@fogus fogus authored stuarthalloway committed
26 test/clojure/test_clojure/protocols.clj
@@ -76,9 +76,29 @@
(eval '(defprotocol Elusive (new-method [x])))
(is (= :new-method (eval '(new-method (reify Elusive (new-method [x] :new-method))))))
(is (fails-with-cause? IllegalArgumentException #"No method of interface: .*\.Elusive found for function: old-method of protocol: Elusive \(The protocol method may have been defined before and removed\.\)"
- (eval '(old-method (reify Elusive (new-method [x] :new-method)))))))
- (testing "you can define a marker protocol"
- (is (= '() (method-names clojure.test_clojure.protocols.examples.MarkerProtocol)))))
+ (eval '(old-method (reify Elusive (new-method [x] :new-method))))))))
+(deftype HasMarkers []
+ ExampleProtocol
+ (foo [this] "foo")
+ MarkerProtocol
+ MarkerProtocol2)
+(deftype WillGetMarker []
+ ExampleProtocol
+ (foo [this] "foo"))
+(extend-type WillGetMarker MarkerProtocol)
+(deftest marker-tests
+ (testing "That a marker protocol has no methods"
+ (is (= '() (method-names clojure.test_clojure.protocols.examples.MarkerProtocol))))
+ (testing "That types with markers are reportedly satifying them."
+ (let [hm (HasMarkers.)
+ wgm (WillGetMarker.)]
+ (is (satisfies? MarkerProtocol hm))
+ (is (satisfies? MarkerProtocol2 hm))
+ (is (satisfies? MarkerProtocol wgm)))))
(deftype ExtendTestWidget [name])
(deftype HasProtocolInline []
2  test/clojure/test_clojure/protocols/examples.clj
@@ -11,6 +11,8 @@
(defprotocol MarkerProtocol
"a protocol with no methods")
+(defprotocol MarkerProtocol2)
(definterface ExampleInterface
(hinted [^int i])
(hinted [^String s]))
Please sign in to comment.
Something went wrong with that request. Please try again.