summaryrefslogtreecommitdiff
path: root/test/lisp/erc
diff options
context:
space:
mode:
authorVivek Dasmohapatra <vivek@etla.org>2016-04-07 14:23:18 +0200
committerLars Magne Ingebrigtsen <larsi@gnus.org>2016-04-07 14:23:18 +0200
commitbadf7369a63e03a5f4f3817be10763611a6aa8a2 (patch)
tree0f7c996dd1863bb9aff9aecd5e620f009d8150dc /test/lisp/erc
parent1f6b0bc1512de08fd542df0234476788038c8c82 (diff)
downloademacs-badf7369a63e03a5f4f3817be10763611a6aa8a2.tar.gz
Prefer 'font-lock-face to 'face in erc where appropriate
* lisp/erc/erc-button.el (erc-button-add-face): Prefer 'font-lock-face to 'face where appropriate. * lisp/erc/erc-capab.el (erc-capab-identify-add-prefix) * lisp/erc/erc-dcc.el (erc-dcc-chat-parse-output) * lisp/erc/erc-goodies.el (erc-controls-propertize) * lisp/erc/erc-stamp.el (erc-format-timestamp) * lisp/erc/erc-track.el (erc-faces-in) * lisp/erc/erc.el (erc-load-irc-script-lines, erc-display-msg) (erc-display-command, erc-make-notice, erc-highlight-notice) (erc-format-my-nick, erc-format-@nick, erc-format-privmessage) (erc-display-prompt, erc-display-message-highlight) (erc-log-irc-protocol): Ditto. * test/lisp/erc/erc-track-tests.el: Converted asserts into ert tests.
Diffstat (limited to 'test/lisp/erc')
-rw-r--r--test/lisp/erc/erc-track-tests.el118
1 files changed, 118 insertions, 0 deletions
diff --git a/test/lisp/erc/erc-track-tests.el b/test/lisp/erc/erc-track-tests.el
new file mode 100644
index 00000000000..8e39e1b9887
--- /dev/null
+++ b/test/lisp/erc/erc-track-tests.el
@@ -0,0 +1,118 @@
+;;; erc-track-tests.el --- Tests for erc-track.
+
+;; Copyright © 2016 Free Software Foundation, Inc.
+
+;; Author: Mario Lang <mlang@delysid.org>
+;; Author: Vivek Das Mohapatra <vivek@etla.org>
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Code:
+
+(require 'ert)
+(require 'erc-track)
+
+(ert-deftest erc-track--shorten-aggressive-nil ()
+ "Test non-aggressive erc track buffer name shortening."
+ (let (erc-track-shorten-aggressively)
+ (should
+ (equal (erc-unique-channel-names '("#emacs" "#vi" "#electronica" "#folk")
+ '("#emacs" "#vi"))
+ '("#em" "#vi")))
+ (should
+ (equal (erc-unique-channel-names '("#linux-de" "#linux-fr")
+ '("#linux-de" "#linux-fr"))
+ '("#linux-de" "#linux-fr")))
+ (should
+ (equal (erc-unique-channel-names
+ '("#dunnet" "#lisp" "#sawfish" "#fsf" "#guile" "#testgnome"
+ "#gnu" "#fsbot" "#hurd" "#hurd-bunny" "#emacs")
+ '("#hurd-bunny" "#hurd" "#sawfish" "#lisp"))
+ '("#hurd-" "#hurd" "#s" "#l")))
+ (should
+ (equal (erc-unique-substrings '("#emacs" "#vi" "#electronica" "#folk"))
+ '("#em" "#vi" "#el" "#f")))
+ (should
+ (equal (erc-unique-channel-names
+ '("#emacs" "#burse" "+linux.de" "#starwars"
+ "#bitlbee" "+burse" "#ratpoison")
+ '("+linux.de" "#starwars" "#burse"))
+ '("+l" "#s" "#bu")))
+ (should
+ (equal (erc-unique-channel-names '("fsbot" "#emacs" "deego") '("fsbot"))
+ '("fs")))
+ (should
+ (equal (erc-unique-channel-names '("fsbot" "#emacs" "deego")
+ '("fsbot")
+ (lambda (s) (> (length s) 4)) 1)
+ '("f")))
+ (should
+ (equal (erc-unique-channel-names '("fsbot" "#emacs" "deego")
+ '("fsbot")
+ (lambda (s) (> (length s) 4)) 2)
+ '("fs")))
+ (should
+ (equal (erc-unique-channel-names '("deego" "#hurd" "#hurd-bunny" "#emacs")
+ '("#hurd" "#hurd-bunny"))
+ '("#hurd" "#hurd-")))
+ (should
+ (and
+ (equal (erc-unique-substring-1 "abc" '("ab" "abcd")) "abcd")
+ (not (erc-unique-substring-1 "a" '("xyz" "xab")))
+ (equal (erc-unique-substrings '("abc" "xyz" "xab")) '("abc" "xyz" "xab"))
+ (equal (erc-unique-substrings '("abc" "abcdefg")) '("abc" "abcd")))) ))
+
+(ert-deftest erc-track--shorten-aggressive-t ()
+ "Test aggressive erc track buffer name shortening."
+ (let ((erc-track-shorten-aggressively t))
+ (should
+ (equal (erc-unique-channel-names '("#emacs" "#vi" "#electronica" "#folk")
+ '("#emacs" "#vi"))
+ '("#em" "#v")))
+ (should
+ (equal (erc-unique-channel-names '("#linux-de" "#linux-fr")
+ '("#linux-de" "#linux-fr"))
+ '("#linux-d" "#linux-f")))
+ (should
+ (equal (erc-unique-substrings '("#emacs" "#vi" "#electronica" "#folk"))
+ '("#em" "#v" "#el" "#f")))
+ (should
+ (and
+ (equal (erc-unique-substring-1 "abc" '("ab" "abcd")) "abcd")
+ (not (erc-unique-substring-1 "a" '("xyz" "xab")))
+ (equal (erc-unique-substrings '("abc" "xyz" "xab")) '("ab" "xy" "xa"))
+ (equal (erc-unique-substrings '("abc" "abcdefg")) '("abc" "abcd")))) ))
+
+(ert-deftest erc-track--shorten-aggressive-max ()
+ "Test maximally aggressive erc track buffer name shortening."
+ (let ((erc-track-shorten-aggressively 'max))
+ (should
+ (equal (erc-unique-channel-names '("#emacs" "#vi" "#electronica" "#folk")
+ '("#emacs" "#vi"))
+ '("#e" "#v"))) ))
+
+(ert-deftest erc-track--erc-faces-in ()
+ "`erc-faces-in' should pick up both 'face and 'font-lock-face properties."
+ (let ((str0 "is bold")
+ (str1 "is bold")
+ ;;(char-property-alias-alist '((face font-lock-face)))
+ )
+ (put-text-property 3 (length str0) 'font-lock-face
+ '(bold erc-current-nick-face) str0)
+ (put-text-property 3 (length str1) 'face
+ '(bold erc-current-nick-face) str1)
+ (should (erc-faces-in str0))
+ (should (erc-faces-in str1)) ))