New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add basic test case. #162
Add basic test case. #162
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
(require 'ert) | ||
|
||
(require 'auto-complete) | ||
(require 'auto-complete-config) | ||
|
||
(defmacro auto-complete-test:common (&rest body) | ||
(declare (indent 0) (debug t)) | ||
`(save-excursion | ||
;; (with-current-buffer "*scratch*" | ||
(with-temp-buffer | ||
(switch-to-buffer (current-buffer)) | ||
(auto-complete-mode 1) | ||
(emacs-lisp-mode) | ||
,@body | ||
(ac-menu-delete) | ||
))) | ||
|
||
(ert-deftest auto-complete-test () | ||
(auto-complete-test:common | ||
(defvar ac-source-test | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. defvar を使うと、どちらかのテストで指定した変数の値が使われなくなってしまいます。 let で指定するのが良いんじゃないでしょうか。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #163 で修正しました |
||
'((candidates list "Foo" "FooBar" "Bar" "Baz" "LongLongLine"))) | ||
(defvar ac-source-action-test | ||
'((candidates list "Action1" "Action2") | ||
(action . (lambda () (message "Done!"))))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. L40 もそうですが、 message を呼ぶよりは また、 batch モードで起動したときに、 ERT の output に message が混ざって結果が見辛くなります。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. etc/test.txt から引っ張ったきたので、何も考えてませんでした。 |
||
(setq ac-sources '(ac-source-test ac-source-action-test)) | ||
(should-not (popup-live-p ac-menu)) | ||
(should (eq ac-menu nil)) | ||
(insert "Foo") | ||
(auto-complete) | ||
(should (popup-live-p ac-menu)) | ||
(should (equal (popup-list ac-menu) '("Foo" "FooBar"))) | ||
)) | ||
|
||
(ert-deftest auto-complete-test2 () | ||
(auto-complete-test:common | ||
(defvar ac-source-test | ||
'((candidates list "Foo" "FooBar" "Bar" "Baz" "LongLongLine"))) | ||
(defvar ac-source-action-test | ||
'((candidates list "Action1" "Action2") | ||
(action . (lambda () (message "Done!"))))) | ||
(setq ac-sources '(ac-source-test ac-source-action-test)) | ||
(should-not (popup-live-p ac-menu)) | ||
(should (eq ac-menu nil)) | ||
(insert "Foo") | ||
(auto-complete) | ||
(execute-kbd-macro "B") | ||
(ac-update-greedy) | ||
(should (popup-live-p ac-menu)) | ||
(should (equal (popup-list ac-menu) '("FooBar"))) | ||
)) | ||
|
||
(ert-run-tests-interactively t) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. テストの方法は、 interactive ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. おっしゃる通りだと思います。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この行は要らないのでは?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9行目に限れば不要です。