 ;;         (is (= "xoxo" (.hinted r "xo")))))))
 
 
-;; ; see CLJ-845
-;; (defprotocol SyntaxQuoteTestProtocol
-;;   (sqtp [p]))
-
-;; (defmacro try-extend-type [c]
-;;   `(extend-type ~c
-;;      SyntaxQuoteTestProtocol
-;;      (sqtp [p#] p#)))
-
-;; (defmacro try-extend-protocol [c]
-;;   `(extend-protocol SyntaxQuoteTestProtocol
-;;      ~c
-;;      (sqtp [p#] p#)))
-
-;; (try-extend-type String)
-;; (try-extend-protocol clojure.lang.Keyword)
-
-;; (deftest test-no-ns-capture
-;;   (is (= "foo" (sqtp "foo")))
-;;   (is (= :foo (sqtp :foo))))
-
-
-;; (defprotocol Dasherizer
-;;   (-do-dashed [this]))
-;; (deftype Dashed []
-;;   Dasherizer
-;;   (-do-dashed [this] 10))
-
-;; (deftest test-leading-dashes
-;;   (is (= 10 (-do-dashed (Dashed.))))
-;;   (is (= [10] (map -do-dashed [(Dashed.)]))))
+; see CLJ-845
+(defprotocol SyntaxQuoteTestProtocol
+  (sqtp [p]))
+
+(defmacro try-extend-type [c]
+  `(extend-type ~c
+     SyntaxQuoteTestProtocol
+     (sqtp [p#] p#)))
+
+(defmacro try-extend-protocol [c]
+  `(extend-protocol SyntaxQuoteTestProtocol
+     ~c
+     (sqtp [p#] p#)))
+
+(try-extend-type clojerl.String)
+(try-extend-protocol clojerl.Keyword)
+
+(deftest test-no-ns-capture
+  (is (= "foo" (sqtp "foo")))
+  (is (= :foo (sqtp :foo))))
+
+(defprotocol Dasherizer
+  (-do-dashed [this]))
+(deftype Dashed []
+  Dasherizer
+  (-do-dashed [this] 10))
+
+(deftest test-leading-dashes
+  (is (= 10 (-do-dashed (new Dashed))))
+  (is (= [10] (map -do-dashed [(new Dashed)]))))

          #"No implementation of method: :foo of protocol: :clojure.test-clojure.protocols.examples.ExampleProtocol found for type: :clojerl.Integer"
          (foo 10))))
  (testing "protocols generate a corresponding interface using _ instead of - for method names"
    (is (= ["bar" "baz" "baz" "foo" "with_quux"] (method-names clojure.test-clojure.protocols.examples.ExampleProtocol))))
  (testing "error conditions checked when defining protocols"
    (is (thrown-with-msg?
         :throw

  (:use clojure.test clojure.test-clojure.protocols.examples)
  (:require [clojure.test-clojure.protocols.more-examples :as other]
            [clojure.set :as set]
            [clojure.string :as str]
            clojure.test-helper)
  (:import [clojure.test-clojure.protocols.examples
            ExampleProtocol
            MarkerProtocol
            MarkerProtocol2]))

(defn delete-module [module]
  (doto module
    code/purge.e
    code/delete.e
    (-> code/which.e file/delete.e)))

(defn find-protocol-impls
  [protocol]
  (let [type->str #(subs (str %) 1)
        prefix (type->str protocol)
        f (fn [[module path]]
            (str/starts-with? (type->str module) prefix))]
    (->> (code/all_loaded.e)
         (filter f)
         (map first))))

(defn clean-protocol [protocol]
  (doseq [m (find-protocol-impls protocol)]
    (delete-module m)))

;; temporary hack until I decide how to cleanly reload protocol
;; this no longer works
(defn reload-example-protocols
  []
  ;; (clean-protocol ExampleProtocol)
  ;; (clean-protocol other/SimpleProtocol)

  ;; (alter-var-root #'clojure.test-clojure.protocols.examples/ExampleProtocol
  ;;                 assoc :impls {})
  ;; (alter-var-root #'clojure.test-clojure.protocols.more-examples/SimpleProtocol
  ;;                 assoc :impls {})

  #_(require :reload
           'clojure.test-clojure.protocols.examples
           'clojure.test-clojure.protocols.more-examples))

