emacs-diffs
[Top][All Lists]
Advanced

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

emacs-27 cd55984: Calc: add missing dynamic variable declarations


From: Mattias Engdegård
Subject: emacs-27 cd55984: Calc: add missing dynamic variable declarations
Date: Thu, 26 Dec 2019 13:40:45 -0500 (EST)

branch: emacs-27
commit cd559841537726315d72a303447140f71e34f635
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>

    Calc: add missing dynamic variable declarations
    
    * lisp/calc/calc-alg.el (math-simplify-only, calc-simplify-mode)
    (math-expand-formulas, calc-poly-div-remainder)
    (math-living-dangerously, math-simplifying, calc-angle-mode)
    (calc-prefer-frac, math-poly-base-variable):
    Declare dynamic variables.
    * test/lisp/calc/calc-tests.el (calc-poly-div):
    Add test for at least one bug caused by missing declarations.
---
 lisp/calc/calc-alg.el        | 15 +++++++++++++++
 test/lisp/calc/calc-tests.el | 15 +++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/lisp/calc/calc-alg.el b/lisp/calc/calc-alg.el
index c3efeee..4905a45 100644
--- a/lisp/calc/calc-alg.el
+++ b/lisp/calc/calc-alg.el
@@ -30,6 +30,8 @@
 
 ;;; Algebra commands.
 
+(defvar math-simplify-only)
+
 (defun calc-alg-evaluate (arg)
   (interactive "p")
   (calc-slow-wrapper
@@ -38,6 +40,8 @@
       (calc-modify-simplify-mode arg)
       (calc-enter-result 1 "dsmp" (calc-top 1))))))
 
+(defvar calc-simplify-mode)
+
 (defun calc-modify-simplify-mode (arg)
   (if (= (math-abs arg) 2)
       (setq calc-simplify-mode 'alg)
@@ -67,6 +71,8 @@
    (calc-with-default-simplification
     (calc-enter-result 1 "esmp" (math-simplify-extended (calc-top-n 1))))))
 
+(defvar math-expand-formulas)
+
 (defun calc-expand-formula (arg)
   (interactive "p")
   (calc-slow-wrapper
@@ -160,6 +166,8 @@
    (calc-binary-op "pgcd" 'calcFunc-pgcd arg)))
 
 
+(defvar calc-poly-div-remainder)
+
 (defun calc-poly-div (arg)
   (interactive "P")
   (calc-slow-wrapper
@@ -303,6 +311,7 @@
                  (math-beforep (car a) (car b)))))
        (t (string-lessp (car a) (car b)))))
 
+(defvar math-living-dangerously)
 
 (defsubst math-simplify-extended (a)
   (let ((math-living-dangerously t))
@@ -363,6 +372,9 @@
 
 ;; math-normalize-error is declared in calc.el.
 (defvar math-normalize-error)
+(defvar math-simplifying)
+(defvar calc-angle-mode)
+
 (defun math-simplify (top-expr)
   (let ((math-simplifying t)
         (calc-angle-mode (if (calc-input-angle-units top-expr)
@@ -677,6 +689,8 @@ and should return the simplified expression to use (or 
nil)."
        (math-make-frac (math-gcd (nth 1 a) (nth 1 b))
                        (math-gcd (nth 2 a) (nth 2 b)))))))
 
+(defvar calc-prefer-frac)
+
 (math-defsimplify %
   (and (Math-realp (nth 2 expr))
        (Math-posp (nth 2 expr))
@@ -1671,6 +1685,7 @@ and should return the simplified expression to use (or 
nil)."
 (defvar math-is-poly-degree)
 (defvar math-is-poly-loose)
 (defvar math-var)
+(defvar math-poly-base-variable)
 
 (defun math-is-polynomial (expr var &optional degree loose)
   (let* ((math-poly-base-variable (if loose
diff --git a/test/lisp/calc/calc-tests.el b/test/lisp/calc/calc-tests.el
index 3f5adce..33e6b14 100644
--- a/test/lisp/calc/calc-tests.el
+++ b/test/lisp/calc/calc-tests.el
@@ -318,6 +318,21 @@ An existing calc stack is reused, otherwise a new one is 
created."
            '(vec (calcFunc-eq (var x var-x) 3)
                  (calcFunc-eq (var y var-y) 0)))))
 
+(ert-deftest calc-poly-div ()
+  "Test polynomial division, and that the remainder is recorded in the trail."
+  (with-current-buffer (calc-trail-buffer)
+    (let ((inhibit-read-only t))
+      (erase-buffer)
+
+      (calc-eval "2x**3+1" 'push)
+      (calc-eval "x**2+2x" 'push)
+      (calc-poly-div nil)
+      (let ((tos (calc-top-n 1))
+            (trail (buffer-string)))
+        (calc-pop 0)
+        (should (equal tos '(- (* 2 (var x var-x)) 4)))
+        (should (equal trail "pdiv 2 * x - 4\nprem 8 * x + 1\n"))))))
+
 (provide 'calc-tests)
 ;;; calc-tests.el ends here
 



reply via email to

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