(require 'ert)
(require 'ert-x)
-(eval-when-compile
- (require 'cl-lib)
- (require 'comp))
+(require 'cl-lib)
+(require 'comp)
+(require 'comp-cstr)
+
(eval-and-compile
- (require 'comp-cstr) ;in eval-and-compile for its defstruct
(defconst comp-test-src (ert-resource-file "comp-test-funcs.el"))
- (defconst comp-test-dyn-src (ert-resource-file "comp-test-funcs-dyn.el"))
- (defconst comp-test-pure-src (ert-resource-file "comp-test-pure.el"))
- (defconst comp-test-45603-src (ert-resource-file "comp-test-45603.el"))
- ;; Load the test code here so the compiler can check the function
- ;; names used in this file.
- (load comp-test-src nil t)
- (load comp-test-dyn-src nil t)
- (load comp-test-pure-src nil t)
- (load comp-test-45603-src nil t))
+ (defconst comp-test-dyn-src (ert-resource-file "comp-test-funcs-dyn.el")))
(when (native-comp-available-p)
(message "Compiling tests...")
(load (native-compile comp-test-src))
(load (native-compile comp-test-dyn-src)))
+;; Load the test code here so the compiler can check the function
+;; names used in this file.
+(require 'comp-test-funcs comp-test-src)
+(require 'comp-test-dyn-funcs comp-test-dyn-src) ;Non-standard feature name!
+
(defmacro comp-deftest (name args &rest docstring-and-body)
"Define a test for the native compiler tagging it as :nativecomp."
(declare (indent defun)
(copy-file comp-src comp2-src t)
(let ((load-no-native t))
(load (concat comp-src "c") nil nil t t))
- (should-not (subr-native-elisp-p (symbol-function #'native-compile)))
+ (should-not (subr-native-elisp-p (symbol-function 'native-compile)))
(message "Compiling stage1...")
(let* ((t0 (current-time))
(comp1-eln (native-compile comp1-src)))
t)
(native-compile #'comp-tests-free-fun-f)
- (should (subr-native-elisp-p (symbol-function #'comp-tests-free-fun-f)))
+ (should (subr-native-elisp-p (symbol-function 'comp-tests-free-fun-f)))
(should (= (comp-tests-free-fun-f) 3))
(should (string= (documentation #'comp-tests-free-fun-f)
"Some doc."))
"Check we are able to compile a single function."
(eval '(defun comp-tests/free\fun-f ()) t)
(native-compile #'comp-tests/free\fun-f)
- (should (subr-native-elisp-p (symbol-function #'comp-tests/free\fun-f))))
+ (should (subr-native-elisp-p (symbol-function 'comp-tests/free\fun-f))))
(comp-deftest bug-40187 ()
"Check function name shadowing.
(comp-deftest speed--1 ()
"Check that at speed -1 we do not native compile."
(should (= (comp-test-speed--1-f) 3))
- (should-not (subr-native-elisp-p (symbol-function #'comp-test-speed--1-f))))
+ (should-not (subr-native-elisp-p (symbol-function 'comp-test-speed--1-f))))
(comp-deftest bug-42360 ()
"<https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-07/msg00418.html>."
(comp-deftest primitive-redefine ()
"Test effectiveness of primitive redefinition."
(cl-letf ((comp-test-primitive-redefine-args nil)
- ((symbol-function #'-)
+ ((symbol-function '-)
(lambda (&rest args)
(setq comp-test-primitive-redefine-args args)
'xxx)))
(comp-deftest comp-test-defsubst ()
;; Bug#42664, Bug#43280, Bug#44209.
- (should-not (subr-native-elisp-p (symbol-function #'comp-test-defsubst-f))))
+ (should-not (subr-native-elisp-p (symbol-function 'comp-test-defsubst-f))))
(comp-deftest primitive-redefine-compile-44221 ()
"Test the compiler still works while primitives are redefined (bug#44221)."
- (cl-letf (((symbol-function #'delete-region)
+ (cl-letf (((symbol-function 'delete-region)
(lambda (_ _))))
(should (subr-native-elisp-p
(native-compile
(comp-deftest 45603-1 ()
"<https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-12/msg01994.html>"
- (load (native-compile comp-test-45603-src))
- (should (fboundp #'comp-test-45603--file-local-name)))
+ (load (native-compile (ert-resource-file "comp-test-45603.el")))
+ (should (fboundp 'comp-test-45603--file-local-name)))
(comp-deftest 46670-1 ()
"<https://lists.gnu.org/archive/html/bug-gnu-emacs/2021-02/msg01413.html>"
(should (string= (comp-test-46670-2-f "foo") "foo"))
- (should (equal (subr-type (symbol-function #'comp-test-46670-2-f))
+ (should (equal (subr-type (symbol-function 'comp-test-46670-2-f))
'(function (t) t))))
(comp-deftest 46824-1 ()
(comp-deftest dynamic-help-arglist ()
"Test `help-function-arglist' works on lisp/d (bug#42572)."
(should (equal (help-function-arglist
- (symbol-function #'comp-tests-ffuncall-callee-opt-rest-dyn-f)
+ (symbol-function 'comp-tests-ffuncall-callee-opt-rest-dyn-f)
t)
'(a b &optional c &rest d))))
(comp-tests-tco-f (+ a b) a (- count 1))))
t)
(native-compile #'comp-tests-tco-f)
- (should (subr-native-elisp-p (symbol-function #'comp-tests-tco-f)))
+ (should (subr-native-elisp-p (symbol-function 'comp-tests-tco-f)))
(should (= (comp-tests-tco-f 1 0 10) 55))))
(defun comp-tests-fw-prop-checker-1 (_)
(length c))) ; <= has to optimize
t)
(native-compile #'comp-tests-fw-prop-1-f)
- (should (subr-native-elisp-p (symbol-function #'comp-tests-fw-prop-1-f)))
+ (should (subr-native-elisp-p (symbol-function 'comp-tests-fw-prop-1-f)))
(should (= (comp-tests-fw-prop-1-f) 6))))
(defun comp-tests-check-ret-type-spec (func-form ret-type)
(let ((native-comp-speed 3)
(comp-post-pass-hooks '((comp-final comp-tests-pure-checker-1
comp-tests-pure-checker-2))))
- (load (native-compile comp-test-pure-src))
+ (load (native-compile (ert-resource-file "comp-test-pure.el")))
+ (declare-function comp-tests-pure-caller-f nil)
+ (declare-function comp-tests-pure-fibn-entry-f nil)
- (should (subr-native-elisp-p (symbol-function #'comp-tests-pure-caller-f)))
+ (should (subr-native-elisp-p (symbol-function 'comp-tests-pure-caller-f)))
(should (= (comp-tests-pure-caller-f) 4))
- (should (subr-native-elisp-p (symbol-function #'comp-tests-pure-fibn-entry-f)))
+ (should (subr-native-elisp-p (symbol-function 'comp-tests-pure-fibn-entry-f)))
(should (= (comp-tests-pure-fibn-entry-f) 6765))))
(defvar comp-tests-cond-rw-checked-function nil