Mercurial > lasercutter
view src/clojure/test_clojure/metadata.clj @ 10:ef7dbbd6452c
added clojure source goodness
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 21 Aug 2010 06:25:44 -0400 |
parents | |
children |
line wrap: on
line source
1 ; Copyright (c) Rich Hickey. All rights reserved.2 ; The use and distribution terms for this software are covered by the3 ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)4 ; which can be found in the file epl-v10.html at the root of this distribution.5 ; By using this software in any fashion, you are agreeing to be bound by6 ; the terms of this license.7 ; You must not remove this notice, or any other, from this software.9 ; Authors: Stuart Halloway, Frantisek Sodomka11 (ns clojure.test-clojure.metadata12 (:use clojure.test13 [clojure.test-clojure.helpers :only (eval-in-temp-ns)]))15 (def public-namespaces16 '[clojure.core17 clojure.pprint18 clojure.inspector19 clojure.set20 clojure.stacktrace21 clojure.test22 clojure.walk23 clojure.xml24 clojure.zip25 clojure.java.io26 clojure.java.browse27 clojure.java.javadoc28 clojure.java.shell29 clojure.string])31 (doseq [ns public-namespaces]32 (require ns))34 (def public-vars35 (mapcat #(vals (ns-publics %)) public-namespaces))37 (def public-vars-with-docstrings38 (filter (comp :doc meta) public-vars))40 (deftest public-vars-with-docstrings-have-added41 (is (= [] (remove (comp :added meta) public-vars-with-docstrings))))43 (deftest interaction-of-def-with-metadata44 (testing "initial def sets metadata"45 (let [v (eval-in-temp-ns46 (def ^{:a 1} foo 0)47 #'foo)]48 (is (= 1 (-> v meta :a)))))49 (testing "subsequent declare doesn't overwrite metadata"50 (let [v (eval-in-temp-ns51 (def ^{:b 2} bar 0)52 (declare bar)53 #'bar)]54 (is (= 2 (-> v meta :b))))55 (testing "when compiled"56 (let [v (eval-in-temp-ns57 (def ^{:c 3} bar 0)58 (defn declare-bar []59 (declare bar))60 (declare-bar)61 #'bar)]62 (is (= 3 (-> v meta :c))))))63 (testing "subsequent def with init-expr *does* overwrite metadata"64 (let [v (eval-in-temp-ns65 (def ^{:d 4} quux 0)66 (def quux 1)67 #'quux)]68 (is (nil? (-> v meta :d))))69 (testing "when compiled"70 (let [v (eval-in-temp-ns71 (def ^{:e 5} quux 0)72 (defn def-quux []73 (def quux 1))74 (def-quux)75 #'quux)]76 (is (nil? (-> v meta :e)))))))