[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/objed b7ded6d 083/216: Improve tests, add more tests
From: |
Stefan Monnier |
Subject: |
[elpa] externals/objed b7ded6d 083/216: Improve tests, add more tests |
Date: |
Tue, 8 Jan 2019 12:29:16 -0500 (EST) |
branch: externals/objed
commit b7ded6dea453cb6e24fb00bd3e61a34a6435bf76
Author: Clemera <address@hidden>
Commit: Clemera <address@hidden>
Improve tests, add more tests
---
test/tests.el | 273 ++++++++++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 238 insertions(+), 35 deletions(-)
diff --git a/test/tests.el b/test/tests.el
index a81f047..9be103a 100644
--- a/test/tests.el
+++ b/test/tests.el
@@ -4,6 +4,14 @@
;; adapted from lispy-test.el
+(defun objed--call-object-interactively (o &optional cmd)
+ (let* ((cmd (or cmd (objed--name2func o)))
+ (real-this-command cmd)
+ (inhibit-message t))
+ (setq this-command cmd)
+ (call-interactively cmd)
+ (setq last-command cmd)))
+
(defun objed-decode-keysequence (str)
"Decode STR from e.g. \"23ab5c\" to '(23 \"a\" \"b\" 5 \"c\")"
(let ((table (copy-sequence (syntax-table))))
@@ -58,8 +66,9 @@ Insert KEY if there's no command."
;; (should (equal (objed-decode-keysequence "3\C-?")
;; '(3 ""))))
-;; adapated from `lispy-with'
-(defmacro objed-with (in &rest body)
+(defmacro objed-with (in body &optional object)
+ (let ((init (if object `(objed--init ',object)
+ '(objed--init 'char))))
`(let ((temp-buffer (generate-new-buffer " *temp*")))
(save-window-excursion
(unwind-protect
@@ -69,7 +78,6 @@ Insert KEY if there's no command."
(transient-mark-mode 1)
;; activate objed
(objed-mode 1)
- (set-transient-map objed-map #'objed--keep-transient-p)
(insert ,in)
(goto-char (point-min))
(when (search-forward "~" nil t)
@@ -78,7 +86,7 @@ Insert KEY if there's no command."
(goto-char (point-max))
(search-backward "|")
(delete-char 1)
- ;; (objed--init 'char)
+ ,init
(setq current-prefix-arg nil)
;; execute command
,@(mapcar (lambda (x)
@@ -89,7 +97,7 @@ Insert KEY if there's no command."
(eq (car x) 'kbd)))
`(objed-unalias ,x))
(t x)))
- body)
+ (list body))
(let ((npos (point-marker)))
(when objed--current-obj
(goto-char (objed--end))
@@ -107,16 +115,10 @@ Insert KEY if there's no command."
(point-min)
(point-max)))
(objed--exit-objed)
+ ;; reset for next round
+ (setq last-command nil)
(and (buffer-name temp-buffer)
- (kill-buffer temp-buffer))))))
-
-(defun objed--call-object-interactively (o &optional cmd)
- (let* ((cmd (or cmd (objed--name2func o)))
- (real-this-command cmd)
- (inhibit-message t))
- (setq this-command cmd)
- (call-interactively cmd)
- (setq last-command cmd)))
+ (kill-buffer temp-buffer)))))))
;; needs to come first initializes, for tests, too
(ert-deftest objed-activate ()
@@ -142,7 +144,7 @@ Insert KEY if there's no command."
>")))
-(ert-deftest objed-basic-movment ()
+(ert-deftest objed-basic-movement ()
(should (string= (objed-with "Testing line he|re" "rr")
"Testing |<line> here"))
(should (string= (objed-with "Testing line he|re" "2r")
@@ -163,7 +165,7 @@ Insert KEY if there's no command."
"<;; this is| the previous line\n>;; this is the current
line"))
(should (string= (objed-with ";; this is a| test\n;; this is the next line"
"n")
";; this is a test\n<;; this is t|he next line>"))
- (should (string= (objed-with "Testing |line here\nFollowing line here"
"npsrfb")
+ (should (string= (objed-with "Testing |line here\nFollowing line here"
"npsrfb")
"Testing |<l>ine here\nFollowing line here"))
(should (string= (objed-with "Testing |line here\nFollowing line here" "e")
"Testing <line here>|\nFollowing line here"))
@@ -173,43 +175,244 @@ Insert KEY if there's no command."
"<Testing line here>|\nFollowing line here")))
-(ert-deftest objed-switch-to-object ()
+(ert-deftest objed-choose-and-navigate-defun ()
(should (string= (objed-with "
-(defun objed--save-start-position (&rest _)
+\(defun objed--save-start-position (&rest _)
\"Save position of point via `objed--opoint'.\"
(setq objed--opoint (point)))
-(defun objed--|goto-start (&optional _)
- \"Goto start of current object if there is one.\"
+\(defun objed--goto-start (&optional _)
+ \"Goto start |of current object if there is one.\"
(when objed--current-obj
(goto-char (objed--beg))))
-(defun objed--object-trailing-line (pos)
+\(defun objed--object-trailing-line (pos)
\"Activate trailing part from POS.\"
(unless (eq objed--obj-state 'inner)
(objed--reverse))
(objed--change-to :beg pos :ibeg pos))"
- "cdd")
+ "cdthh")
"
-(defun objed--save-start-position (&rest _)
+\(defun objed--save-start-position (&rest _)
\"Save position of point via `objed--opoint'.\"
(setq objed--opoint (point)))
-|<
->(defun objed--object-trailing-line (pos)
+
+\(defun objed--goto-start (&optional _)
+ \"Goto start of current object if there is one.\"
+ (when objed--current-obj
+ (goto-char (objed--beg))))
+<
+|(defun objed--object-trailing-line (pos)
\"Activate trailing part from POS.\"
(unless (eq objed--obj-state 'inner)
(objed--reverse))
- (objed--change-to :beg pos :ibeg pos))")))
+ (objed--change-to :beg pos :ibeg pos))>")))
-(ert-deftest objed-delete-op ()
- (should (string= (objed-with "
-(defun |objed--save-start-position (&rest _)
- \"Save position of point via `objed--opoint'.\"
- (setq objed--opoint (point)))"
- "nd")
-"
-(defun objed--save-start-position (&rest _)
-|< (setq objed--opoint (point)))>")))
+(ert-deftest objed-beg-of-block-expansion ()
+
+ (let ((string "
+\(defun check ()
+ (ignore))
+
+;; More on same level
+
+;; Some text
+;; and |more text"))
+ (should (string= (objed-with string "a")
+ "
+\(defun check ()
+ (ignore))
+
+;; More on same level
+
+;; Some text
+|<;; and >more text"))
+ (should (string= (objed-with string "aa")
+ "
+\(defun check ()
+ (ignore))
+
+;; More on same level
+
+|<;; Some text
+;; and >more text"))
+ (should (string= (objed-with string "aaa")
+ "
+\(defun check ()
+ (ignore))
+
+;; More on same level
+|<
+;; Some text
+;; and >more text"))
+ (should (string= (objed-with string "aaaa")
+ "
+\(defun check ()
+ (ignore))
+
+|<;; More on same level
+
+;; Some text
+;; and >more text"))
+ (should (string= (objed-with string "aaaaa")
+ "|<
+\(defun check ()
+ (ignore))
+
+;; More on same level
+
+;; Some text
+;; and >more text"))))
+
+(ert-deftest objed-end-of-block-expansion ()
+ (let ((string "
+;; Some |text
+;; and more text
+;;
+;;
+
+;; Comment end
+
+\(defun check ()
+ (ignore))
+
+;; buffer end"))
+ (should (string= (objed-with string "e")
+ "
+;; Some <text>|
+;; and more text
+;;
+;;
+
+;; Comment end
+
+\(defun check ()
+ (ignore))
+
+;; buffer end"))
+ (should (string= (objed-with string "ee")
+ "
+;; Some <text
+;; and more text>|
+;;
+;;
+
+;; Comment end
+
+\(defun check ()
+ (ignore))
+
+;; buffer end"))
+ (should (string= (objed-with string "eee")
+ "
+;; Some <text
+;; and more text
+;;
+;;>|
+
+;; Comment end
+
+\(defun check ()
+ (ignore))
+
+;; buffer end"))
+ (should (string= (objed-with string "eeee")
+ "
+;; Some <text
+;; and more text
+;;
+;;
+
+;; Comment end>|
+
+\(defun check ()
+ (ignore))
+
+;; buffer end"))
+ (should (string= (objed-with string "eeeee")
+ "
+;; Some <text
+;; and more text
+;;
+;;
+
+;; Comment end
+
+\(defun check ()>|
+ (ignore))
+
+;; buffer end"))
+ (should (string= (objed-with string "eeeeee")
+ "
+;; Some <text
+;; and more text
+;;
+;;
+
+;; Comment end
+
+\(defun check ()
+ (ignore))
+
+;; buffer end>|"))))
+
+
+(ert-deftest objed-block-expansion ()
+ (let ((string "
+\(defun check ()
+ (ignore))
+
+;; More on same level
+
+;; Some text
+;; and |more text"))
+ (should (string= (objed-with string "l")
+ "
+\(defun check ()
+ (ignore))
+
+;; More on same level
+
+;; Some text
+|<;; and more text>"))
+ (should (string= (objed-with string "ll")
+ "
+\(defun check ()
+ (ignore))
+
+;; More on same level
+
+|<;; Some text
+;; and more text>"))
+ (should (string= (objed-with string "lll")
+ "
+\(defun check ()
+ (ignore))
+
+;; More on same level
+|<
+;; Some text
+;; and more text>"))
+ (should (string= (objed-with string "llll")
+ "
+\(defun check ()
+ (ignore))
+
+|<;; More on same level
+
+;; Some text
+;; and more text>"))
+ (should (string= (objed-with string "lllll")
+ "|<
+\(defun check ()
+ (ignore))
+
+;; More on same level
+
+;; Some text
+;; and more text>"))
+))
+;; TODO: context expansion
(provide 'tests)
- [elpa] externals/objed bd6a50c 092/216: Change bindings for surroundings, undo in region, (continued)
- [elpa] externals/objed bd6a50c 092/216: Change bindings for surroundings, undo in region, Stefan Monnier, 2019/01/08
- [elpa] externals/objed aa8ba7b 093/216: Change DEL to behave as normal for char object, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 21ca995 069/216: Cleanup malformed object, Stefan Monnier, 2019/01/08
- [elpa] externals/objed d21fd72 073/216: Fix makup again, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 7c41d13 076/216: Fixup which-key paging commands, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 204ea88 095/216: Change surroundings binding, Stefan Monnier, 2019/01/08
- [elpa] externals/objed b54fa1a 077/216: Add more tests, Stefan Monnier, 2019/01/08
- [elpa] externals/objed deb059e 100/216: Update bindings, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 53cafee 085/216: Add new commands to move to first/last instance, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 919a72d 071/216: Adjust python block object, Stefan Monnier, 2019/01/08
- [elpa] externals/objed b7ded6d 083/216: Improve tests, add more tests,
Stefan Monnier <=
- [elpa] externals/objed e5f8bac 102/216: Improve undo in region, Stefan Monnier, 2019/01/08
- [elpa] externals/objed e5dfba1 096/216: Add extend commands, Stefan Monnier, 2019/01/08
- [elpa] externals/objed d770ddd 055/216: Don't exit after eval op, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 6907e69 058/216: Improve face object, Stefan Monnier, 2019/01/08
- [elpa] externals/objed cac61c3 084/216: Improve block objects, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 58af659 068/216: Start adding tests, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 655a636 090/216: Fix bug, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 838094f 097/216: Working on #14, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 9f4e3cf 062/216: More face object adjustments, Stefan Monnier, 2019/01/08
- [elpa] externals/objed d15d904 089/216: Fix up forward/backward until any object, Stefan Monnier, 2019/01/08