+
+ ;; automagic restarts
+ (setf *invoke-debugger-hook*
+ (lambda (condition hook)
+ (princ condition)
+ (let ((cont (find-restart 'continue condition)))
+ (when cont
+ (invoke-restart cont)))
+ (print :fell-through)
+ (invoke-debugger condition)))
+EOF
+
+echo "(declaim (optimize speed))" > $testfilestem.fast.lisp
+cat $testfilestem.base.lisp >> $testfilestem.fast.lisp
+
+echo "(declaim (optimize space))" > $testfilestem.small.lisp
+cat $testfilestem.base.lisp >> $testfilestem.small.lisp
+
+# Test code
+cat > $testfilestem.test.lisp <<EOF
+ ;; FIXME: currently the start/small case fails on x86/Darwin. Moving
+ ;; this NOTE definition to the base.lisp file fixes that, but obviously
+ ;; it is better fo figure out what is going on instead of doing that...
+ ;;
+ ;; Other trivialish changes that mask the error include:
+ ;; * loading the .lisp file instead of the .fasl at the save test
+ ;; * --eval 'nil' before loading the .fasl at the save test
+ ;;
+ ;; HATE.
+ (defun note (x)
+ (write-line x *standard-output*)
+ (force-output *standard-output*))
+ (note "/initial assertions")
+ (assert (= 31 (summish 10 20)))
+ (assert (= 42 numberish))
+ (setf numberish 13)
+ (assert (= 13 numberish))
+ (assert (= 14 (nummish 1)))
+
+ (assert (= -1 (negative-short)))
+ (assert (= -2 (negative-int)))
+ (assert (= -3 (negative-long)))
+
+ (assert (= 9.0s0 (return9th 1.0s0 2.0s0 3.0s0 4.0s0 5.0s0 6.0s0 7.0s0 8.0s0 9.0s0 10.0s0 11.0s0 12.0s0)))
+ (assert (= 9.0d0 (return9thd 1.0d0 2.0d0 3.0d0 4.0d0 5.0d0 6.0d0 7.0d0 8.0d0 9.0d0 10.0d0 11.0d0 12.0d0)))
+
+ (assert (= 1 (long-test8 1 2 3 4 5 6 7 (ash 1 34))))
+ (assert (= 1 (long-test9 1 2 3 4 5 6 7 (ash 1 35) 8)))
+ (assert (= 1 (long-test2 1 2 3 4 5 6 7 8 9 (+ 1 (ash 1 37)) 15)))
+ (assert (= (ash 1 33) (return-long-long)))
+
+ (note "/initial assertions ok")
+
+ ;; test reloading object file with new definitions
+ (assert (= 13 foo))
+ (assert (= 42 (bar)))
+ (note "/original definitions ok")
+ (rename-file "$testfilestem-b.so" "$testfilestem-b.bak")
+ (rename-file "$testfilestem-b2.so" "$testfilestem-b.so")
+ (load-shared-object "$testfilestem-b.so")
+ (note "/reloading ok")
+ (assert (= 42 foo))
+ (assert (= 13 (bar)))
+ (note "/redefined versions ok")
+ (rename-file "$testfilestem-b.so" "$testfilestem-b2.so")
+ (rename-file "$testfilestem-b.bak" "$testfilestem-b.so")
+ (note "/renamed back to originals")
+
+ ;; test late resolution
+ #+linkage-table
+ (progn
+ (note "/starting linkage table tests")
+ (define-alien-variable late-foo int)
+ (define-alien-routine late-bar int)
+ (multiple-value-bind (val err) (ignore-errors late-foo)
+ (assert (not val))
+ (assert (typep err 'undefined-alien-error)))
+ (multiple-value-bind (val err) (ignore-errors (late-bar))
+ (assert (not val))
+ (assert (typep err 'undefined-alien-error)))
+ (load-shared-object "$testfilestem-c.so")
+ (assert (= 43 late-foo))
+ (assert (= 14 (late-bar)))
+ (note "/linkage table ok"))
+