emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/native-comp 47ab6c2 02/12: Add some testing for dynamic scope


From: Andrea Corallo
Subject: feature/native-comp 47ab6c2 02/12: Add some testing for dynamic scope
Date: Sun, 21 Jun 2020 18:37:15 -0400 (EDT)

branch: feature/native-comp
commit 47ab6c237e703cf4b5bbcd3c301e324e0deb1173
Author: Andrea Corallo <andcor03@e112547.nice.arm.com>
Commit: Andrea Corallo <akrl@sdf.org>

    Add some testing for dynamic scope
    
        * test/src/comp-test-funcs-dyn.el: New file.
    
        * test/src/comp-tests.el (comp-tests-dynamic-ffuncall): Add
        new tests.
---
 test/src/comp-test-funcs-dyn.el | 40 +++++++++++++++++++++++++++++++++++
 test/src/comp-tests.el          | 46 +++++++++++++++++++++++++++++++++++++----
 2 files changed, 82 insertions(+), 4 deletions(-)

diff --git a/test/src/comp-test-funcs-dyn.el b/test/src/comp-test-funcs-dyn.el
new file mode 100644
index 0000000..0e342a3
--- /dev/null
+++ b/test/src/comp-test-funcs-dyn.el
@@ -0,0 +1,40 @@
+;;; comp-test-funcs.el --- compilation unit tested by comp-tests.el -*- 
lexical-binding: nil; -*-
+
+;; Copyright (C) 2020 Free Software Foundation, Inc.
+
+;; Author: Andrea Corallo <akrl@sdf.org>
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; Code:
+
+(defun comp-tests-ffuncall-callee-dyn-f (a b)
+  (list a b))
+
+(defun comp-tests-ffuncall-callee-opt-dyn-f (a b &optional c d)
+  (list a b c d))
+
+(defun comp-tests-ffuncall-callee-rest-dyn-f (a b &rest c)
+  (list a b c))
+
+(defun comp-tests-ffuncall-callee-opt-rest-dyn-f (a b &optional c &rest d)
+  (list a b c d))
+
+(provide 'comp-test-dyn-funcs)
+
+;;; comp-test-funcs-dyn.el ends here
diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el
index 3e40dba..ee96d56 100644
--- a/test/src/comp-tests.el
+++ b/test/src/comp-tests.el
@@ -34,8 +34,14 @@
 (defconst comp-test-src
   (concat comp-test-directory "comp-test-funcs.el"))
 
-(message "Compiling %s" comp-test-src)
+(defconst comp-test-dyn-src
+  (concat comp-test-directory "comp-test-funcs-dyn.el"))
+
+(message "Compiling tests...")
 (load (native-compile comp-test-src))
+(load (native-compile comp-test-dyn-src))
+
+
 
 (ert-deftest comp-tests-bootstrap ()
   "Compile the compiler and load it to compile it-self.
@@ -353,9 +359,9 @@ 
https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-03/msg00914.html.";
   (should (eq (comp-test-40187-2-f) 'bar)))
 
 
-;;;;;;;;;;;;;;;;;;;;
-;; Tromey's tests ;;
-;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;
+;; Tromey's tests. ;;
+;;;;;;;;;;;;;;;;;;;;;
 
 (ert-deftest comp-consp ()
   (should-not (comp-test-consp 23))
@@ -520,4 +526,36 @@ 
https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-03/msg00914.html.";
      nil))
   (should (eq comp-test-up-val 999)))
 
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Tests for dynamic scope. ;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(ert-deftest comp-tests-dynamic-ffuncall ()
+  "Test calling convention for dynamic binding."
+
+  (should (equal (comp-tests-ffuncall-callee-dyn-f 1 2)
+                 '(1 2)))
+
+  (should (equal (comp-tests-ffuncall-callee-opt-dyn-f 1 2 3 4)
+                 '(1 2 3 4)))
+  (should (equal (comp-tests-ffuncall-callee-opt-dyn-f 1 2 3)
+                 '(1 2 3 nil)))
+  (should (equal (comp-tests-ffuncall-callee-opt-dyn-f 1 2)
+                 '(1 2 nil nil)))
+
+  (should (equal (comp-tests-ffuncall-callee-rest-dyn-f 1 2)
+                 '(1 2 nil)))
+  (should (equal (comp-tests-ffuncall-callee-rest-dyn-f 1 2 3)
+                 '(1 2 (3))))
+  (should (equal (comp-tests-ffuncall-callee-rest-dyn-f 1 2 3 4)
+                 '(1 2 (3 4))))
+
+  (should (equal (comp-tests-ffuncall-callee-opt-rest-dyn-f 1 2)
+                 '(1 2 nil nil)))
+  (should (equal (comp-tests-ffuncall-callee-opt-rest-dyn-f 1 2 3)
+                 '(1 2 3 nil)))
+  (should (equal (comp-tests-ffuncall-callee-opt-rest-dyn-f 1 2 3 4)
+                 '(1 2 3 (4)))))
+
 ;;; comp-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]