From 3d71e628f14db95a6855d5d4a8bae47022d5abb9 Mon Sep 17 00:00:00 2001 From: Charles Zhang Date: Thu, 2 Jun 2022 21:34:27 -0700 Subject: [PATCH] Add failing tests. --- tests/block-compile.impure.lisp | 30 ++++++++++++++++++++++++++++++ tests/input-manifest.lisp-expr | 5 +++++ tests/package-test-1.lisp | 8 ++++++++ tests/package-test-2.lisp | 13 +++++++++++++ tests/package-test-3.lisp | 11 +++++++++++ tests/package-test-4.lisp | 13 +++++++++++++ 6 files changed, 80 insertions(+) create mode 100644 tests/package-test-1.lisp create mode 100644 tests/package-test-2.lisp create mode 100644 tests/package-test-3.lisp create mode 100644 tests/package-test-4.lisp diff --git a/tests/block-compile.impure.lisp b/tests/block-compile.impure.lisp index d4b0819f6..8b8d5ee44 100644 --- a/tests/block-compile.impure.lisp +++ b/tests/block-compile.impure.lisp @@ -122,6 +122,36 @@ :load t) (assert (find-symbol "STABLE-UNION" "BLOCK-DEFPACKAGE-BAR"))) +(with-test (:name :block-defpackage-rename-package-symbol-conflict + :fails-on :sbcl) + (with-scratch-file (fasl2 "fasl") + (compile-file "package-test-2.lisp" :output-file fasl2 + :block-compile t) + (delete-package "BAR") + (with-scratch-file (fasl1 "fasl") + (compile-file "package-test-1.lisp" :output-file fasl1 + :block-compile t) + (load fasl2))) + (assert (eq (symbol-package (find-symbol "BAZ" "BAR")) + (find-package "BAR"))) + (assert (eq (funcall (find-symbol "BAZ" "BAR")) + :good)) + (delete-package "BAR")) + +(with-test (:name :block-defpackage-rename-package-preserve-externals + :fails-on :sbcl) + (with-scratch-file (fasl4 "fasl") + (compile-file "package-test-4.lisp" :output-file fasl4 + :block-compile t) + (delete-package "FOO-NEW") + (with-scratch-file (fasl3 "fasl") + (compile-file "package-test-3.lisp" :output-file fasl3 + :block-compile t) + (load fasl4))) + (assert (eq (nth-value 1 (find-symbol "BAR" "FOO-NEW")) + :external)) + (delete-package "FOO-NEW")) + (with-test (:name :block-defconstant-then-load-fasl) (ctu:file-compile ;; test a non-EQL-comparable constant. diff --git a/tests/input-manifest.lisp-expr b/tests/input-manifest.lisp-expr index b6371f376..830d3b54f 100644 --- a/tests/input-manifest.lisp-expr +++ b/tests/input-manifest.lisp-expr @@ -40,6 +40,11 @@ "tests/block-compile-test-4.lisp" "tests/block-compile-test-5.lisp") ("debug.impure.lisp" "tests/bug-414.lisp") + ("block-compile.impure.lisp" + "tests/package-test-1.lisp" + "tests/package-test-2.lisp" + "tests/package-test-3.lisp" + "tests/package-test-4.lisp") ("defstruct.impure-cload.lisp" "tests/block-compile-defstruct-test.lisp") ("elfcore.test.sh" "src/runtime/shrinkwrap-sbcl") ("exit-hang.impure.lisp" "tests/fcb-threads.so") diff --git a/tests/package-test-1.lisp b/tests/package-test-1.lisp new file mode 100644 index 000000000..e4106ccab --- /dev/null +++ b/tests/package-test-1.lisp @@ -0,0 +1,8 @@ +(defpackage "FOO" + (:use "CL")) + +(in-package "FOO") + +(eval-when (:compile-toplevel :load-toplevel :execute) + (defun baz () + :bad)) diff --git a/tests/package-test-2.lisp b/tests/package-test-2.lisp new file mode 100644 index 000000000..b2dc5b2ee --- /dev/null +++ b/tests/package-test-2.lisp @@ -0,0 +1,13 @@ +(eval-when (:compile-toplevel :load-toplevel :execute) + (cond + ((find-package "FOO") + (rename-package "FOO" "BAR" '("FOO"))) + ((not (find-package "BAR")) + (make-package "BAR" :use '("CL") :nicknames '("FOO")) + (export (list (intern "BAZ" "BAR")) "BAR")))) + +(in-package "BAR") + +(eval-when (:compile-toplevel :load-toplevel :execute) + (defun baz () + :good)) diff --git a/tests/package-test-3.lisp b/tests/package-test-3.lisp new file mode 100644 index 000000000..2b0a2557e --- /dev/null +++ b/tests/package-test-3.lisp @@ -0,0 +1,11 @@ +(defpackage "FOO" + (:use "CL") + (:export "BAR" "BAZ")) + +(in-package "FOO") + +(eval-when (:compile-toplevel :load-toplevel :execute) + (defun baz () + 1) + (defmacro bar (&rest args) + `(baz ,@args))) diff --git a/tests/package-test-4.lisp b/tests/package-test-4.lisp new file mode 100644 index 000000000..75dbb837a --- /dev/null +++ b/tests/package-test-4.lisp @@ -0,0 +1,13 @@ +(eval-when (:compile-toplevel :load-toplevel :execute) + (cond + ((find-package "FOO") + (rename-package "FOO" "FOO-NEW" '("FOO"))) + ((not (find-package "FOO-NEW")) + (make-package "FOO-NEW" :use '("CL") :nicknames '("FOO")) + (export (list (intern "BAR" "FOO-NEW") (intern "BAZ" "FOO-NEW")) "FOO-NEW")))) + +(in-package "FOO-NEW") + +(eval-when (:compile-toplevel :load-toplevel :execute) + (defmacro bar (&rest args) + `(baz ,@args)))