|
57 | 57 | (clojure-expected-ns))
|
58 | 58 | clj-file-ns))))))
|
59 | 59 |
|
60 |
| -(describe "clojure-namespace-name-regex" |
61 |
| - (it "should match common namespace declarations" |
62 |
| - (let ((ns "(ns foo)")) |
63 |
| - (expect (string-match clojure-namespace-name-regex ns)) |
64 |
| - (match-string 4 ns)) |
65 |
| - (let ((ns "(ns |
66 |
| - foo)")) |
67 |
| - (expect (string-match clojure-namespace-name-regex ns)) |
68 |
| - (expect (match-string 4 ns) :to-equal "foo")) |
69 |
| - (let ((ns "(ns foo.baz)")) |
70 |
| - (expect (string-match clojure-namespace-name-regex ns)) |
71 |
| - (expect (match-string 4 ns) :to-equal "foo.baz")) |
72 |
| - (let ((ns "(ns ^:bar foo)")) |
73 |
| - (expect (string-match clojure-namespace-name-regex ns)) |
74 |
| - (expect (match-string 4 ns) :to-equal "foo")) |
75 |
| - (let ((ns "(ns ^:bar ^:baz foo)")) |
76 |
| - (expect (string-match clojure-namespace-name-regex ns)) |
77 |
| - (expect (match-string 4 ns) :to-equal "foo")) |
78 |
| - (let ((ns "(ns ^{:bar true} foo)")) |
79 |
| - (expect (string-match clojure-namespace-name-regex ns)) |
80 |
| - (expect (match-string 4 ns) :to-equal "foo")) |
81 |
| - (let ((ns "(ns #^{:bar true} foo)")) |
82 |
| - (expect (string-match clojure-namespace-name-regex ns)) |
83 |
| - (expect (match-string 4 ns) :to-equal "foo")) |
84 |
| - ;; TODO |
85 |
| - ;; (let ((ns "(ns #^{:fail {}} foo)")) |
86 |
| - ;; (should (string-match clojure-namespace-name-regex ns)) |
87 |
| - ;; (match-string 4 ns)) |
88 |
| - ;; (let ((ns "(ns ^{:fail2 {}} foo.baz)")) |
89 |
| - ;; (should (string-match clojure-namespace-name-regex ns)) |
90 |
| - ;; (should (equal "foo.baz" (match-string 4 ns)))) |
91 |
| - (let ((ns "(ns ^{} foo)")) |
92 |
| - (expect (string-match clojure-namespace-name-regex ns)) |
93 |
| - (expect (match-string 4 ns) :to-equal "foo")) |
94 |
| - (let ((ns "(ns ^{:skip-wiki true} |
95 |
| - aleph.netty")) |
96 |
| - (expect (string-match clojure-namespace-name-regex ns)) |
97 |
| - (expect (match-string 4 ns) :to-equal "aleph.netty")) |
98 |
| - (let ((ns "(ns foo+)")) |
99 |
| - (expect (string-match clojure-namespace-name-regex ns)) |
100 |
| - (expect (match-string 4 ns) :to-equal "foo+")))) |
| 60 | +(describe "clojure-find-ns" |
| 61 | + (it "should find common namespace declarations" |
| 62 | + (with-clojure-buffer "(ns foo)" |
| 63 | + (expect (clojure-find-ns) :to-equal "foo")) |
| 64 | + (with-clojure-buffer "(ns |
| 65 | + foo)" |
| 66 | + (expect (clojure-find-ns) :to-equal "foo")) |
| 67 | + (with-clojure-buffer "(ns foo.baz)" |
| 68 | + (expect (clojure-find-ns) :to-equal "foo.baz")) |
| 69 | + (with-clojure-buffer "(ns ^:bar foo)" |
| 70 | + (expect (clojure-find-ns) :to-equal "foo")) |
| 71 | + (with-clojure-buffer "(ns ^:bar ^:baz foo)" |
| 72 | + (expect (clojure-find-ns) :to-equal "foo"))) |
| 73 | + (it "should find namespace declarations with nested metadata and docstrings" |
| 74 | + (with-clojure-buffer "(ns ^{:bar true} foo)" |
| 75 | + (expect (clojure-find-ns) :to-equal "foo")) |
| 76 | + (with-clojure-buffer "(ns #^{:bar true} foo)" |
| 77 | + (expect (clojure-find-ns) :to-equal "foo")) |
| 78 | + (with-clojure-buffer "(ns #^{:fail {}} foo)" |
| 79 | + (expect (clojure-find-ns) :to-equal "foo")) |
| 80 | + (with-clojure-buffer "(ns ^{:fail2 {}} foo.baz)" |
| 81 | + (expect (clojure-find-ns) :to-equal "foo.baz")) |
| 82 | + (with-clojure-buffer "(ns ^{} foo)" |
| 83 | + (expect (clojure-find-ns) :to-equal "foo")) |
| 84 | + (with-clojure-buffer "(ns ^{:skip-wiki true} |
| 85 | + aleph.netty" |
| 86 | + (expect (clojure-find-ns) :to-equal "aleph.netty")) |
| 87 | + (with-clojure-buffer "(ns ^{:foo {:bar :baz} :fake (ns in.meta)} foo |
| 88 | + \"docstring |
| 89 | +(ns misleading)\")" |
| 90 | + (expect (clojure-find-ns) :to-equal "foo"))) |
| 91 | + (it "should support non-alphanumeric characters" |
| 92 | + (with-clojure-buffer "(ns foo+)" |
| 93 | + (expect (clojure-find-ns) :to-equal "foo+")) |
| 94 | + (with-clojure-buffer "(ns bar**baz$-_quux)" |
| 95 | + (expect (clojure-find-ns) :to-equal "bar**baz$-_quux"))) |
| 96 | + (it "should support in-ns forms" |
| 97 | + (with-clojure-buffer "(in-ns 'bar.baz)" |
| 98 | + (expect (clojure-find-ns) :to-equal "bar.baz"))) |
| 99 | + (it "should take the closest ns before point" |
| 100 | + (with-clojure-buffer " (ns foo1) |
| 101 | +
|
| 102 | +(ns foo2)" |
| 103 | + (expect (clojure-find-ns) :to-equal "foo2")) |
| 104 | + (with-clojure-buffer " (in-ns foo1) |
| 105 | +(ns 'foo2) |
| 106 | +(in-ns 'foo3) |
| 107 | +| |
| 108 | +(ns foo4)" |
| 109 | + (re-search-backward "|") |
| 110 | + (expect (clojure-find-ns) :to-equal "foo3")))) |
101 | 111 |
|
102 | 112 | (describe "clojure-sort-ns"
|
103 | 113 | (it "should sort requires in a basic ns"
|
|
0 commit comments