[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/pyim b3868caa80 29/41: Add pyim-probe tests
From: |
ELPA Syncer |
Subject: |
[elpa] externals/pyim b3868caa80 29/41: Add pyim-probe tests |
Date: |
Sat, 4 Jun 2022 09:57:47 -0400 (EDT) |
branch: externals/pyim
commit b3868caa80ddb01d34d251209f457e7f1286c725
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>
Add pyim-probe tests
---
tests/pyim-tests.el | 157 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 156 insertions(+), 1 deletion(-)
diff --git a/tests/pyim-tests.el b/tests/pyim-tests.el
index 1a033f5f65..9b48ffd4ce 100644
--- a/tests/pyim-tests.el
+++ b/tests/pyim-tests.el
@@ -1247,7 +1247,7 @@ yin-xing 因行
;; `pyim-dregcache-get' calls `pyim-pymap-py2cchar-get' before return
result
(should (eq (length words) 26))))
-
+;; ** pyim-cloudim 相关单元测试
(ert-deftest pyim-tests-pyim-cloudim ()
(with-temp-buffer
(insert "HTTP/1.1 200 OK
@@ -1300,6 +1300,161 @@ Transfer-Encoding: chunked
(quanpin (pyim-scheme-get 'quanpin)))
(should (not (pyim-candidates-cloud-search "nihao" quanpin))))))
+;; ** pyim-probe 相关单元测试
+(ert-deftest pyim-tests-pyim-probe-program-mode ()
+ (with-temp-buffer
+ (emacs-lisp-mode)
+ (insert ";; comment")
+ (should-not (pyim-probe-program-mode))
+ (insert "\n")
+ (should (pyim-probe-program-mode))
+ (insert "()")
+ (backward-char 1)
+ (should (pyim-probe-program-mode))
+ (insert "setq test")
+ (should (pyim-probe-program-mode))
+ (insert " \"\"")
+ (backward-char 1)
+ (should-not (pyim-probe-program-mode))))
+
+(ert-deftest pyim-tests-pyim-probe-program-mode ()
+ ;; Isearch mode 不好写测试,这里假设 isearch 命令运行时,至少有一个 buffer 中
+ ;; 变量 isearch-mode 取值为 t. 参考了 `isearch-define-mode-toggle'.
+ (let ((pyim-isearch-mode t))
+ (with-current-buffer (get-buffer-create "test")
+ (setq-local isearch-mode t))
+ (should (pyim-probe-isearch-mode)))))
+
+(ert-deftest pyim-tests-pyim-probe-org-speed-commands ()
+ (with-temp-buffer
+ (let ((org-use-speed-commands t))
+ (org-mode)
+ (insert "* heading")
+ (goto-char (line-beginning-position))
+ (should (pyim-probe-org-speed-commands))
+ (forward-char 1)
+ (should-not (pyim-probe-org-speed-commands))
+ (forward-char 1)
+ (should-not (pyim-probe-org-speed-commands)))))
+
+(ert-deftest pyim-tests-pyim-probe-org-structure-template ()
+ (with-temp-buffer
+ (org-mode)
+ (insert "<")
+ (should (pyim-probe-org-structure-template))
+ (insert "abcde")
+ (should (pyim-probe-org-structure-template))
+ (insert " ")
+ (should-not (pyim-probe-org-structure-template))
+
+ (erase-buffer)
+
+ (insert " <")
+ (should (pyim-probe-org-structure-template))
+ (insert "abcde")
+ (should (pyim-probe-org-structure-template))
+ (insert " ")
+ (should-not (pyim-probe-org-structure-template))))
+
+(ert-deftest pyim-tests-pyim-probe-dynamic-english ()
+ (with-temp-buffer
+ ;; 从光标往前找第一个非数字的字符,为其他字符时,输入下一个字符时默认开启英文输入
+ (insert "english")
+ (should (pyim-probe-dynamic-english))
+
+ (insert "123")
+ (should (pyim-probe-dynamic-english))
+
+ (insert ",")
+ (should (pyim-probe-dynamic-english))
+
+ (insert " ")
+ (should (pyim-probe-dynamic-english))
+
+ ;; 从光标往前找第一个非数字的字符,为中文字符时,输入下一个字符时默认开启中文输入
+ (insert "中文")
+ (should-not (pyim-probe-dynamic-english))))
+
+(ert-deftest pyim-tests-pyim-probe-auto-english ()
+ (with-temp-buffer
+ ;; 1. 当前字符为英文字符(不包括空格)时,输入下一个字符为英文字符
+ (insert "english")
+ (should (pyim-probe-auto-english))
+ ;; 当前字符为中文字符或输入字符为行首字符时,输入的字符为中文字符
+ (insert "\n")
+ (should-not (pyim-probe-auto-english))
+
+ (insert "中文")
+ (should-not (pyim-probe-auto-english))
+ ;; 以单个空格为界,自动切换中文和英文字符
+
+ (insert " ")
+ (should (pyim-probe-auto-english))
+
+ (insert "english ")
+ (should-not (pyim-probe-auto-english))
+
+ (insert "中文 ")
+ (should (pyim-probe-auto-english))))
+
+(ert-deftest pyim-tests-pyim-probe-evil-normal-mode ()
+ (when (featurep 'evil)
+ (with-temp-buffer
+ (evil-local-mode)
+ (should (pyim-probe-evil-normal-mode))
+ (evil-local-mode -1)
+ (should-not (pyim-probe-evil-normal-mode)))))
+
+(ert-deftest pyim-tests-pyim-probe-punctuation-line-beginning (char)
+ (with-temp-buffer
+ (should (pyim-probe-punctuation-line-beginning ?.))
+ (insert "fff")
+ (should-not (pyim-probe-punctuation-line-beginning ?.))
+ (insert "\n")
+ (should (pyim-probe-punctuation-line-beginning ?.))))
+
+(ert-deftest pyim-tests-pyim-probe-punctuation-after-punctuation (char)
+ (with-temp-buffer
+ (should-not (pyim-probe-punctuation-after-punctuation ?.))
+ (insert "'")
+ (should (pyim-probe-punctuation-after-punctuation ?.))
+ (insert "abc")
+ (should-not (pyim-probe-punctuation-after-punctuation ?.))
+ (insert "123")
+ (should-not (pyim-probe-punctuation-after-punctuation ?.))
+ (insert "。")
+ (should-not (pyim-probe-punctuation-after-punctuation ?.))
+ (insert ".")
+ (should (pyim-probe-punctuation-after-punctuation ?.))))
+
+(ert-deftest pyim-tests-pyim-probe-org-latex-mode ()
+ (with-temp-buffer
+ (org-mode)
+ (insert "\\begin{equation}")
+ (save-excursion
+ (insert "\\end{equation}"))
+ (should (pyim-probe-org-latex-mode))
+
+ (erase-buffer)
+ (insert "$$")
+ (backward-char 1)
+ (should (pyim-probe-org-latex-mode))
+
+ (erase-buffer)
+ (insert "\\documentclass{article}")
+ (should (pyim-probe-org-latex-mode))))
+
+(ert-deftest pyim-tests-pyim-probe-exwm-xim-environment ()
+ (with-temp-buffer
+ (setq-local exwm-xim-buffer-p t)
+ (should (pyim-probe-exwm-xim-environment))
+ (setq-local exwm-xim-buffer-p nil)
+ (should-not (pyim-probe-exwm-xim-environment))))
+
+(ert-deftest pyim-tests-pyim-probe-xwidget-webkit-environment ()
+ ;; TODO
+ ))
+
(ert-run-tests-batch-and-exit)
;; * Footer
;;; pyim-tests.el ends here
- [elpa] externals/pyim aa07a23fda 39/41: * pyim-probe.el (pyim-probe-org-latex-mode): Update., (continued)
- [elpa] externals/pyim aa07a23fda 39/41: * pyim-probe.el (pyim-probe-org-latex-mode): Update., ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 573fefe532 38/41: Use (eql symbol) instead of (eql 'symbol)., ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 2f1aaaa9a7 41/41: Merge pull request #442 from tumashu/struct, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim c5a77c3f73 05/41: Add pyim-candidate-create-async, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 0d357b5fd9 08/41: pyim-candidates-create-like-znabc, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 6ce5f49b8f 01/41: Big refactor: use cl-defstruct and cl-defgeneric., ELPA Syncer, 2022/06/04
- [elpa] externals/pyim f5300086fd 02/41: * tests/pyim-tests.el (pyim-tests-pyim-candidates-get-chief): New test., ELPA Syncer, 2022/06/04
- [elpa] externals/pyim f536e5ede3 06/41: Fix warns., ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 33a0f5a9b7 09/41: Add pyim-candidates-create-like-jianpin, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim b6b46a4e36 22/41: * pyim-candidates.el (pyim-candidates-create): Remove method of shuangpin., ELPA Syncer, 2022/06/04
- [elpa] externals/pyim b3868caa80 29/41: Add pyim-probe tests,
ELPA Syncer <=
- [elpa] externals/pyim 951013539c 33/41: Add progress to commentary, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim f4cc14ac64 32/41: Fix pyim-test.el, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 1b767c669e 40/41: * pyim-probe.el (pyim-probe-org-speed-commands): Updated., ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 6ef8630475 11/41: pyim-candidates-create-like-znabc -> pyim-candidates-znabc-words, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 2aa48479b4 14/41: pyim-candidates-create-get-pymap-chars -> pyim-candidates-pymap-chars, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 016064e7fc 16/41: Update docstring., ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 1330b436a6 27/41: Refactor pyim-page.el, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 302f1bff4b 34/41: Refactor pyim-preview.el, ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 987087e515 15/41: Update pyim-candidates-create-quanpin., ELPA Syncer, 2022/06/04
- [elpa] externals/pyim 35bf05ce3e 19/41: pyim-scheme-common -> pyim-scheme, ELPA Syncer, 2022/06/04