|
67 | 67 | '(defonce just-var) "(def just-var 888)"})))) |
68 | 68 |
|
69 | 69 | (defn meta= [a b] |
70 | | - (= (dissoc (meta a) :ns) (dissoc (meta b) :ns))) |
| 70 | + (= (dissoc (meta a) :ns :file) (dissoc (meta b) :ns :file))) |
71 | 71 |
|
72 | 72 | (deftest keep-vars-test |
73 | 73 | (tu/init 'clj-reload.keep-vars) |
|
129 | 129 | (is (thrown? Exception (tu/reload))))) |
130 | 130 |
|
131 | 131 | (deftest keep-type-test |
132 | | - (tu/init 'clj-reload.keep-deftype) |
133 | | - (let [ns (find-ns 'clj-reload.keep-deftype) |
134 | | - normal-new @(ns-resolve ns 'type-normal-new) |
135 | | - normal-factory @(ns-resolve ns 'type-normal-factory) |
136 | | - keep-new @(ns-resolve ns 'type-keep-new) |
137 | | - keep-factory @(ns-resolve ns 'type-keep-factory) |
138 | | - _ (tu/touch 'clj-reload.keep-deftype) |
139 | | - _ (tu/reload) |
140 | | - ns' (find-ns 'clj-reload.keep-deftype)] |
141 | | - (is (not= normal-new @(ns-resolve ns' 'type-normal-new))) |
142 | | - (is (not (identical? (class normal-new) (class @(ns-resolve ns' 'type-normal-new))))) |
143 | | - |
144 | | - (is (not= normal-factory @(ns-resolve ns' 'type-normal-factory))) |
145 | | - (is (not (identical? (class normal-factory) (class @(ns-resolve ns' 'type-normal-factory))))) |
146 | | - |
147 | | - (is (not (identical? keep-new @(ns-resolve ns' 'type-keep-new)))) |
148 | | - (is (= keep-new @(ns-resolve ns' 'type-keep-new))) |
149 | | - (is (identical? (class keep-new) (class @(ns-resolve ns' 'type-keep-new)))) |
| 132 | + (when-not (tu/babashka?) |
| 133 | + (tu/init 'clj-reload.keep-deftype) |
| 134 | + (let [ns (find-ns 'clj-reload.keep-deftype) |
| 135 | + normal-new @(ns-resolve ns 'type-normal-new) |
| 136 | + normal-factory @(ns-resolve ns 'type-normal-factory) |
| 137 | + keep-new @(ns-resolve ns 'type-keep-new) |
| 138 | + keep-factory @(ns-resolve ns 'type-keep-factory) |
| 139 | + _ (tu/touch 'clj-reload.keep-deftype) |
| 140 | + _ (tu/reload) |
| 141 | + ns' (find-ns 'clj-reload.keep-deftype)] |
| 142 | + (is (not= normal-new @(ns-resolve ns' 'type-normal-new))) |
| 143 | + (is (not (identical? (class normal-new) (class @(ns-resolve ns' 'type-normal-new))))) |
| 144 | + |
| 145 | + (is (not= normal-factory @(ns-resolve ns' 'type-normal-factory))) |
| 146 | + (is (not (identical? (class normal-factory) (class @(ns-resolve ns' 'type-normal-factory))))) |
| 147 | + |
| 148 | + (is (not (identical? keep-new @(ns-resolve ns' 'type-keep-new)))) |
| 149 | + (is (= keep-new @(ns-resolve ns' 'type-keep-new))) |
| 150 | + (is (identical? (class keep-new) (class @(ns-resolve ns' 'type-keep-new)))) |
150 | 151 |
|
151 | | - (is (not (identical? keep-factory @(ns-resolve ns' 'type-keep-factory)))) |
152 | | - (is (= keep-factory @(ns-resolve ns' 'type-keep-factory))) |
153 | | - (is (identical? (class keep-factory) (class @(ns-resolve ns' 'type-keep-factory)))))) |
| 152 | + (is (not (identical? keep-factory @(ns-resolve ns' 'type-keep-factory)))) |
| 153 | + (is (= keep-factory @(ns-resolve ns' 'type-keep-factory))) |
| 154 | + (is (identical? (class keep-factory) (class @(ns-resolve ns' 'type-keep-factory))))))) |
154 | 155 |
|
155 | 156 | (deftest keep-record-test |
156 | | - (tu/init 'clj-reload.keep-defrecord) |
157 | | - (let [ns (find-ns 'clj-reload.keep-defrecord) |
158 | | - normal-new @(ns-resolve ns 'record-normal-new) |
159 | | - normal-factory @(ns-resolve ns 'record-normal-factory) |
160 | | - normal-map-factory @(ns-resolve ns 'record-normal-map-factory) |
161 | | - keep-new @(ns-resolve ns 'record-keep-new) |
162 | | - keep-factory @(ns-resolve ns 'record-keep-factory) |
163 | | - keep-map-factory @(ns-resolve ns 'record-keep-map-factory) |
164 | | - _ (tu/touch 'clj-reload.keep-defrecord) |
165 | | - _ (tu/reload) |
166 | | - ns' (find-ns 'clj-reload.keep-defrecord)] |
167 | | - (is (not= normal-new @(ns-resolve ns' 'record-normal-new))) |
168 | | - (is (not (identical? (class normal-new) (class @(ns-resolve ns' 'record-normal-new))))) |
169 | | - |
170 | | - (is (not= normal-factory @(ns-resolve ns' 'record-normal-factory))) |
171 | | - (is (not (identical? (class normal-factory) (class @(ns-resolve ns' 'record-normal-factory))))) |
172 | | - |
173 | | - (is (not= normal-map-factory @(ns-resolve ns' 'record-normal-map-factory))) |
174 | | - (is (not (identical? (class normal-map-factory) (class @(ns-resolve ns' 'record-normal-map-factory))))) |
175 | | - |
176 | | - (is (not (identical? keep-new @(ns-resolve ns' 'record-keep-new)))) |
177 | | - (is (= keep-new @(ns-resolve ns' 'record-keep-new))) |
178 | | - (is (identical? (class keep-new) (class @(ns-resolve ns' 'record-keep-new)))) |
| 157 | + (when-not (tu/babashka?) |
| 158 | + (tu/init 'clj-reload.keep-defrecord) |
| 159 | + (let [ns (find-ns 'clj-reload.keep-defrecord) |
| 160 | + normal-new @(ns-resolve ns 'record-normal-new) |
| 161 | + normal-factory @(ns-resolve ns 'record-normal-factory) |
| 162 | + normal-map-factory @(ns-resolve ns 'record-normal-map-factory) |
| 163 | + keep-new @(ns-resolve ns 'record-keep-new) |
| 164 | + keep-factory @(ns-resolve ns 'record-keep-factory) |
| 165 | + keep-map-factory @(ns-resolve ns 'record-keep-map-factory) |
| 166 | + _ (tu/touch 'clj-reload.keep-defrecord) |
| 167 | + _ (tu/reload) |
| 168 | + ns' (find-ns 'clj-reload.keep-defrecord)] |
| 169 | + (is (not= normal-new @(ns-resolve ns' 'record-normal-new))) |
| 170 | + (is (not (identical? (class normal-new) (class @(ns-resolve ns' 'record-normal-new))))) |
| 171 | + |
| 172 | + (is (not= normal-factory @(ns-resolve ns' 'record-normal-factory))) |
| 173 | + (is (not (identical? (class normal-factory) (class @(ns-resolve ns' 'record-normal-factory))))) |
| 174 | + |
| 175 | + (is (not= normal-map-factory @(ns-resolve ns' 'record-normal-map-factory))) |
| 176 | + (is (not (identical? (class normal-map-factory) (class @(ns-resolve ns' 'record-normal-map-factory))))) |
| 177 | + |
| 178 | + (is (not (identical? keep-new @(ns-resolve ns' 'record-keep-new)))) |
| 179 | + (is (= keep-new @(ns-resolve ns' 'record-keep-new))) |
| 180 | + (is (identical? (class keep-new) (class @(ns-resolve ns' 'record-keep-new)))) |
179 | 181 |
|
180 | | - (is (not (identical? keep-factory @(ns-resolve ns' 'record-keep-factory)))) |
181 | | - (is (= keep-factory @(ns-resolve ns' 'record-keep-factory))) |
182 | | - (is (identical? (class keep-factory) (class @(ns-resolve ns' 'record-keep-factory)))) |
183 | | - |
184 | | - (is (not (identical? keep-map-factory @(ns-resolve ns' 'record-keep-map-factory)))) |
185 | | - (is (= keep-map-factory @(ns-resolve ns' 'record-keep-map-factory))) |
186 | | - (is (identical? (class keep-map-factory) (class @(ns-resolve ns' 'record-keep-map-factory)))))) |
| 182 | + (is (not (identical? keep-factory @(ns-resolve ns' 'record-keep-factory)))) |
| 183 | + (is (= keep-factory @(ns-resolve ns' 'record-keep-factory))) |
| 184 | + (is (identical? (class keep-factory) (class @(ns-resolve ns' 'record-keep-factory)))) |
| 185 | + |
| 186 | + (is (not (identical? keep-map-factory @(ns-resolve ns' 'record-keep-map-factory)))) |
| 187 | + (is (= keep-map-factory @(ns-resolve ns' 'record-keep-map-factory))) |
| 188 | + (is (identical? (class keep-map-factory) (class @(ns-resolve ns' 'record-keep-map-factory))))))) |
187 | 189 |
|
188 | 190 | (defmethod reload/keep-methods 'deftype+ [_] |
189 | 191 | (reload/keep-methods 'deftype)) |
190 | 192 |
|
191 | 193 | (deftest keep-custom-def-test |
192 | | - (tu/init 'clj-reload.keep-custom) |
193 | | - (let [ns (find-ns 'clj-reload.keep-custom) |
194 | | - ctor @(ns-resolve ns '->CustomTypeKeep) |
195 | | - value @(ns-resolve ns 'custom-type-keep) |
196 | | - _ (tu/touch 'clj-reload.keep-custom) |
197 | | - _ (tu/reload) |
198 | | - ns' (find-ns 'clj-reload.keep-custom)] |
199 | | - (is (identical? ctor @(ns-resolve ns' '->CustomTypeKeep))) |
200 | | - (is (identical? (class value) (class @(ns-resolve ns' 'custom-type-keep)))))) |
| 194 | + (when-not (tu/babashka?) |
| 195 | + (tu/init 'clj-reload.keep-custom) |
| 196 | + (let [ns (find-ns 'clj-reload.keep-custom) |
| 197 | + ctor @(ns-resolve ns '->CustomTypeKeep) |
| 198 | + value @(ns-resolve ns 'custom-type-keep) |
| 199 | + _ (tu/touch 'clj-reload.keep-custom) |
| 200 | + _ (tu/reload) |
| 201 | + ns' (find-ns 'clj-reload.keep-custom)] |
| 202 | + (is (identical? ctor @(ns-resolve ns' '->CustomTypeKeep))) |
| 203 | + (is (identical? (class value) (class @(ns-resolve ns' 'custom-type-keep))))))) |
201 | 204 |
|
202 | 205 | (deftest keep-protocol-test |
203 | | - (tu/init 'clj-reload.keep-defprotocol) |
204 | | - (let [ns (find-ns 'clj-reload.keep-defprotocol) |
205 | | - proto @(ns-resolve ns 'IProto) |
206 | | - method @(ns-resolve ns '-method) |
207 | | - rec-inline @(ns-resolve ns 'rec-inline) |
208 | | - rec-extend-proto @(ns-resolve ns 'rec-extend-proto) |
209 | | - rec-extend-type @(ns-resolve ns 'rec-extend-type) |
210 | | - rec-extend @(ns-resolve ns 'rec-extend) |
211 | | - extend-meta @(ns-resolve ns 'extend-meta) |
212 | | - |
213 | | - _ (tu/touch 'clj-reload.keep-defprotocol) |
214 | | - _ (tu/reload) |
215 | | - |
216 | | - ns' (find-ns 'clj-reload.keep-defprotocol) |
217 | | - proto' @(ns-resolve ns' 'IProto) |
218 | | - method' @(ns-resolve ns' '-method) |
219 | | - rec-inline' @(ns-resolve ns' 'rec-inline) |
220 | | - rec-extend-proto' @(ns-resolve ns' 'rec-extend-proto) |
221 | | - rec-extend-type' @(ns-resolve ns' 'rec-extend-type) |
222 | | - rec-extend' @(ns-resolve ns' 'rec-extend) |
223 | | - extend-meta' @(ns-resolve ns' 'extend-meta)] |
224 | | - |
225 | | - ;; make sure reload happened |
226 | | - (is (not (identical? rec-inline rec-inline'))) |
227 | | - (is (not (identical? (class rec-inline) (class rec-inline')))) |
228 | | - |
229 | | - (is (satisfies? proto rec-inline)) |
230 | | - (is (satisfies? proto rec-inline')) |
231 | | - (is (satisfies? proto' rec-inline)) |
232 | | - (is (satisfies? proto' rec-inline')) |
233 | | - (is (= :rec-inline (method rec-inline))) |
234 | | - (is (= :rec-inline (method rec-inline'))) |
235 | | - (is (= :rec-inline (method' rec-inline))) |
236 | | - (is (= :rec-inline (method' rec-inline'))) |
237 | | - |
238 | | - (is (satisfies? proto rec-extend-proto)) |
239 | | - ; (is (satisfies? proto rec-extend-proto')) |
240 | | - (is (satisfies? proto' rec-extend-proto)) |
241 | | - (is (satisfies? proto' rec-extend-proto')) |
242 | | - (is (= :rec-extend-proto (method rec-extend-proto))) |
243 | | - ; (is (= :rec-extend-proto (method rec-extend-proto'))) |
244 | | - (is (= :rec-extend-proto (method' rec-extend-proto))) |
245 | | - (is (= :rec-extend-proto (method' rec-extend-proto'))) |
246 | | - |
247 | | - (is (satisfies? proto rec-extend-type)) |
248 | | - ; (is (satisfies? proto rec-extend-type')) |
249 | | - (is (satisfies? proto' rec-extend-type)) |
250 | | - (is (satisfies? proto' rec-extend-type')) |
251 | | - (is (= :rec-extend-type (method rec-extend-type))) |
252 | | - ; (is (= :rec-extend-type (method rec-extend-type'))) |
253 | | - (is (= :rec-extend-type (method' rec-extend-type))) |
254 | | - (is (= :rec-extend-type (method' rec-extend-type'))) |
255 | | - |
256 | | - (is (satisfies? proto rec-extend)) |
257 | | - ; (is (satisfies? proto rec-extend')) |
258 | | - (is (satisfies? proto' rec-extend)) |
259 | | - (is (satisfies? proto' rec-extend')) |
260 | | - (is (= :rec-extend (method rec-extend))) |
261 | | - ; (is (= :rec-extend (method rec-extend'))) |
262 | | - (is (= :rec-extend (method' rec-extend))) |
263 | | - (is (= :rec-extend (method' rec-extend'))) |
264 | | - |
265 | | - ; (is (satisfies? proto extend-meta)) |
266 | | - ; (is (satisfies? proto extend-meta')) |
267 | | - ; (is (satisfies? proto' extend-meta)) |
268 | | - ; (is (satisfies? proto' extend-meta')) |
269 | | - (is (= :extend-meta (method extend-meta))) |
270 | | - (is (= :extend-meta (method extend-meta'))) |
271 | | - (is (= :extend-meta (method' extend-meta))) |
272 | | - (is (= :extend-meta (method' extend-meta'))))) |
| 206 | + (when-not (tu/babashka?) |
| 207 | + (tu/init 'clj-reload.keep-defprotocol) |
| 208 | + (let [ns (find-ns 'clj-reload.keep-defprotocol) |
| 209 | + proto @(ns-resolve ns 'IProto) |
| 210 | + method @(ns-resolve ns '-method) |
| 211 | + rec-inline @(ns-resolve ns 'rec-inline) |
| 212 | + rec-extend-proto @(ns-resolve ns 'rec-extend-proto) |
| 213 | + rec-extend-type @(ns-resolve ns 'rec-extend-type) |
| 214 | + rec-extend @(ns-resolve ns 'rec-extend) |
| 215 | + extend-meta @(ns-resolve ns 'extend-meta) |
| 216 | + |
| 217 | + _ (tu/touch 'clj-reload.keep-defprotocol) |
| 218 | + _ (tu/reload) |
| 219 | + |
| 220 | + ns' (find-ns 'clj-reload.keep-defprotocol) |
| 221 | + proto' @(ns-resolve ns' 'IProto) |
| 222 | + method' @(ns-resolve ns' '-method) |
| 223 | + rec-inline' @(ns-resolve ns' 'rec-inline) |
| 224 | + rec-extend-proto' @(ns-resolve ns' 'rec-extend-proto) |
| 225 | + rec-extend-type' @(ns-resolve ns' 'rec-extend-type) |
| 226 | + rec-extend' @(ns-resolve ns' 'rec-extend) |
| 227 | + extend-meta' @(ns-resolve ns' 'extend-meta)] |
| 228 | + |
| 229 | + ;; make sure reload happened |
| 230 | + (is (not (identical? rec-inline rec-inline'))) |
| 231 | + (is (not (identical? (class rec-inline) (class rec-inline')))) |
| 232 | + |
| 233 | + (is (satisfies? proto rec-inline)) |
| 234 | + (is (satisfies? proto rec-inline')) |
| 235 | + (is (satisfies? proto' rec-inline)) |
| 236 | + (is (satisfies? proto' rec-inline')) |
| 237 | + (is (= :rec-inline (method rec-inline))) |
| 238 | + (is (= :rec-inline (method rec-inline'))) |
| 239 | + (is (= :rec-inline (method' rec-inline))) |
| 240 | + (is (= :rec-inline (method' rec-inline'))) |
| 241 | + |
| 242 | + (is (satisfies? proto rec-extend-proto)) |
| 243 | + ; (is (satisfies? proto rec-extend-proto')) |
| 244 | + (is (satisfies? proto' rec-extend-proto)) |
| 245 | + (is (satisfies? proto' rec-extend-proto')) |
| 246 | + (is (= :rec-extend-proto (method rec-extend-proto))) |
| 247 | + ; (is (= :rec-extend-proto (method rec-extend-proto'))) |
| 248 | + (is (= :rec-extend-proto (method' rec-extend-proto))) |
| 249 | + (is (= :rec-extend-proto (method' rec-extend-proto'))) |
| 250 | + |
| 251 | + (is (satisfies? proto rec-extend-type)) |
| 252 | + ; (is (satisfies? proto rec-extend-type')) |
| 253 | + (is (satisfies? proto' rec-extend-type)) |
| 254 | + (is (satisfies? proto' rec-extend-type')) |
| 255 | + (is (= :rec-extend-type (method rec-extend-type))) |
| 256 | + ; (is (= :rec-extend-type (method rec-extend-type'))) |
| 257 | + (is (= :rec-extend-type (method' rec-extend-type))) |
| 258 | + (is (= :rec-extend-type (method' rec-extend-type'))) |
| 259 | + |
| 260 | + (is (satisfies? proto rec-extend)) |
| 261 | + ; (is (satisfies? proto rec-extend')) |
| 262 | + (is (satisfies? proto' rec-extend)) |
| 263 | + (is (satisfies? proto' rec-extend')) |
| 264 | + (is (= :rec-extend (method rec-extend))) |
| 265 | + ; (is (= :rec-extend (method rec-extend'))) |
| 266 | + (is (= :rec-extend (method' rec-extend))) |
| 267 | + (is (= :rec-extend (method' rec-extend'))) |
| 268 | + |
| 269 | + ; (is (satisfies? proto extend-meta)) |
| 270 | + ; (is (satisfies? proto extend-meta')) |
| 271 | + ; (is (satisfies? proto' extend-meta)) |
| 272 | + ; (is (satisfies? proto' extend-meta')) |
| 273 | + (is (= :extend-meta (method extend-meta))) |
| 274 | + (is (= :extend-meta (method extend-meta'))) |
| 275 | + (is (= :extend-meta (method' extend-meta))) |
| 276 | + (is (= :extend-meta (method' extend-meta')))))) |
273 | 277 |
|
274 | 278 | (deftest keep-dependent-test |
275 | 279 | (tu/init 'clj-reload.keep-downstream) |
|
0 commit comments