From cf4be2e3fac7b3925a7d97b1fc6ef60feb0e633e Mon Sep 17 00:00:00 2001
From: fogus <mefogus@gmail.com>
Date: Wed, 15 Aug 2012 15:36:26 -0400
Subject: [PATCH] Added further tests for marker protocols as defined in
 CLJ-966

---
 test/clojure/test_clojure/protocols.clj          |   26 +++++++++++++++++++---
 test/clojure/test_clojure/protocols/examples.clj |    2 ++
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/test/clojure/test_clojure/protocols.clj b/test/clojure/test_clojure/protocols.clj
index f23c1a7..f3bd9bf 100644
--- a/test/clojure/test_clojure/protocols.clj
+++ b/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 []
diff --git a/test/clojure/test_clojure/protocols/examples.clj b/test/clojure/test_clojure/protocols/examples.clj
index 2b72037..9d962d5 100644
--- a/test/clojure/test_clojure/protocols/examples.clj
+++ b/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]))
-- 
1.7.9.5

