 ;;           (read-string "#java.util.Locale[\"\" \"\" \"\" \"\"]")))
 ;;     (is (thrown? Exception (read-string "#java.util.Nachos(\"en\")")))))
 
-;; (defrecord RecordToTestPrinting [a b])
-;; (deftest defrecord-printing
-;;   (testing "that the default printer gives the proper representation"
-;;     (let [r   (RecordToTestPrinting. 1 2)]
-;;       (is (= "#clojure.test-clojure.protocols.RecordToTestPrinting{:a 1, :b 2}"
-;;              (pr-str r)))
-;;       (is (= "#clojure.test-clojure.protocols.RecordToTestPrinting[1, 2]"
-;;              (binding [*print-dup* true] (pr-str r))))
-;;       (is (= "#clojure.test-clojure.protocols.RecordToTestPrinting{:a 1, :b 2}"
-;;              (binding [*print-dup* true *verbose-defrecords* true] (pr-str r)))))))
+(defrecord RecordToTestPrinting [a b])
+(deftest defrecord-printing
+  (testing "that the default printer gives the proper representation"
+    (let [r   (new RecordToTestPrinting 1 2)]
+      (is (= "#clojure.test-clojure.protocols.RecordToTestPrinting{:a 1, :b 2}"
+             (pr-str r)))
+      (is (= "#clojure.test-clojure.protocols.RecordToTestPrinting[1, 2]"
+             (binding [*print-dup* true] (pr-str r))))
+      (is (= "#clojure.test-clojure.protocols.RecordToTestPrinting{:a 1, :b 2}"
+             (binding [*print-dup* true *verbose-defrecords* true] (pr-str r)))))))
 
 ;; (defrecord RecordToTest__ [__a ___b])
 ;; (defrecord TypeToTest__   [__a ___b])


(deftype ExtendsTestWidget []
  ExampleProtocol)

(deftest extends?-test
  ;; (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

  (: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))

