Fix renaming a test and ensure its removal from ert
This commit is contained in:
@@ -354,11 +354,33 @@ the description. This may destroy existing links, or change their targets so use
|
|||||||
(new-function-name (as-function-name new-name)))
|
(new-function-name (as-function-name new-name)))
|
||||||
(message "Will rename to %s" new-function-name) ;; should use as-function-name here
|
(message "Will rename to %s" new-function-name) ;; should use as-function-name here
|
||||||
(movd (intern old-name) (intern new-function-name))
|
(movd (intern old-name) (intern new-function-name))
|
||||||
|
(ert-make-test-unbound (intern old-name))
|
||||||
(delete-region begin end)
|
(delete-region begin end)
|
||||||
(insert new-function-name)
|
(insert new-function-name)
|
||||||
(message "Renamed %s to %s." old-name new-name)))
|
(message "Renamed %s to %s." old-name new-name)))
|
||||||
(message "No symbol under cursor."))))
|
(message "No symbol under cursor."))))
|
||||||
|
|
||||||
|
(defun qrefactor/remove-test ()
|
||||||
|
"Renmove test at point from memory.
|
||||||
|
See also ert-delete-test if you want to delete from a list of existing tests."
|
||||||
|
(interactive)
|
||||||
|
(let
|
||||||
|
((bounds
|
||||||
|
(bounds-of-thing-at-point 'symbol)))
|
||||||
|
(if bounds
|
||||||
|
(progn
|
||||||
|
(let*
|
||||||
|
((begin
|
||||||
|
(car bounds))
|
||||||
|
(end
|
||||||
|
(cdr bounds))
|
||||||
|
(old-name
|
||||||
|
(buffer-substring-no-properties begin end)))
|
||||||
|
(ert-make-test-unbound (intern old-name))
|
||||||
|
(message "Undefined %s." old-name ))))
|
||||||
|
(message "No symbol under cursor.")))
|
||||||
|
|
||||||
|
|
||||||
;; tests are better than literate programming when you want to triangulate on the same function
|
;; tests are better than literate programming when you want to triangulate on the same function
|
||||||
;; org only shows the last return value by default, you can return a list of course, but still
|
;; org only shows the last return value by default, you can return a list of course, but still
|
||||||
(defun as-function-name (candidate-name)
|
(defun as-function-name (candidate-name)
|
||||||
@@ -378,4 +400,10 @@ the description. This may destroy existing links, or change their targets so use
|
|||||||
(ert-deftest refactor-rename-replaces-uppercase-with-lowercase()
|
(ert-deftest refactor-rename-replaces-uppercase-with-lowercase()
|
||||||
(should (equal (as-function-name "Echo-chamber")
|
(should (equal (as-function-name "Echo-chamber")
|
||||||
"echo-chamber")))
|
"echo-chamber")))
|
||||||
|
|
||||||
|
(ert-deftest refactor-renamed-now ()
|
||||||
|
(should (equal 1 1)))
|
||||||
|
|
||||||
|
|
||||||
|
(ert-make-test-unbound 'refactor-rename-test-for-fun)
|
||||||
(ert "refactor.*")
|
(ert "refactor.*")
|
||||||
|
|||||||
Reference in New Issue
Block a user