1.0.12.29: optimize POSITION & FIND families for strings
[sbcl.git] / tests / load.impure.lisp
blob829950c079edad38eeaeb4663ea8e96b4d6fedb7
1 ;;;; miscellaneous side-effectful tests of LOAD
3 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; more information.
5 ;;;;
6 ;;;; While most of SBCL is derived from the CMU CL system, the test
7 ;;;; files (like this one) were written from scratch after the fork
8 ;;;; from CMU CL.
9 ;;;;
10 ;;;; This software is in the public domain and is provided with
11 ;;;; absolutely no warranty. See the COPYING and CREDITS files for
12 ;;;; more information.
14 (defvar *tmp-filename* "load-test.tmp")
16 ;;; Bug reported by Sean Ross: FASL loader set fill pointer to loaded
17 ;;; simple arrays.
19 (defvar *array*)
21 (progn
22 (with-open-file (s *tmp-filename*
23 :direction :output
24 :if-exists :supersede
25 :if-does-not-exist :create)
26 (print '(setq *array* #3a(((1 2) (2 1)) ((3 4) (4 3)))) s))
27 (let (tmp-fasl)
28 (unwind-protect
29 (progn
30 (setq tmp-fasl (compile-file *tmp-filename*))
31 (let ((*array* nil))
32 (load tmp-fasl)
33 (assert (arrayp *array*))
34 (assert (= (array-rank *array*) 3))
35 (assert (not (array-has-fill-pointer-p *array*)))))
36 (when tmp-fasl (delete-file tmp-fasl))
37 (delete-file *tmp-filename*))))
39 ;;; rudimentary external-format test
40 (dolist (ef '(:default :ascii :latin-1 :utf-8))
41 (with-open-file (s *tmp-filename*
42 :direction :output
43 :if-exists :supersede
44 :if-does-not-exist :create)
45 (print '(defun foo (x) (1+ x)) s))
46 (fmakunbound 'foo)
47 (let (tmp-fasl)
48 (unwind-protect
49 (progn
50 (setq tmp-fasl (compile-file *tmp-filename* :external-format ef))
51 (load tmp-fasl)
52 (assert (= (foo 1) 2)))
53 (when tmp-fasl (delete-file tmp-fasl))
54 (delete-file *tmp-filename*))))
56 ;;; As reported by David Tolpin *LOAD-PATHNAME* was not merged.
57 (progn
58 (defvar *saved-load-pathname*)
59 (with-open-file (s *tmp-filename*
60 :direction :output
61 :if-exists :supersede
62 :if-does-not-exist :create)
63 (print '(setq *saved-load-pathname* *load-pathname*) s))
64 (let (tmp-fasl)
65 (unwind-protect
66 (progn
67 (load *tmp-filename*)
68 (assert (equal (merge-pathnames *tmp-filename*) *saved-load-pathname*)))
69 (delete-file *tmp-filename*))))