|
155 | 155 | `(cljs.user/foo ~(tags/->JSValue []))
|
156 | 156 | '(cljs.user/foo (make-array 0))))))
|
157 | 157 |
|
158 |
| -;; CLJS-1607 |
159 |
| -;; Commented out this test - too hard coded to unnecessary details - David |
160 |
| - |
161 |
| -#_(deftest test-cljs-1607 |
162 |
| - (let [define-Foo #(assoc-in % [::ana/namespaces 'cljs.user :defs 'Foo] |
163 |
| - {:ns 'cljs.user |
164 |
| - :name 'cljs.user/Foo |
165 |
| - :protocol-symbol true |
166 |
| - :protocol-info {:methods '{foo [[this]]}} |
167 |
| - :protocol 'cljs.user/Foo}) |
168 |
| - define-foo #(assoc-in % [::ana/namespaces 'cljs.user :defs 'foo] |
169 |
| - {:ns 'cljs.user |
170 |
| - :name 'cljs.user/foo |
171 |
| - :fn-var true |
172 |
| - :method-params '([x]) |
173 |
| - :protocol 'cljs.user/Foo}) |
174 |
| - aenv-with-foo (-> aenv define-foo define-Foo) |
175 |
| - cenv-with-foo (-> @cenv define-foo define-Foo)] |
176 |
| - (binding [ana/*cljs-static-fns* true] |
177 |
| - (are [form] |
178 |
| - (empty? |
179 |
| - (capture-warnings |
180 |
| - (env/with-compiler-env (atom cenv-with-foo) |
181 |
| - (with-out-str |
182 |
| - (comp/emit |
183 |
| - (ana/analyze aenv-with-foo form)))))) |
184 |
| - '(specify! [] |
185 |
| - cljs.user/Foo |
186 |
| - (cljs.user/foo [this] |
187 |
| - :none) |
188 |
| - Object |
189 |
| - (bar [this] |
190 |
| - (cljs.user/foo this))))))) |
191 |
| - |
192 | 158 | (deftest test-cljs-1643
|
193 | 159 | (is (thrown-with-msg? Exception #"is not a valid ClojureScript constant."
|
194 | 160 | (comp/emit-constant clojure.core/inc))))
|
195 | 161 |
|
| 162 | +(def test-cljs-1925-code |
| 163 | + '(do |
| 164 | + (defprotocol X |
| 165 | + (x [x])) |
| 166 | + |
| 167 | + (defprotocol Y |
| 168 | + (y [y])) |
| 169 | + |
| 170 | + (extend-protocol X |
| 171 | + js/RegExp |
| 172 | + (x [x] |
| 173 | + (y x))) |
| 174 | + |
| 175 | + (extend-protocol Y |
| 176 | + js/RegExp |
| 177 | + (y [y] |
| 178 | + :y)))) |
| 179 | + |
| 180 | +(def specify-test-code |
| 181 | + '(do |
| 182 | + (defprotocol IBug |
| 183 | + (bug [this other] "A sample protocol")) |
| 184 | + |
| 185 | + (defn MyBug []) |
| 186 | + (specify! (.-prototype MyBug) |
| 187 | + IBug |
| 188 | + (bug [this other] |
| 189 | + "bug") |
| 190 | + Object |
| 191 | + (foo [this] |
| 192 | + (bug this 3))))) |
| 193 | + |
| 194 | +(deftest test-cljs-1925 |
| 195 | + (let [opts {:static-fns true} |
| 196 | + cenv (env/default-compiler-env opts)] |
| 197 | + (is (= [] (binding [ana/*unchecked-if* false |
| 198 | + ana/*cljs-static-fns* true] |
| 199 | + (capture-warnings |
| 200 | + (env/with-compiler-env cenv |
| 201 | + (with-out-str |
| 202 | + (comp/emit |
| 203 | + (comp/with-core-cljs |
| 204 | + opts |
| 205 | + (fn [] (ana/analyze aenv test-cljs-1925-code nil opts))))))))))) |
| 206 | + (let [opts {:static-fns true} |
| 207 | + cenv (env/default-compiler-env opts)] |
| 208 | + (is (= [] (binding [ana/*unchecked-if* false |
| 209 | + ana/*cljs-static-fns* true] |
| 210 | + (capture-warnings |
| 211 | + (env/with-compiler-env cenv |
| 212 | + (with-out-str |
| 213 | + (comp/emit |
| 214 | + (comp/with-core-cljs |
| 215 | + opts |
| 216 | + (fn [] (ana/analyze aenv specify-test-code nil opts)))))))))))) |
| 217 | + |
196 | 218 | ;; CLJS-1225
|
197 | 219 |
|
198 | 220 | (comment
|
|
0 commit comments