diff options
author | Tino Calancha <tino.calancha@gmail.com> | 2017-05-18 14:47:06 +0900 |
---|---|---|
committer | Tino Calancha <tino.calancha@gmail.com> | 2017-05-18 14:47:06 +0900 |
commit | c48e539226a062d01b8d5534644fae959506a743 (patch) | |
tree | bff2bc631c358f616ab51c671c2a60201e9488a6 /test/lisp/calc | |
parent | eab1a6307b09180bd775cfb6bf7330eb5367bbe0 (diff) | |
download | emacs-c48e539226a062d01b8d5534644fae959506a743.tar.gz |
Use the expression angle units while simplifying it
Don't use the angle mode, use the angle units included
in the expression instead (Bug#23889).
* lisp/calc/calc-alg.el (calc-input-angle-units): New defun.
(math-simplify): Use it.
* lisp/calc/calc-forms.el (math-to-hms, math-from-hms):
Don't use calc-angle-mode if math-simplifying-units is non-nil.
* lisp/calc/calc-math.el (calcFunc-nroot, math-from-radians)
(math-to-radians-2, math-from-radians-2): Don't convert angle
to radians if math-simplifying-units is non-nil.
* test/lisp/calc/calc-tests.el (test-calc-23889): Add test.
Diffstat (limited to 'test/lisp/calc')
-rw-r--r-- | test/lisp/calc/calc-tests.el | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/lisp/calc/calc-tests.el b/test/lisp/calc/calc-tests.el index 8f56d48d01d..68567dcc212 100644 --- a/test/lisp/calc/calc-tests.el +++ b/test/lisp/calc/calc-tests.el @@ -86,6 +86,50 @@ An existing calc stack is reused, otherwise a new one is created." (math-read-expr "1m") "cm") '(* -100 (var cm var-cm))))) +(ert-deftest test-calc-23889 () + "Test for http://debbugs.gnu.org/23889 and 25652." + (dolist (mode '(deg rad)) + (let ((calc-angle-mode mode)) + ;; If user inputs angle units, then should ignore `calc-angle-mode'. + (should (string= "5253" + (substring + (number-to-string + (nth 1 + (math-simplify-units + '(calcFunc-cos (* 45 (var rad var-rad)))))) + 0 4))) + (should (string= "7071" + (substring + (number-to-string + (nth 1 + (math-simplify-units + '(calcFunc-cos (* 45 (var deg var-deg)))))) + 0 4))) + (should (string= "8939" + (substring + (number-to-string + (nth 1 + (math-simplify-units + '(+ (calcFunc-sin (* 90 (var rad var-rad))) + (calcFunc-cos (* 90 (var deg var-deg))))))) + 0 4))) + (should (string= "5519" + (substring + (number-to-string + (nth 1 + (math-simplify-units + '(+ (calcFunc-sin (* 90 (var deg var-deg))) + (calcFunc-cos (* 90 (var rad var-rad))))))) + 0 4))) + ;; If user doesn't input units, then must use `calc-angle-mode'. + (should (string= (if (eq calc-angle-mode 'deg) + "9998" + "5403") + (substring + (number-to-string + (nth 1 (calcFunc-cos 1))) + 0 4)))))) + (provide 'calc-tests) ;;; calc-tests.el ends here |