Commit a8d9d882 authored by Yuanle Song's avatar Yuanle Song
Browse files

v1.2.5 renamed zero-framework.el to zero.el;

split ert tests to separate files. These tests are not required in melpa
distribution.
parent d71546e6
VERSION := $(shell grep 'setq zero-version' zero-framework.el | cut -d'"' -f2) VERSION := $(shell grep 'setq zero-version' zero.el | cut -d'"' -f2)
default: compile default: compile
pkg-el: pkg-el:
sed "s/PKG_VERSION/$(VERSION)/g" zero-pkg.el.tpl > zero-pkg.el sed "s/PKG_VERSION/$(VERSION)/g" zero-pkg.el.tpl > zero-pkg.el
compile: compile:
emacs -Q --batch -l zero-reload-all.el -f zero-rebuild -l zero-table.el -f ert-run-tests-batch emacs -Q --batch -l zero-reload-all.el -f zero-rebuild -l zero-table.el -l zero-table-test.el -f ert-run-tests-batch
zip: pkg-el zip: pkg-el
git archive -o zero-el-$(VERSION).zip --prefix=zero/ HEAD git archive -o zero-el-$(VERSION).zip --prefix=zero/ HEAD
pkg: pkg-el pkg: pkg-el
......
zero-el zero-el
Copyright (C) 2019 Yuanle Song <sylecn@gmail.com> Copyright (C) 2019 Yuanle Song <sylecn@gmail.com>
ibus-compute-pixel-position function in zero-framework.el is copied from ibus-compute-pixel-position function in zero.el is copied from ibus.el.
ibus.el. This function is under GPLv3 license. This function is under GPLv3 license. Copyright (C) 2010-2012 S. Irie
Copyright (C) 2010-2012 S. Irie
* COMMENT -*- mode: org -*- * COMMENT -*- mode: org -*-
#+Date: 2019-09-01 #+Date: 2019-09-01
Time-stamp: <2019-09-01> Time-stamp: <2019-10-11>
* zero-el * zero-el
...@@ -8,9 +8,9 @@ zero-el provides zero-pinyin, an emacs pinyin input method for Chinese and ...@@ -8,9 +8,9 @@ zero-el provides zero-pinyin, an emacs pinyin input method for Chinese and
zero-framework, which is an emacs Chinese input method framework. zero-framework, which is an emacs Chinese input method framework.
* File list * File list
- zero-framework.el - zero.el
zero-framework source code. This provides the framework and user interface zero framework source code. This provides the framework and user interface
for zero-el. for zero-el.
- zero-panel.el - zero-panel.el
...@@ -23,7 +23,7 @@ zero-framework, which is an emacs Chinese input method framework. ...@@ -23,7 +23,7 @@ zero-framework, which is an emacs Chinese input method framework.
- zero-pinyin.el - zero-pinyin.el
pinyin input method implemented using zero-framework.el pinyin input method implemented using zero.el
- zero-quickdial.el - zero-quickdial.el
...@@ -35,7 +35,7 @@ zero-framework, which is an emacs Chinese input method framework. ...@@ -35,7 +35,7 @@ zero-framework, which is an emacs Chinese input method framework.
- zero-table.el - zero-table.el
serves as an example of how to use zero-framework to create new input serves as an example of how to use zero framework to create new input
methods. methods.
* introduce to zero-el * introduce to zero-el
...@@ -44,5 +44,5 @@ https://blog.emacsos.com/zero-el.html ...@@ -44,5 +44,5 @@ https://blog.emacsos.com/zero-el.html
* License * License
zero-el is under Apache License 2.0 zero-el is under Apache License 2.0
ibus-compute-pixel-position function in zero-framework.el is under GPLv3. ibus-compute-pixel-position function in zero.el is under GPLv3.
see NOTICE file. see NOTICE file.
* COMMENT -*- mode: org -*- * COMMENT -*- mode: org -*-
#+Date: 2019-10-08 #+Date: 2019-10-08
Time-stamp: <2019-10-10> Time-stamp: <2019-10-11>
#+STARTUP: content #+STARTUP: content
* notes :entry: * notes :entry:
** 2019-04-01 zero-framework.el a Chinese IM framework in emacs; FSM :doc: ** 2019-04-01 zero.el a Chinese IM framework in emacs; FSM :doc:
title was: how to write a modern im for emacs. title was: how to write a modern im for emacs.
cd ~/lisp/elisp/zero/ cd ~/lisp/elisp/zero/
- DONE can I implement it as a minor mode? yes. - DONE can I implement it as a minor mode? yes.
- DONE can I use panel to show candidates? yes. - DONE can I use panel to show candidates? yes.
- zero minor mode FSM - zero minor mode FSM
implemented in zero-framework.el implemented in zero.el
| Imp | state | action | next state | trigger action | | Imp | state | action | next state | trigger action |
|-----+------------------+-----------------------------------------------------+------------------+---------------------------------------------------------------------------------------------------------| |-----+------------------+-----------------------------------------------------+------------------+---------------------------------------------------------------------------------------------------------|
...@@ -83,6 +83,10 @@ cd ~/lisp/elisp/zero/ ...@@ -83,6 +83,10 @@ cd ~/lisp/elisp/zero/
* later :entry: * later :entry:
* current :entry: * current :entry:
** **
** 2019-10-11 move tests to separated files.
otherwise (require 'zero-pinyin) will fail because (require 'ert) is not in
source code.
* done :entry: * done :entry:
** 2019-10-09 release zero-el on melpa ** 2019-10-09 release zero-el on melpa
melpa/CONTRIBUTING.org at master · melpa/melpa · GitHub melpa/CONTRIBUTING.org at master · melpa/melpa · GitHub
......
;;; zero-panel-test.el --- tests for zero-panel.el -*- lexical-binding: t -*-
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;; http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.
;;; Commentary:
;;
;;; Code:
(require 'ert)
(require 'zero-panel)
(ert-deftest zero-alist-to-asv ()
(should (equal (zero-alist-to-asv nil) '(:array :signature "{sv}")))
(should (equal (zero-alist-to-asv
'(("name" "foo")
("timeout" :int32 10)))
'(:array
(:dict-entry "name" (:variant "foo"))
(:dict-entry "timeout" (:variant :int32 10))))))
(provide 'zero-panel-test)
;;; zero-panel-test.el ends here
...@@ -70,15 +70,6 @@ For example, ...@@ -70,15 +70,6 @@ For example,
(push (list :dict-entry (car item) (cons :variant (cdr item))) result)) (push (list :dict-entry (car item) (cons :variant (cdr item))) result))
(reverse result)))) (reverse result))))
(ert-deftest zero-alist-to-asv ()
(should (equal (zero-alist-to-asv nil) '(:array :signature "{sv}")))
(should (equal (zero-alist-to-asv
'(("name" "foo")
("timeout" :int32 10)))
'(:array
(:dict-entry "name" (:variant "foo"))
(:dict-entry "timeout" (:variant :int32 10))))))
;;============ ;;============
;; public API ;; public API
;;============ ;;============
......
;;; zero-pinyin-service-test.el --- tests for zero-pinyin-service.el -*- lexical-binding: t -*-
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;; http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.
;;; Commentary:
;;
;;; Code:
(require 'zero-pinyin-service)
(require 'ert)
(eval-when-compile (require 'cl-macs))
(ert-deftest zero-pinyin-candidate-pinyin-indices-to-dbus-format ()
(should (equal (zero-pinyin-candidate-pinyin-indices-to-dbus-format '((22 31)))
'(:array (:struct :int32 22 :int32 31))))
(should (equal (zero-pinyin-candidate-pinyin-indices-to-dbus-format
'((17 46) (7 55)))
'(:array (:struct :int32 17 :int32 46)
(:struct :int32 7 :int32 55)))))
(ert-deftest zero-pinyin-service-get-candidates ()
(cl-destructuring-bind (cs ls &rest rest)
(zero-pinyin-service-get-candidates "liyifeng" 1)
(should (or (and (equal (car cs) "李易峰")
(= (car ls) 8))
(and (equal (car cs) "利益")
(= (car ls) 4)))))
(cl-destructuring-bind (cs ls &rest rest)
(zero-pinyin-service-get-candidates "wenti" 1)
(should (equal (car cs) "问题"))
(should (= (car ls) 5)))
(cl-destructuring-bind (cs ls &rest rest)
(zero-pinyin-service-get-candidates "meiyou" 1)
(should (equal (car cs) "没有"))
(should (= (car ls) 6)))
(cl-destructuring-bind (cs ls &rest rest)
(zero-pinyin-service-get-candidates "shi" 1)
(should (equal (car cs) "是"))
(should (= (car ls) 3)))
(cl-destructuring-bind (cs ls &rest rest)
(zero-pinyin-service-get-candidates "de" 1)
(should (equal (car cs) "的"))
(should (= (car ls) 2))))
(provide 'zero-pinyin-service-test)
;;; zero-pinyin-service-test.el ends here
...@@ -86,14 +86,6 @@ GET-CANDIDATES-COMPLETE the async handler function." ...@@ -86,14 +86,6 @@ GET-CANDIDATES-COMPLETE the async handler function."
result)) result))
(reverse result))) (reverse result)))
(ert-deftest zero-pinyin-candidate-pinyin-indices-to-dbus-format ()
(should (equal (zero-pinyin-candidate-pinyin-indices-to-dbus-format '((22 31)))
'(:array (:struct :int32 22 :int32 31))))
(should (equal (zero-pinyin-candidate-pinyin-indices-to-dbus-format
'((17 46) (7 55)))
'(:array (:struct :int32 17 :int32 46)
(:struct :int32 7 :int32 55)))))
(defun zero-pinyin-service-commit-candidate-async (candidate candidate_pinyin_indices) (defun zero-pinyin-service-commit-candidate-async (candidate candidate_pinyin_indices)
"Commit candidate asynchronously. "Commit candidate asynchronously.
...@@ -116,36 +108,6 @@ DELETE-CANDIDATE-COMPLETE the async handler function." ...@@ -116,36 +108,6 @@ DELETE-CANDIDATE-COMPLETE the async handler function."
"Quit panel application." "Quit panel application."
(zero-pinyin-service-async-call "Quit" nil)) (zero-pinyin-service-async-call "Quit" nil))
;;================
;; some app test
;;================
(eval-when-compile (require 'cl-macs))
(ert-deftest zero-pinyin-service-get-candidates ()
(cl-destructuring-bind (cs ls &rest rest)
(zero-pinyin-service-get-candidates "liyifeng" 1)
(should (or (and (equal (car cs) "李易峰")
(= (car ls) 8))
(and (equal (car cs) "利益")
(= (car ls) 4)))))
(cl-destructuring-bind (cs ls &rest rest)
(zero-pinyin-service-get-candidates "wenti" 1)
(should (equal (car cs) "问题"))
(should (= (car ls) 5)))
(cl-destructuring-bind (cs ls &rest rest)
(zero-pinyin-service-get-candidates "meiyou" 1)
(should (equal (car cs) "没有"))
(should (= (car ls) 6)))
(cl-destructuring-bind (cs ls &rest rest)
(zero-pinyin-service-get-candidates "shi" 1)
(should (equal (car cs) "是"))
(should (= (car ls) 3)))
(cl-destructuring-bind (cs ls &rest rest)
(zero-pinyin-service-get-candidates "de" 1)
(should (equal (car cs) "的"))
(should (= (car ls) 2))))
(provide 'zero-pinyin-service) (provide 'zero-pinyin-service)
;;; zero-pinyin-service.el ends here ;;; zero-pinyin-service.el ends here
;;; zero-pinyin-test.el --- tests for zero-pinyin.el
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;; http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.
;;; Commentary:
;;
;;; Code:
(require 'zero-pinyin)
(require 'ert)
(ert-deftest zero-pinyin-can-start-sequence ()
(should (zero-pinyin-can-start-sequence ?a))
(should (zero-pinyin-can-start-sequence ?l))
(should (zero-pinyin-can-start-sequence ?m))
(should (zero-pinyin-can-start-sequence ?z))
(should-not (zero-pinyin-can-start-sequence ?1))
(should-not (zero-pinyin-can-start-sequence ?.))
(should-not (zero-pinyin-can-start-sequence ?i))
(should-not (zero-pinyin-can-start-sequence ?u))
(should-not (zero-pinyin-can-start-sequence ?v)))
(provide 'zero-pinyin-test)
;;; zero-pinyin-test.el ends here
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
;; dependencies ;; dependencies
;;============== ;;==============
(require 'zero-framework) (require 'zero)
(require 'zero-pinyin-service) (require 'zero-pinyin-service)
;;=============================== ;;===============================
...@@ -119,17 +119,6 @@ COMPLETE-FUNC the callback function when async call completes. it's called with ...@@ -119,17 +119,6 @@ COMPLETE-FUNC the callback function when async call completes. it's called with
(not (= ch ?u)) (not (= ch ?u))
(not (= ch ?v)))) (not (= ch ?v))))
(ert-deftest zero-pinyin-can-start-sequence ()
(should (zero-pinyin-can-start-sequence ?a))
(should (zero-pinyin-can-start-sequence ?l))
(should (zero-pinyin-can-start-sequence ?m))
(should (zero-pinyin-can-start-sequence ?z))
(should-not (zero-pinyin-can-start-sequence ?1))
(should-not (zero-pinyin-can-start-sequence ?.))
(should-not (zero-pinyin-can-start-sequence ?i))
(should-not (zero-pinyin-can-start-sequence ?u))
(should-not (zero-pinyin-can-start-sequence ?v)))
(defun zero-pinyin-pending-preedit-str-changed () (defun zero-pinyin-pending-preedit-str-changed ()
"Update zero states when pending preedit string changed." "Update zero states when pending preedit string changed."
(setq zero-fetch-size 0) (setq zero-fetch-size 0)
......
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
;; See the License for the specific language governing permissions and ;; See the License for the specific language governing permissions and
;; limitations under the License. ;; limitations under the License.
;; Version: 1.2.4 ;; Version: 1.2.5
;; URL: https://gitlab.emacsos.com/sylecn/zero-el ;; URL: https://gitlab.emacsos.com/sylecn/zero-el
;; Package-Version: 1.2.4 ;; Package-Version: 1.2.5
;; Package-Requires: ((emacs "24") (s "1.2.0")) ;; Package-Requires: ((emacs "24") (s "1.2.0"))
;;; Commentary: ;;; Commentary:
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
;;; Code: ;;; Code:
(define-package "zero" "1.2.4" (define-package "zero" "1.2.5"
"a Chinese input method framework" "a Chinese input method framework"
'((emacs "24") '((emacs "24")
(s "1.2.0"))) (s "1.2.0")))
......
...@@ -26,9 +26,14 @@ SOURCE-DIR where to find the zero source dir." ...@@ -26,9 +26,14 @@ SOURCE-DIR where to find the zero source dir."
(let ((source-dir (or source-dir "~/lisp/elisp/zero/"))) (let ((source-dir (or source-dir "~/lisp/elisp/zero/")))
(dolist (f '("zero-quickdial.el" (dolist (f '("zero-quickdial.el"
"zero-panel.el" "zero-panel.el"
"zero-framework.el" "zero-panel-test.el"
"zero.el"
"zero-test.el"
"zero-pinyin-service.el" "zero-pinyin-service.el"
"zero-pinyin.el")) "zero-pinyin-service-test.el"
"zero-pinyin.el"
"zero-pinyin-test.el"
))
(byte-compile-file (concat source-dir f) t)))) (byte-compile-file (concat source-dir f) t))))
(defun zero-reload-all () (defun zero-reload-all ()
...@@ -37,10 +42,16 @@ SOURCE-DIR where to find the zero source dir." ...@@ -37,10 +42,16 @@ SOURCE-DIR where to find the zero source dir."
(byte-recompile-directory "~/lisp/elisp/zero/" 0) (byte-recompile-directory "~/lisp/elisp/zero/" 0)
(dolist (f '("zero-quickdial.elc" (dolist (f '("zero-quickdial.elc"
"zero-panel.elc" "zero-panel.elc"
"zero-framework.elc" "zero-panel-test.elc"
"zero-table.el" "zero.elc"
"zero-test.elc"
"zero-pinyin-service.elc" "zero-pinyin-service.elc"
"zero-pinyin.elc")) "zero-pinyin-service-test.elc"
"zero-pinyin.elc"
"zero-pinyin-test.elc"
"zero-table.el"
"zero-table-test.el"
))
(load-file f))) (load-file f)))
;;; zero-reload-all.el ends here ;;; zero-reload-all.el ends here
;;; zero-table-test.el --- tests for zero-table.el -*- no-byte-compile: t; lexical-binding: t -*-
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;; http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.
;;; Commentary:
;;
;;; Code:
(require 'zero-table)
(require 'ert)
(ert-deftest zero-table-build-candidates ()
(should (equal (zero-table-build-candidates "ph") '("18612345678")))
(should (equal (zero-table-build-candidates "m")
'("https://msdn.microsoft.com/en-us"
"foo@example.com"
"https://ditu.amap.com/"))))
(ert-deftest zero-table-can-start-sequence ()
(should (zero-table-can-start-sequence ?a))
(should (zero-table-can-start-sequence ?m))
(should-not (zero-table-can-start-sequence ?1))
(should-not (zero-table-can-start-sequence ?b)))
(provide 'zero-table-test)
;;; zero-table-test.el ends here
;;; zero-table.el --- a demo table based input method based on zero-framework.el -*- no-byte-compile: t; lexical-binding: t -*- ;;; zero-table.el --- a demo table based input method based on zero.el -*- no-byte-compile: t; lexical-binding: t -*-
;; Licensed under the Apache License, Version 2.0 (the "License"); ;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License. ;; you may not use this file except in compliance with the License.
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
;; dependencies ;; dependencies
;;============== ;;==============
(require 'zero-framework) (require 'zero)
;;=============================== ;;===============================
;; basic data and emacs facility ;; basic data and emacs facility
...@@ -51,12 +51,6 @@ ...@@ -51,12 +51,6 @@
"Build candidates by looking up PREEDIT-STR in `zero-table-table'." "Build candidates by looking up PREEDIT-STR in `zero-table-table'."
(mapcar 'cdr (sort (cl-remove-if-not (lambda (pair) (string-prefix-p preedit-str (car pair))) zero-table-table) 'zero-table-sort-key))) (mapcar 'cdr (sort (cl-remove-if-not (lambda (pair) (string-prefix-p preedit-str (car pair))) zero-table-table) 'zero-table-sort-key)))
(ert-deftest zero-table-build-candidates ()
(should (equal (zero-table-build-candidates "ph") '("18612345678")))
(should (equal (zero-table-build-candidates "m") '("https://msdn.microsoft.com/en-us"
"foo@example.com"
"https://ditu.amap.com/"))))
;; (defun zero-table-build-candidates-async (preedit-str) ;; (defun zero-table-build-candidates-async (preedit-str)
;; "build candidate list, when done show it via `zero-table-show-candidates'" ;; "build candidate list, when done show it via `zero-table-show-candidates'"
;; (zero-table-debug "building candidate list\n") ;; (zero-table-debug "building candidate list\n")
...@@ -69,12 +63,6 @@ ...@@ -69,12 +63,6 @@
"Return t if char CH can start a preedit sequence." "Return t if char CH can start a preedit sequence."
(member (make-string 1 ch) zero-table-sequence-initials)) (member (make-string 1 ch) zero-table-sequence-initials))
(ert-deftest zero-table-can-start-sequence ()
(should (zero-table-can-start-sequence ?a))
(should (zero-table-can-start-sequence ?m))
(should-not (zero-table-can-start-sequence ?1))
(should-not (zero-table-can-start-sequence ?b)))
;;=============================== ;;===============================
;; register IM to zero framework ;; register IM to zero framework
;;=============================== ;;===============================
......
;;; zero-test.el --- tests for zero.el -*- lexical-binding: t -*-
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;; http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.
;;; Commentary:
;;
;;; Code:
(require 'zero)
(require 'ert)
(ert-deftest zero-cycle-list ()
(should (= (zero-cycle-list '(1 2 3) 1) 2))
(should (eq (zero-cycle-list '(a b c) 'a) 'b))
(should (eq (zero-cycle-list '(a b c) 'b) 'c))
(should (eq (zero-cycle-list '(a b c) 'c) 'a))
(should (eq (zero-cycle-list '(a b c) 'd) nil)))
(ert-deftest zero-convert-ch-to-full-width ()
(should (= (zero-convert-ch-to-full-width ?\!) ?\!)))
(ert-deftest zero-convert-str-to-full-width ()
(should (string-equal "!" (zero-convert-str-to-full-width "!")))
(should (string-equal "(" (zero-convert-str-to-full-width "(")))
(should (string-equal "(:)" (zero-convert-str-to-full-width "(:)")))
(should (string-equal "ABab" (zero-convert-str-to-full-width "ABab")))
(should (string-equal "hehe" (zero-convert-str-to-full-width "hehe")))
(should (string-equal "(A)" (zero-convert-str-to-full-width "(A)"))))
(provide 'zero-test)
;;; zero-test.el ends here
;;; zero-framework.el --- Zero Chinese input method framework -*- lexical-binding: t -*- ;;; zero.el --- Zero Chinese input method framework -*- lexical-binding: t -*-
;; Licensed under the Apache License, Version 2.0 (the "License"); ;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License. ;; you may not use this file except in compliance with the License.
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
;;; Commentary: ;;; Commentary:
;; zero-framework is a Chinese input method framework for Emacs, implemented ;; zero is a Chinese input method framework for Emacs, implemented
;; as an Emacs minor mode. ;; as an Emacs minor mode.
;; ;;
;; You can cycle zero-punctuation-level in current buffer by C-c , , ;; You can cycle zero-punctuation-level in current buffer by C-c , ,
...@@ -126,20 +126,13 @@ If item is not in lst, return nil."