 
 (deftype ExtendsTestWidget []
   ExampleProtocol)
-
 (deftest extends?-test
-  ;; (reload-example-protocols)
+  (reload-example-protocols)
   (testing "returns false if a type does not implement the protocol at all"
     (is (false? (extends? other/SimpleProtocol ExtendsTestWidget))))
   (testing "returns true if a type implements the protocol directly" ;; semantics changed 4/15/2010

          #"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))

