Mercurial > lasercutter
comparison 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 |
comparison
equal
deleted
inserted
replaced
9:35cf337adfcf | 10:ef7dbbd6452c |
---|---|
1 ; Copyright (c) Rich Hickey. All rights reserved. | |
2 ; The use and distribution terms for this software are covered by the | |
3 ; 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 by | |
6 ; the terms of this license. | |
7 ; You must not remove this notice, or any other, from this software. | |
8 | |
9 ; Authors: Stuart Halloway, Frantisek Sodomka | |
10 | |
11 (ns clojure.test-clojure.metadata | |
12 (:use clojure.test | |
13 [clojure.test-clojure.helpers :only (eval-in-temp-ns)])) | |
14 | |
15 (def public-namespaces | |
16 '[clojure.core | |
17 clojure.pprint | |
18 clojure.inspector | |
19 clojure.set | |
20 clojure.stacktrace | |
21 clojure.test | |
22 clojure.walk | |
23 clojure.xml | |
24 clojure.zip | |
25 clojure.java.io | |
26 clojure.java.browse | |
27 clojure.java.javadoc | |
28 clojure.java.shell | |
29 clojure.string]) | |
30 | |
31 (doseq [ns public-namespaces] | |
32 (require ns)) | |
33 | |
34 (def public-vars | |
35 (mapcat #(vals (ns-publics %)) public-namespaces)) | |
36 | |
37 (def public-vars-with-docstrings | |
38 (filter (comp :doc meta) public-vars)) | |
39 | |
40 (deftest public-vars-with-docstrings-have-added | |
41 (is (= [] (remove (comp :added meta) public-vars-with-docstrings)))) | |
42 | |
43 (deftest interaction-of-def-with-metadata | |
44 (testing "initial def sets metadata" | |
45 (let [v (eval-in-temp-ns | |
46 (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-ns | |
51 (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-ns | |
57 (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-ns | |
65 (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-ns | |
71 (def ^{:e 5} quux 0) | |
72 (defn def-quux [] | |
73 (def quux 1)) | |
74 (def-quux) | |
75 #'quux)] | |
76 (is (nil? (-> v meta :e))))))) |