Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Add integration test for hie-hare-rename #147

Merged
merged 2 commits into from
Dec 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,3 @@ test-haskell:
.PHONY: ghci-test
ghci-test:
stack ghci --main-is=haskell-ide-test


22 changes: 12 additions & 10 deletions elisp/hie.el
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ association lists and count on HIE to use default values there."
type-info))))

(defmacro hie-with-refactor-buffer (&rest body)
'(setq hie-refactor-buffer (get-buffer-create "*hie-refactor*"))
`(with-current-buffer hie-refactor-buffer ,@body))
`(progn (setq hie-refactor-buffer (get-buffer-create "*hie-refactor*"))
(with-current-buffer hie-refactor-buffer ,@body)))

(defmacro hie-literal-save-excursion (&rest body)
"Like save-excursion but preserves line and column instead of point"
Expand All @@ -190,8 +190,8 @@ association lists and count on HIE to use default values there."
(-if-let (((&alist 'first first 'second second 'diff diff)) refactor)
(progn
(hie-with-refactor-buffer
(erase-buffer)
(insert diff))
(erase-buffer)
(insert diff))
(let ((refactored-buffer (create-file-buffer second))
(old-buffer (or (find-buffer-visiting first)
(create-file-buffer first))))
Expand Down Expand Up @@ -310,17 +310,19 @@ Keymap:
:keymap 'hie-mode-map

(if hie-mode
(unless (hie-process-live-p)
(hie-start-process)
(progn
(unless (hie-process-live-p)
(hie-start-process))
(setq hie-process-handle-message
#'hie-handle-first-plugins-command)
(hie-post-message
'(("cmd" . "base:plugins"))))

;; we need to kill hie if this is the last one buffer standing
(unless (cl-find-if (lambda (buffer)
(with-current-buffer buffer
(bound-and-true-p hie-mode))) (buffer-list))
(hie-kill-process))))
(progn
(unless (cl-find-if (lambda (buffer)
(with-current-buffer buffer
(bound-and-true-p hie-mode))) (buffer-list))
(hie-kill-process)))))

(provide 'hie)
18 changes: 18 additions & 0 deletions elisp/tests/hie-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,24 @@ http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15990."
(cons 'type "text")
(cons 'val param2)))))
test-command))))
(hie-define-test
hie-can-hare-rename
(save-excursion
(find-file "test/testdata/HaReRename.hs")
(move-to-column 0)
(goto-line 4)
(hie-mode)
(really-sleep-for 10 (lambda () (fboundp 'hie-hare-rename)))
(hie-hare-rename "foo_renamed")
(really-sleep-for
100
(lambda ()
(equal "\nmain = putStrLn \"hello\"\n\nfoo_renamed :: Int -> Int\nfoo_renamed x = x + 3\n\n"
(buffer-substring-no-properties (point-min) (point-max)))))
(let ((refactored-string (buffer-substring-no-properties (point-min) (point-max))))
(revert-buffer nil t)
(should (equal "\nmain = putStrLn \"hello\"\n\nfoo_renamed :: Int -> Int\nfoo_renamed x = x + 3\n\n"
refactored-string)))))



Expand Down