403Webshell
Server IP : 82.208.35.60  /  Your IP : 216.73.217.33
Web Server : Apache/2.4.55 (FreeBSD) OpenSSL/1.1.1q-freebsd PHP/7.3.31
System : FreeBSD server7.d2m.cz 12.4-RELEASE-p9 FreeBSD 12.4-RELEASE-p9 GENERIC amd64
User : studiokobylisy_cz ( 1008)
PHP Version : 7.3.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /usr/ports/textproc/py-docutils/work-py39/docutils-0.17.1/tools/editors/emacs/tests/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/ports/textproc/py-docutils/work-py39/docutils-0.17.1/tools/editors/emacs/tests/helpers.el
;; Tests for helper functions and macros.  -*- lexical-binding: t -*-

(add-to-list 'load-path ".")
(load "init" nil t)
(init-rst-ert t)

(ert-deftest helpers-asserts ()
  "Check some assertions."
  (should (equal ert-Buf-point-char "\^@"))
  (should (equal ert-Buf-mark-char "\^?"))
  )

(ert-deftest rst-destructuring-dolist ()
  "Test `rst-destructuring-dolist'."
  (should (equal nil (rst-destructuring-dolist (i nil)
		       (signal 'error nil))))
  (should (equal t (rst-destructuring-dolist (i nil t)
		     (signal 'error nil))))
  (should (let (res)
	    (rst-destructuring-dolist (e '(1) res)
	      (setq res (not (boundp '--rst-destructuring-dolist-var--))))))
  (should (equal
	   '((4 . 3) (2 . 1))
	   (let (res)
	     (rst-destructuring-dolist ((l &rest r) '((1 . 2) (3 . 4)) res)
	       (push (cons r l) res)))))
  (should (equal
	   '((6 5 4) (3 2 1))
	   (let (res)
	     (rst-destructuring-dolist ((l m r) '((1 2 3) (4 5 6)) res)
	       (push (list r m l) res)))))
  (should (equal
	   '(3 2 1)
	   (let (res)
	     (rst-destructuring-dolist (e '(1 2 3) res)
	       (push e res)))))
  (should (equal
  	   '(30 20 10)
  	   (let (res)
  	     (rst-destructuring-dolist ((e &aux (a 10)) '((1) (2) (3)) res)
  	       (push (* e a) res)
  	       (setq a (+ a a))))))
  (should (equal
  	   '(30 20 10)
  	   (let (res)
  	     (rst-destructuring-dolist ((&rest e &aux (a 10)) '(1 2 3) res)
  	       (push (* e a) res)
  	       (setq a (+ a a))))))
  )

(ert-deftest rst-forward-line-strict ()
  "Test `rst-forward-line-strict'."
  (should (ert-equal-buffer-return
	   '(rst-forward-line-strict 1)
	     "\^@"
	     t
	     nil))
  (should (ert-equal-buffer-return
	   '(rst-forward-line-strict 0)
	     "\^@"
	     t
	     t))
  (should (ert-equal-buffer-return
	   '(rst-forward-line-strict -1)
	     "\^@"
	     t
	     nil))
  (should (ert-equal-buffer-return
	   '(rst-forward-line-strict 1)
	     "abc\^@"
	     t
	     nil))
  (should (ert-equal-buffer-return
	   '(rst-forward-line-strict 0)
	     "abc\^@"
	     "\^@abc"
	     t))
  (should (ert-equal-buffer-return
	   '(rst-forward-line-strict -1)
	     "abc\^@"
	     t
	     nil))
  (should (ert-equal-buffer-return
	   '(rst-forward-line-strict 1)
	     "abc\^@
"
	     "abc
\^@"
	     t))
  (should (ert-equal-buffer-return
	   '(rst-forward-line-strict 2)
	     "abc\^@
"
	     t
	     nil))
  (should (ert-equal-buffer-return
	   '(rst-forward-line-strict 0)
	     "abc\^@
"
	     "\^@abc
"
	     t))
  (should (ert-equal-buffer-return
	   '(rst-forward-line-strict -1)
	     "abc
\^@"
	     "\^@abc
"
	     t))
  (should (ert-equal-buffer-return
	   '(rst-forward-line-strict -2)
	     "abc
\^@"
	     t
	     nil))
  (should (ert-equal-buffer-return
	   '(rst-forward-line-strict 1 1)
	     "\^@"
	     t
	     nil))
  (should (ert-equal-buffer-return
	   '(rst-forward-line-strict 1 2)
	     "\^@"
	     t
	     nil))
  (should (ert-equal-buffer-return
	   '(rst-forward-line-strict 1 4)
	     "\^@abc"
	     "abc\^@"
	     t))
  (should (ert-equal-buffer-return
	   '(rst-forward-line-strict 1 4)
	     "abc\^@"
	     t
	     nil))
  (should (ert-equal-buffer-return
	   '(rst-forward-line-strict 1 3)
	     "\^@abc"
	     "abc\^@"
	     t))
  (should (ert-equal-buffer-return
	   '(rst-forward-line-strict 1 5)
	     "abc\^@
"
	     "abc
\^@"
	     t))
  (should (ert-equal-buffer-return
	   '(rst-forward-line-strict 2 5)
	     "abc\^@
"
	     t
	     nil))
  )

(defun forward-line-looking-at (n &rest rst-res)
  "Call `rst-forward-line-looking-at'. If match is returned
return t if `(match-beginning 0)' satisfies `(bolp)'
and `(match-end 0)' matches mark."
  (rst-forward-line-looking-at
   n rst-res
   #'(lambda (mtcd)
       (when mtcd
	 (and (bolp)
	      (= (match-end 0) (mark)))))))

(ert-deftest rst-forward-line-looking-at ()
  "Test `rst-forward-line-looking-at'."
  (should (ert-equal-buffer-return
	   '(forward-line-looking-at 0)
	   "\^@\^?"
	   t
	   t))
  (should (ert-equal-buffer-return
	   '(forward-line-looking-at 1)
	   "\^@\^?"
	   t
	   nil))
  (should (ert-equal-buffer-return
	   '(forward-line-looking-at 1)
	   "\^@
\^?"
	   t
	   t))
  (should (ert-equal-buffer-return
	   '(forward-line-looking-at 1)
	   "\^@
  .. \^?"
	   t
	   nil))
  (should (ert-equal-buffer-return
	   '(forward-line-looking-at 1 'exm-sta)
	   "\^@
  .. \^?
"
	   t
	   nil))
  (should (ert-equal-buffer-return
	   '(forward-line-looking-at 1 'exm-beg)
	   "\^@
  .. \^?
"
	   t
	   t))
  )

(ert-deftest rst-delete-entire-line ()
  "Test `rst-delete-entire-line'."
  (should (ert-equal-buffer
	   '(rst-delete-entire-line 0)
	   "\^@"
	   t))
  (should (ert-equal-buffer
	   '(rst-delete-entire-line 0)
	   " \^@"
	   "\^@"))
  (should (ert-equal-buffer
	   '(rst-delete-entire-line 1)
	   "\^@
abc
"
	   "\^@
"))
  (should (ert-equal-buffer
	   '(rst-delete-entire-line 2)
	   "\^@
abc
"
	   t))
  (should (ert-equal-buffer
	   '(rst-delete-entire-line 3)
	   "\^@
abc
"
	   t))
  (should (ert-equal-buffer
	   '(rst-delete-entire-line 0)
	   "
\^@abc
"
	   "
\^@"))
  (should (ert-equal-buffer
	   '(rst-delete-entire-line -1)
	   "
abc
\^@"
	   "
\^@"))
  )

Youez - 2016 - github.com/yon3zu
LinuXploit