emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/pyim 6bbea03 2/2: Add pyim-tests-pyim-dhashcache-get


From: ELPA Syncer
Subject: [elpa] externals/pyim 6bbea03 2/2: Add pyim-tests-pyim-dhashcache-get
Date: Mon, 13 Dec 2021 01:57:38 -0500 (EST)

branch: externals/pyim
commit 6bbea038e7f89cbe29cad57c9ca17ecefbbca957
Author: Feng Shu <tumashu@163.com>
Commit: Feng Shu <tumashu@163.com>

    Add pyim-tests-pyim-dhashcache-get
    
        * tests/pyim-tests.el (pyim-tests-pyim-dhashcache-get): New test.
    
        * pyim-dcache.el (pyim-dcache-get): call pyim-pymap-py2cchar-get.
    
        * pyim-dregcache.el (pyim-dregcache-get): do not call 
pyim-pymap-py2cchar-get.
    
        * pyim-dhashcache.el (pyim-dhashcache-get): do not call 
pyim-pymap-py2cchar-get
---
 pyim-dcache.el      |  3 ++-
 pyim-dhashcache.el  |  2 +-
 pyim-dregcache.el   |  3 +--
 tests/pyim-tests.el | 12 ++++++++++++
 4 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/pyim-dcache.el b/pyim-dcache.el
index 06dbe1b..324fbf1 100644
--- a/pyim-dcache.el
+++ b/pyim-dcache.el
@@ -288,7 +288,8 @@ scheme 中的 :code-prefix-history 信息。"
 
 当词库文件加载完成后,pyim 就可以用这个函数从词库缓存中搜索某个
 code 对应的中文词条了."
-  (pyim-dcache-call-api 'get code from))
+  `(,@(pyim-dcache-call-api 'get code from)
+    ,@(pyim-pymap-py2cchar-get code t t)))
 
 ;; ** 分割 code
 (defun pyim-dcache-code-split (code)
diff --git a/pyim-dhashcache.el b/pyim-dhashcache.el
index d81041c..9f64161 100644
--- a/pyim-dhashcache.el
+++ b/pyim-dhashcache.el
@@ -302,7 +302,7 @@ code 对应的中文词条了。
              (value (and cache (gethash code cache))))
         (when value
           (setq result (append result value)))))
-    `(,@result ,@(pyim-pymap-py2cchar-get code t t))))
+    result))
 
 (defun pyim-dhashcache-update-icode2word (&optional force)
   "对 personal 缓存中的词条进行排序,加载排序后的结果.
diff --git a/pyim-dregcache.el b/pyim-dregcache.el
index 92fc357..ba8d07e 100644
--- a/pyim-dregcache.el
+++ b/pyim-dregcache.el
@@ -281,8 +281,7 @@ DICT-FILES 是词库文件列表. DICTS-MD5 是词库的MD5校验码.
             (setq result (append (pyim-dregcache-get-1 content code) 
result)))))
       ;; `push' plus `nreverse' is more efficient than `add-to-list'
       ;; Many examples exist in Emacs' own code
-      (setq result (nreverse result))
-      `(,@result ,@(pyim-pymap-py2cchar-get code t t)))))
+      (nreverse result))))
 
 (defun pyim-dregcache-get-icode2word-ishortcode2word (code)
   "以 CODE 搜索个人词和个人联想词.  正则表达式搜索词库,不需要为联想词开单独缓存."
diff --git a/tests/pyim-tests.el b/tests/pyim-tests.el
index d042dd4..a8cf903 100644
--- a/tests/pyim-tests.el
+++ b/tests/pyim-tests.el
@@ -731,6 +731,18 @@ zuo-zuo-you-mang 作作有芒")
 yin-xing 因行
 ")))))
 
+(ert-deftest pyim-tests-pyim-dhashcache-get ()
+  (let ((pyim-dhashcache-code2word (make-hash-table :test #'equal))
+        (pyim-dhashcache-icode2word (make-hash-table :test #'equal)))
+
+    (puthash "ni-hao" '("呢耗") pyim-dhashcache-icode2word)
+    (puthash "ni-hao" '("你好") pyim-dhashcache-code2word)
+
+    (should (equal (pyim-dhashcache-get "ni-hao" '(code2word)) '("你好")))
+    (should (equal (pyim-dhashcache-get "ni-hao" '(icode2word)) '("呢耗")))
+    (should (equal (pyim-dhashcache-get "ni-hao" '(code2word icode2word)) 
'("你好" "呢耗")))
+    (should (equal (pyim-dhashcache-get "ni-hao") '("呢耗" "你好")))))
+
 ;; ** pyim-dregcache 相关单元测试
 (ert-deftest pyim-tests-pyim-general ()
   (let ((pyim-dcache-backend 'pyim-dregcache))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]