test-utilities.script 22.7 KB
Newer Older
1
;;; -*- Lisp -*-
2

3
#+(and sbcl os-windows) (trace sb-ext:run-program)
4
(proclaim '(optimize (debug 3) (speed 1) (safety 3) (compilation-speed 0)))
5

6
7
(defun getcwd-from-run-program ()
  (uiop:parse-native-namestring
8
9
10
11
   (nest
    ;; TODO: fix run-program to use POWERSHELL.EXE rather than CMD, and remove this kluge.
    #+os-windows (string-trim " ")
    (run-program
12
13
14
     (os-cond
       ((os-unix-p) '("pwd" "-P"))
       ((os-windows-p) "cd"))
15
     :output '(:string :stripped t)))
16
17
   :ensure-directory t))

18
19
20
21
22
23
24
25
26
(defun simplify-pathname-directory (pathname)
  (setf pathname (ensure-pathname pathname))
  (when pathname
    (make-pathname :defaults pathname :directory (simplify-pathname-directory-component (pathname-directory pathname)))))

(defun simplify-pathname-directory-component (dir)
  (setf dir (normalize-pathname-directory-component dir))
  (loop
   :with head = (progn
Robert Goldman's avatar
Robert Goldman committed
27
28
                  (unless (and (consp dir) (cdr dir)) (return dir))
                  (subseq dir 0 1))
29
30
31
32
33
34
35
   :with tail = (rest dir)
   :for (next rest) :on tail :do
   (unless (equal next ".")
     (when (member next '(".." :up) :test 'equal) (setf next :back))
     (setf head (merge-pathname-directory-components (list :relative next) head)))
   :finally (return head)))

36
37
38
39
40
41
42
43
(let ((asdf-directory (truename *asdf-directory*))
      (test-directory (truename *test-directory*)))
  (labels ((check-cwd (dir)
             (assert-pathname-equal dir (getcwd))
             #-(and sbcl os-windows)
             (assert-pathname-equal dir (getcwd-from-run-program)))
           (check-true-dpd (dir)
             (assert-pathname-equal dir (get-pathname-defaults))
44
45
             (assert-pathname-equal dir (simplify-pathname-directory (truename #p"./")))
             (assert-pathname-equal dir (simplify-pathname-directory (truename* #p"./"))))
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
           (check-file-exists (file &optional true)
             (setf file (parse-unix-namestring file))
             (if true
                 (assert-pathname-equal true (probe-file file))
                 (setf true (probe-file file)))
             (assert-pathname-equal true (truename file))
             (assert-pathname-equal true (truename* file))
             (assert-pathname-equal true (probe-file* file :truename t))
             (assert-pathname-equal true (ensure-absolute-pathname (probe-file* file) 'get-pathname-defaults)))
           (check-file-doesnt-exist (file)
             (setf file (parse-unix-namestring file))
             (assert-equal nil (probe-file* file))
             (assert-equal nil (probe-file file)))
           (check-directory-exists (file &optional true)
             (setf file (parse-unix-namestring file))
             (let ((dir (truename (ensure-directory-pathname file))))
               (if true
                   (assert-pathname-equal true dir)
                   (setf true dir)))
             (assert-pathname-equal true (truename (ensure-directory-pathname file)))
66
             (assert-pathname-equal true (nest #+(and clisp os-windows) (ensure-directory-pathname)
67
                                               (truename* file)))
68
69
70
71
             (assert-pathname-equal true
                                    (let ((path (probe-file* file :truename t)))
                                      #+(or allegro (and clisp os-windows)) (ensure-directory-pathname path)
                                      #-(or allegro (and clisp os-windows)) path))
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
             (assert-pathname-equal true (if-let (x (probe-file* file))
                                           (ensure-absolute-pathname (ensure-directory-pathname x) 'get-pathname-defaults))))
           (check-directory-doesnt-exist (file)
             (setf file (parse-unix-namestring file))
             (assert-equal nil (probe-file* file)))
           (check-true-dpd-asdf ()
             (check-true-dpd asdf-directory)
             (check-file-exists "asdf.asd")
             (check-file-exists "test/test-utilities.script")
             (check-directory-exists "tools/")
             (check-directory-exists "tools")
             (check-file-doesnt-exist "test-utilities.script")
             (check-directory-doesnt-exist "stamp-propagation/"))
           (check-true-dpd-test ()
             (check-true-dpd test-directory)
             (check-file-exists "test-utilities.script")
             (check-directory-exists "stamp-propagation/")
             (check-directory-exists "stamp-propagation")
             (check-file-doesnt-exist "test/test-utilities.script")
             (check-directory-doesnt-exist "tools/")))

    (DBG "1" (chdir asdf-directory) (setf *default-pathname-defaults* asdf-directory))
    (check-true-dpd-asdf)

    (DBG "2" (chdir test-directory) (setf *default-pathname-defaults* test-directory))
    (check-true-dpd-test)

    (with-expected-failure (#+gcl t)
      (DBG "3" (chdir asdf-directory) (setf *default-pathname-defaults* test-directory))
      (check-true-dpd-test))

103
    #-(or abcl genera xcl ;; on these platforms, chdir changes D-P-D so these tests are not meaningful
Robert Goldman's avatar
Robert Goldman committed
104
          (and sbcl os-windows)) ;; SBCL on Windows really hates a relative D-P-D.
105
106
107
108
109
110
111
112
113
114
115
116
117
    (progn
      ;; SBCL hates to get (truename #p"") when D-P-D is itself #p"". See https://bugs.launchpad.net/sbcl/+bug/1472414
      (DBG "4"
           (setf *default-pathname-defaults* (nil-pathname)) ;; make things relative to GETCWD
           (chdir asdf-directory)) ;; note: may or may not change *default-pathname-defaults* to an absolute pathname.
      (check-true-dpd-asdf)
      (DBG "5"
           *default-pathname-defaults*
           (chdir test-directory)) ;; note: may or may not change *default-pathname-defaults* to an absolute pathname.
      (check-true-dpd-test)

      ;; On implementations where chdir doesn't side-effect D-P-D, we can have D-P-D be relative to GETCWD...
      ;; except on allegro, that hates this trick.
118
      (with-expected-failure (#+(or allegro gcl (and clisp os-windows)) t)
119
120
121
122
123
124
125
126
        (unless (absolute-pathname-p *default-pathname-defaults*)
          (DBG "6"
               (chdir asdf-directory)
               (setf *default-pathname-defaults* (parse-unix-namestring "test/")))
          (check-true-dpd-test))))

    ;; For the rest of this test, use these:
    (setf *default-pathname-defaults* (nil-pathname))
127
    (chdir test-directory)))
128

129
130
131
(assert
 (every #'directory-pathname-p
  (list
132
133
134
   (make-pathname* :name nil :type nil :directory '(:absolute "tmp"))
   ;; CLHS 19.2.2.2.3 says we can't portably specify :unspecific here,
   ;; and some implementations will enforce it.
135
136
   (make-pathname* :type *unspecific-pathname-type* :directory '(:absolute "tmp"))
   (make-pathname* :name *unspecific-pathname-type* :directory '(:absolute "tmp")))))
137
138
139
(assert
 (every (complement #'directory-pathname-p)
  (list
140
141
   (make-pathname* :name "foo" :type nil :directory '(:absolute "tmp"))
   (make-pathname* :name nil :type "bar" :directory '(:absolute "tmp")))))
142
;; These are funky and non portable, omit from tests:
143
144
;; (make-pathname* :name "" :type nil :directory '(:absolute "tmp"))
;; (make-pathname* :name nil :type "" :directory '(:absolute "tmp"))
145
146
;; (make-pathname* :name "." :type nil :directory '(:absolute "tmp"))
;; (make-pathname* :name "." :type "" :directory '(:absolute "tmp"))
147
148
149
150
151
152
153
154
155
156
157
158
(macrolet ((ts (x y)
             `(assert-equal (multiple-value-list (split-unix-namestring-directory-components ,@x))
                            ',y)))
  (ts ("" :ensure-directory t) (:relative nil nil nil))
  (ts (""  :ensure-directory nil) (:relative nil nil nil))
  (ts ("/" :ensure-directory t) (:absolute nil nil nil))
  (ts ("/" :ensure-directory nil) (:absolute nil nil nil))
  (ts ("/aa/ba" :ensure-directory t) (:absolute ("aa" "ba") nil nil))
  (ts ("/aa/ba" :ensure-directory nil) (:absolute ("aa") "ba" nil)))
(assert (version-satisfies (asdf-version) (asdf-version)))
(assert (version-satisfies (asdf-version) "3.0"))
(assert (version-satisfies (asdf-version) "2.0"))
159
(assert (not (version-satisfies (find-system :test-asdf) "666")))
160
161
(handler-case (version-satisfies (find-system :test-asdf) "666")
  (simple-warning (c)
162
    (assert (search "Requested version ~S but ~S has no version" (simple-condition-format-control c))))
163
  (:no-error (x)
164
    (declare (ignore x))
165
    (error "version-satisfies must warn when given component without version")))
166
167
(assert (version<= "2.0" (asdf-version)))
(assert (not (version-satisfies (asdf-version) "666")))
168
(DBG "First pathname test.")
169
(assert-pathnames-equal
170
 (split-native-pathnames-string (join-namestrings '("foo" "bar")))
171
 '(#p"foo" #p"bar"))
172
(DBG "Second pathname test.")
173
(assert-pathnames-equal
174
 (split-native-pathnames-string (join-namestrings '("foo" "bar")) :ensure-directory t)
175
 '(#p"foo/" #p"bar/"))
176
(DBG "Third pathname test.")
177
(assert-pathnames-equal
178
 (split-native-pathnames-string (join-namestrings '("/foo" "/bar")) :want-absolute t)
179
 '(#p"/foo" #p"/bar"))
180
(DBG "Fourth pathname test.")
181
(assert-pathnames-equal
182
 (split-native-pathnames-string (join-namestrings '("/foo" "/bar"))
183
                                :want-absolute t :ensure-directory t)
184
 '(#p"/foo/" #p"/bar/"))
185
(DBG "Fifth pathname test.")
186
187
188
189
190
191
192
(assert-equal
 (mapcar 'location-function-p
         '((:function f)
           (:function (lambda (path absolute-source)
                        (declare (ignore absolute-source))
                        path))
           (function previous-isnt-keyword)
193
194
           (:function f too many arguments)))
 '(t t nil nil))
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210

(initialize-source-registry '())

#|
(unless (find-system :swank nil)
  (leave-test "Cannot find SWANK" 0))

(load-system :swank)
;;(setq swank-loader::*fasl-directory* (resolve-output "slime/"))
;;(ensure-directories-exist swank-loader::*fasl-directory*)
;;(DBG :foo swank-loader::*fasl-directory*)
(swank-loader:init)
|#

(defparameter *ok-symbols*
  '(;; slots names
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
    asdf/action:accept
    asdf/action:action
    asdf/action:done-p
    asdf/action:stamp
    asdf/bundle:prologue-code
    asdf/bundle:build-args
    asdf/bundle:epilogue-code
    asdf/bundle:name-suffix
    asdf/component:absolute-pathname
    asdf/component:around-compile
    asdf/component:author
    asdf/component:children
    asdf/component:children-by-name
    asdf/component:components
    asdf/component:components-by-name
    asdf/component:default-component-class
227
228
    ;; the following is here only for backward compatibility; should be in
    ;; asdf/system. [2014/02/20:rpg]
229
    asdf/component:defsystem-depends-on
230
231
232
233
234
235
236
237
238
239
240
241
242
    asdf/component:description
    asdf/component:%encoding
    asdf/component:if-feature
    asdf/component:inline-methods
    asdf/component:in-order-to
    asdf/component:licence
    asdf/component:long-description
    asdf/component:maintainer
    asdf/component:name
    asdf/component:operation-times
    asdf/component:parent
    asdf/component:properties
    asdf/component:relative-pathname
243
    asdf/component:sideway-dependencies
244
245
    asdf/component:version
    asdf/lisp-action:flags
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
246
    asdf/operation:feature
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
247
    asdf/operation:original-initargs
248
249
250
251
252
253
254
255
256
257
258
259
    asdf/plan:index
    asdf/plan:forced
    asdf/plan:forced-not
    asdf/plan:planned-action-count
    asdf/plan:planned-output-action-count
    asdf/plan:planned-p
    asdf/plan:total-action-count
    asdf/plan:visited-actions
    asdf/plan:visiting-action-set
    asdf/plan:visiting-action-list
    asdf/system:bug-tracker
    asdf/system:build-pathname
260
261
    asdf/system:system-defsystem-depends-on
    asdf/system:system-weakly-depends-on
262
263
264
265
266
    asdf/system:entry-point
    asdf/system:homepage
    asdf/system:long-name
    asdf/system:mailto
    asdf/system:source-control
267
    ;; restarts
268
269
270
271
272
    asdf/action:accept
    asdf/find-component:retry
    asdf/find-system:coerce-entry-to-directory
    asdf/find-system:remove-entry-from-registry
    asdf/lisp-action:try-recompiling
273
    ;; types
274
    asdf/bundle:user-system
275
    #+sbcl uiop/lisp-build:sb-grovel-unknown-constant-condition
276
    ;; on some implementations only
277
    asdf/bundle:bundle-system
278
    asdf/bundle:static-library
279
280
281
282
    uiop/os:parse-file-location-info
    uiop/os:parse-windows-shortcut
    uiop/os:read-little-endian
    uiop/os:read-null-terminated-string
283
    ;; backward compatibility upgrade only
284
285
    asdf/backward-interface:on-failure
    asdf/backward-interface:on-warnings
286
287
    asdf/find-system:contrib-sysdef-search
    asdf/find-system:sysdef-find-asdf
288
    ;; restart
289
    asdf/cache:clear-configuration-and-retry
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
    ))

(defun defined-symbol-p (symbol)
  (or (boundp symbol)
      (fboundp symbol)
      (macro-function symbol)
      (find-class symbol nil)))

(defun fishy-exported-symbols (package &optional (ok-symbols *ok-symbols*))
  (loop :for symbol :being :the external-symbols :of package
        :unless (or
                 (defined-symbol-p symbol)
                 ;;(symbol-call :swank :classify-symbol symbol)
                 (member symbol ok-symbols))
          :collect symbol))

(defun fishy-asdf-exported-symbols ()
  (remove-duplicates
   (loop :for package :in (list-all-packages)
         :when (and (string-prefix-p "ASDF/" (package-name package))
                    (not (equal (package-name package) "ASDF/COMMON-LISP")))
           :nconc (fishy-exported-symbols package))
   :from-end t))

(assert-equal nil (fishy-asdf-exported-symbols))
315
316

(delete-package* :asdf-test-package-1)
317
318
319
320
321
322

(ensure-directories-exist (subpathname *build-directory* "deleteme/a/b/c/"))
(ensure-directories-exist (subpathname *build-directory* "deleteme/a/b/d/"))
(ensure-directories-exist (subpathname *build-directory* "deleteme/a/b/e/"))
(register-directory *asdf-directory*)
(register-directory *uiop-directory*)
323
324
325
326
327
328
329
330
(let ((new-file (subpathname *build-directory* "deleteme/a/1.x")))
  (when (probe-file new-file)
    (delete-file new-file))
  (copy-file (system-source-file :uiop) new-file))
(let ((new-file (subpathname *build-directory* "deleteme/a/b/2")))
  (when (probe-file new-file)
    (delete-file new-file))
  (copy-file (system-source-file :uiop) new-file))
331
332
333
334
335
(assert (directory-exists-p (subpathname *build-directory* "deleteme/a/b/c/")))
(assert (directory-exists-p (subpathname *build-directory* "deleteme/a/b/d/")))
(assert (directory-exists-p (subpathname *build-directory* "deleteme/a/b/e/")))
(assert (probe-file* (subpathname *build-directory* "deleteme/a/1.x")))
(assert (probe-file* (subpathname *build-directory* "deleteme/a/b/2")))
336
(DBG "check to make sure DIRECTORY-FILES doesn't list subdirectories")
337
338
(let ((directory-a (directory-files (subpathname *build-directory* "deleteme/a/")))
      (directory-b (directory-files (subpathname *build-directory* "deleteme/a/b/"))))
339
340
341
  (assert-pathnames-equal directory-a (list (subpathname *build-directory* "deleteme/a/1.x")))
  (assert-pathnames-equal directory-b (list (subpathname *build-directory* "deleteme/a/b/2"))))
(DBG "check to make sure SUBDIRECTORIES does list subdirectories")
342
343
(let ((directory-a (subdirectories (subpathname *build-directory* "deleteme/a/")))
      (directory-b (subdirectories (subpathname *build-directory* "deleteme/a/b/"))))
344
345
346
347
  (assert-pathnames-equal directory-a (list (subpathname *build-directory* "deleteme/a/b/")))
  (assert-pathnames-equal
   (sort directory-b #'string< :key #'(lambda (x) (car (last (pathname-directory x)))))
   (list (subpathname *build-directory* "deleteme/a/b/c/")
348
349
         (subpathname *build-directory* "deleteme/a/b/d/")
         (subpathname *build-directory* "deleteme/a/b/e/"))))
350
351
352
(delete-empty-directory (subpathname *build-directory* "deleteme/a/b/e/"))
(assert (not (directory-exists-p (subpathname *build-directory* "deleteme/a/b/e/"))))
(delete-directory-tree (subpathname *build-directory* "deleteme/")
353
                       :validate (lambda (x) (and (<= 4 (length (pathname-directory x)))
354
355
356
357
358
                                                  (subpathp x *build-directory*))))
(assert (not (directory-exists-p (subpathname *build-directory* "deleteme/a/b/c/"))))
(assert (not (directory-exists-p (subpathname *build-directory* "deleteme/a/b/d/"))))
(assert (not (probe-file* (subpathname *build-directory* "deleteme/a/1.x"))))
(assert (not (probe-file* (subpathname *build-directory* "deleteme/a/b/2"))))
359
360
361
362
363

#+(and sbcl sb-unicode) (assert +non-base-chars-exist-p+)
#+(or clozure (and sbcl (not sb-unicode))) (assert (not +non-base-chars-exist-p+))

(assert (base-string-p (make-string 10 :element-type 'base-char)))
364
365
(assert-equal "abcd" (strcat "a" nil "bc" "d"))
(assert-equal "abcd" (reduce/strcat '("a" nil "bc" "d")))
366

367
(defparameter *last-char-code* (1- (or #+allegro excl:real-char-code-limit char-code-limit)))
368
369
370
(defparameter *last-char* (code-char *last-char-code*))
(defparameter *last-char-string* (string *last-char*))

371
372
#-non-base-chars-exist-p
(progn
373
  (assert (base-string-p (make-string 10 :element-type 'character :initial-element *last-char*)))
374
  (assert (typep *last-char* 'base-char)))
375
376

(defun basify (s) (coerce s 'base-string))
377
(defun unbasify (s) (coerce s '(array character (*)))) ; on ECL, literals are base strings (!)
378
379

#+non-base-chars-exist-p
380
(progn
381
  (assert (= 0 (character-type-index #\a)))
382
  (assert (not (base-string-p *last-char-string*)))
383
  (assert (not (base-string-p (make-string 10 :element-type 'character))))
384
  (assert (not (base-string-p (unbasify "abc"))))
385
  (assert (base-string-p (basify "abc")))
386
  (assert (base-string-p (strcat "a" nil #\b (unbasify "cd"))))
387
  (assert (base-string-p (reduce/strcat (mapcar 'basify '("a" "b" nil "cd")))))
388
  (assert (base-string-p (strcat (basify "ab") (basify "cd"))))
389
  (assert (not (base-string-p (strcat (basify "ab") #\c *last-char* (unbasify "d")))))
390
391
392
393
394
395
396
397
398
399
400
401
402
  (assert (base-string-p (strcat (basify "ab") #\c #\d)))
  (when (< 256 char-code-limit)
    (let* ((lambda-char (code-char 955))
           (lambda-string (string lambda-char)))
      (assert (= 1 (character-type-index lambda-char)))
      (assert-equal (strings-common-element-type (list #\a nil (strcat "hello, " lambda-string "world")))
                    #-lispworks 'character #+lispworks7 'lw:bmp-char #+(and lispworks (not lispworks7)) 'lw:simple-char)
      (when (< 65536 char-code-limit)
        (let* ((amagi (format nil "~a~a" (code-char #x120BC) (code-char #x12104))))
          (assert (= #+lispworks7 2 #-lispworks7 1 (character-type-index (first-char amagi))))
          (assert-equal (strings-common-element-type (list #\a nil amagi lambda-string))
                        #+(or (not lispworks) lispworks7) 'character
                        #+(and lispworks (not lispworks7)) 'lw:simple-char))))))
403
404
405
406
407
408
409

(assert-equal +crlf+ (map 'string 'code-char '(13 10)))
(assert-equal +lf+ (map 'string 'code-char '(10)))
(assert-equal +cr+ (map 'string 'code-char '(13)))
(defparameter acrlf (strcat "a" +crlf+))
(defparameter blf (strcat "b" +lf+))
(defparameter ccr (strcat "c" +cr+))
410
411
412
413
414
415
416
417
418
419
420
421
(macrolet ((ts (x y z)
             `(progn
                (assert-equal (list ,x ,y) (multiple-value-list (stripln ,z)))
                (assert-equal (strcat ,x ,y) ,z))))
  (ts "a" +crlf+ acrlf)
  (ts "b" +lf+ blf)
  (ts "c" +cr+ ccr)
  (ts acrlf +crlf+ (strcat acrlf +crlf+))
  (ts blf +cr+ (strcat blf +cr+))
  (ts "c" +crlf+ (strcat ccr +lf+))
  (ts (strcat acrlf "b") +lf+ (strcat acrlf blf)))

422
423
(DBG "testing with-temporary-file")
(with-temporary-file (:stream s :direction :io :prefix "WTF0")
424
425
426
427
  (println "Hello, World" s)
  (file-position s 0)
  (assert-equal (read-line s) "Hello, World"))

428
429
430
431
(let ((pn1 (with-temporary-file (:pathname pn :direction :output :prefix "WTF1")
             (assert-equal (read-file-lines pn) ())
             pn)))
  (assert (not (probe-file pn1))))
432

433
434
435
436
437
(let ((pn2 (with-temporary-file (:stream s :pathname p :keep t :direction :io :prefix "WTF2")
             (println "Hello, World" s)
             p)))
  (assert-equal (read-file-lines pn2) '("Hello, World"))
  (delete-file pn2))
438

439
440
441
442
443
444
445
446
447
448
449
(with-expected-failure (#+gcl "BUG in GCL compiling the WTF internal loop. Works if loaded without compiling.")
  (assert
   (not (probe-file
         (let ((s 'outer-s))
           (with-temporary-file (:stream s :pathname p :direction :io :prefix "WTF3")
             (assert (open-stream-p s))
             (println "Same thing with :close-stream" s)
             :close-stream
             (assert-equal s 'outer-s) ;; the stream s (1) has been closed and (2) is no longer in scope.
             (assert-equal (read-file-lines p) '("Same thing with :close-stream"))
             p))))))
450

451
452
453
454
455
456
457
458
459
460
461
462
(DBG :ensure-gethash)
(let ((h (make-hash-table :test 'equal)))
  (assert-equal (multiple-value-list (gethash 1 h 2)) '(2 nil))
  (assert-equal (multiple-value-list (ensure-gethash 1 h 2)) '(2 nil))
  (assert-equal (multiple-value-list (gethash 1 h 2)) '(2 t))
  (assert-equal (multiple-value-list (ensure-gethash 1 h 3)) '(2 t))
  (assert-equal (multiple-value-list (ensure-gethash 1 h '(error "foo"))) '(2 t))
  (signals parse-error (ensure-gethash 2 h '(error parse-error)))
  (assert-equal (multiple-value-list (gethash 3 h nil)) '(nil nil))
  (assert-equal (multiple-value-list (ensure-gethash 3 h nil)) '(nil nil))
  (assert-equal (multiple-value-list (gethash 3 h 4)) '(nil t))
  (assert-equal (multiple-value-list (ensure-gethash 3 h 5)) '(nil t)))
463
464

(DBG :optimization-settings)
465
#-(or ecl-bytecmp gcl mkcl)
466
467
468
469
470
471
472
473
(loop :with settings = (get-optimization-settings)
      :for i :from 0 :to 3 :do
        (with-optimization-settings (`((speed ,i) (space ,i) (safety ,i) (debug ,i)))
          (let ((s (get-optimization-settings)))
            (loop :for q :in '(speed space safety debug) :do
                  #+mkcl (DBG :os i q s (assoc q s))
                         (assert-equal i (second (assoc q s))))))
        (assert-equal (get-optimization-settings) settings))
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499

(DBG :standard-case-symbol-name)
(if (or #+allegro (eq excl:*current-case-mode* :case-sensitive-lower))
    (push :modern-syntax *features*)
    (setf *features* (remove :modern-syntax *features*)))
(assert-equal (standard-case-symbol-name "foo") #-modern-syntax "FOO" #+modern-syntax "foo")
(assert-equal (standard-case-symbol-name "BaR") #-modern-syntax "BAR" #+modern-syntax "BaR")
(assert-equal (standard-case-symbol-name "BAZ") #-modern-syntax "BAZ" #+modern-syntax "BAZ")
(assert-equal (standard-case-symbol-name :foo) #-modern-syntax "FOO" #+modern-syntax "foo")
(assert-equal (standard-case-symbol-name 'BaR) #-modern-syntax "BAR" #+modern-syntax "BaR")
(assert-equal (standard-case-symbol-name '#:BAZ) #-modern-syntax "BAZ" #+modern-syntax "BAZ")
(assert-equal (standard-case-symbol-name :|foo|) "foo")
(assert-equal (standard-case-symbol-name '|BaR|) "BaR")
(assert-equal (standard-case-symbol-name '#:|BAZ|) "BAZ")

(DBG :find-standard-case-symbol)
(assert-equal 'symbol (find-standard-case-symbol "symbol" "asdf-test"))
(assert-equal 'Symbol (find-standard-case-symbol "Symbol" "asdf-test"))
(assert-equal 'SYMBOL (find-standard-case-symbol "SYMBOL" "asdf-test"))

(assert-equal '|lowercase| (find-standard-case-symbol :|lowercase| :asdf-test))
(assert-equal '|CamelCase| (find-standard-case-symbol :|CamelCase| :asdf-test))
(assert-equal '|UPPER-CASE| (find-standard-case-symbol :|UPPER-CASE| :asdf-test))

(assert-equal #-modern-syntax '|THIS_SYMBOL| #+modern-syntax '|This_Symbol|
              (find-standard-case-symbol "This_Symbol" "asdf-test"))