diff options
| -rw-r--r-- | test/lisp/erc/erc-tests.el | 161 | ||||
| -rw-r--r-- | test/lisp/erc/resources/erc-d/erc-d-tests.el | 2 |
2 files changed, 82 insertions, 81 deletions
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index 5c1a34bc3fa..6d0172e98fc 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el | |||
| @@ -987,87 +987,88 @@ | |||
| 987 | (setq erc-channel-users (make-hash-table :test #'equal) | 987 | (setq erc-channel-users (make-hash-table :test #'equal) |
| 988 | erc--target (erc--target-from-string "#test")) | 988 | erc--target (erc--target-from-string "#test")) |
| 989 | 989 | ||
| 990 | (let ((orig-handle-fn (symbol-function 'erc--handle-channel-mode)) | 990 | (cl-letf ((calls ()) |
| 991 | calls) | 991 | ((symbol-function 'erc-update-mode-line) #'ignore)) |
| 992 | (cl-letf (((symbol-function 'erc--handle-channel-mode) | 992 | (advice-add 'erc--handle-channel-mode |
| 993 | (lambda (&rest r) (push r calls) (apply orig-handle-fn r))) | 993 | :before (lambda (&rest r) (push r calls)) |
| 994 | ((symbol-function 'erc-update-mode-line) #'ignore)) | 994 | '((name . erc-tests-spy))) |
| 995 | 995 | ||
| 996 | (ert-info ("Unknown user not created") | 996 | (ert-info ("Unknown user not created") |
| 997 | (erc--update-channel-modes "+o" "bob") | 997 | (erc--update-channel-modes "+o" "bob") |
| 998 | (should-not (erc-get-channel-user "bob"))) | 998 | (should-not (erc-get-channel-user "bob"))) |
| 999 | 999 | ||
| 1000 | (ert-info ("Status updated when user known") | 1000 | (ert-info ("Status updated when user known") |
| 1001 | (puthash "bob" (cons (erc-add-server-user | 1001 | (puthash "bob" (cons (erc-add-server-user |
| 1002 | "bob" (make-erc-server-user | 1002 | "bob" (make-erc-server-user |
| 1003 | :nickname "bob" | 1003 | :nickname "bob" |
| 1004 | :buffers (list (current-buffer)))) | 1004 | :buffers (list (current-buffer)))) |
| 1005 | (make-erc-channel-user)) | 1005 | (make-erc-channel-user)) |
| 1006 | erc-channel-users) | 1006 | erc-channel-users) |
| 1007 | ;; Also asserts fallback behavior for traditional prefixes. | 1007 | ;; Also asserts fallback behavior for traditional prefixes. |
| 1008 | (should-not (erc-channel-user-op-p "bob")) | 1008 | (should-not (erc-channel-user-op-p "bob")) |
| 1009 | (erc--update-channel-modes "+o" "bob") | 1009 | (erc--update-channel-modes "+o" "bob") |
| 1010 | (should (erc-channel-user-op-p "bob")) | 1010 | (should (erc-channel-user-op-p "bob")) |
| 1011 | (erc--update-channel-modes "-o" "bob") ; status revoked | 1011 | (erc--update-channel-modes "-o" "bob") ; status revoked |
| 1012 | (should-not (erc-channel-user-op-p "bob"))) | 1012 | (should-not (erc-channel-user-op-p "bob"))) |
| 1013 | 1013 | ||
| 1014 | (ert-info ("Unknown nullary added and removed") | 1014 | (ert-info ("Unknown nullary added and removed") |
| 1015 | (should-not erc--channel-modes) | 1015 | (should-not erc--channel-modes) |
| 1016 | (should-not erc-channel-modes) | 1016 | (should-not erc-channel-modes) |
| 1017 | (erc--update-channel-modes "+u") | 1017 | (erc--update-channel-modes "+u") |
| 1018 | (should (equal erc-channel-modes '("u"))) | 1018 | (should (equal erc-channel-modes '("u"))) |
| 1019 | (should (eq t (gethash ?u erc--channel-modes))) | 1019 | (should (eq t (gethash ?u erc--channel-modes))) |
| 1020 | (should (equal (pop calls) '(?d ?u t nil))) | 1020 | (should (equal (pop calls) '(?d ?u t nil))) |
| 1021 | (erc--update-channel-modes "-u") | 1021 | (erc--update-channel-modes "-u") |
| 1022 | (should (equal (pop calls) '(?d ?u nil nil))) | 1022 | (should (equal (pop calls) '(?d ?u nil nil))) |
| 1023 | (should-not (gethash ?u erc--channel-modes)) | 1023 | (should-not (gethash ?u erc--channel-modes)) |
| 1024 | (should-not erc-channel-modes) | 1024 | (should-not erc-channel-modes) |
| 1025 | (should-not calls)) | 1025 | (should-not calls)) |
| 1026 | |||
| 1027 | (ert-info ("Fallback for Type B includes mode letter k") | ||
| 1028 | (erc--update-channel-modes "+k" "h2") | ||
| 1029 | (should (equal (pop calls) '(?b ?k t "h2"))) | ||
| 1030 | (should-not erc-channel-modes) | ||
| 1031 | (should (equal "h2" (gethash ?k erc--channel-modes))) | ||
| 1032 | (erc--update-channel-modes "-k" "*") | ||
| 1033 | (should (equal (pop calls) '(?b ?k nil "*"))) | ||
| 1034 | (should-not calls) | ||
| 1035 | (should-not (gethash ?k erc--channel-modes)) | ||
| 1036 | (should-not erc-channel-modes)) | ||
| 1037 | |||
| 1038 | (ert-info ("Fallback for Type C includes mode letter l") | ||
| 1039 | (erc--update-channel-modes "+l" "3") | ||
| 1040 | (should (equal (pop calls) '(?c ?l t "3"))) | ||
| 1041 | (should-not erc-channel-modes) | ||
| 1042 | (should (equal "3" (gethash ?l erc--channel-modes))) | ||
| 1043 | (erc--update-channel-modes "-l" nil) | ||
| 1044 | (should (equal (pop calls) '(?c ?l nil nil))) | ||
| 1045 | (should-not (gethash ?l erc--channel-modes)) | ||
| 1046 | (should-not erc-channel-modes)) | ||
| 1047 | |||
| 1048 | (ert-info ("Advertised supersedes heuristics") | ||
| 1049 | (setq erc-server-parameters | ||
| 1050 | '(("PREFIX" . "(ov)@+") | ||
| 1051 | ;; Add phony 5th type for this CHANMODES value for | ||
| 1052 | ;; robustness in case some server gets creative. | ||
| 1053 | ("CHANMODES" . "eIbq,k,flj,CFLMPQRSTcgimnprstuz,FAKE"))) | ||
| 1054 | (erc--update-channel-modes "+qu" "fool!*@*") | ||
| 1055 | (should (equal (pop calls) '(?d ?u t nil))) | ||
| 1056 | (should (equal (pop calls) '(?a ?q t "fool!*@*"))) | ||
| 1057 | (should (equal 1 (gethash ?q erc--channel-modes))) | ||
| 1058 | (should (eq t (gethash ?u erc--channel-modes))) | ||
| 1059 | (should (equal erc-channel-modes '("u"))) | ||
| 1060 | (should-not (erc-channel-user-owner-p "bob")) | ||
| 1061 | |||
| 1062 | ;; Remove fool!*@* from list mode "q". | ||
| 1063 | (erc--update-channel-modes "-uq" "fool!*@*") | ||
| 1064 | (should (equal (pop calls) '(?a ?q nil "fool!*@*"))) | ||
| 1065 | (should (equal (pop calls) '(?d ?u nil nil))) | ||
| 1066 | (should-not (gethash ?u erc--channel-modes)) | ||
| 1067 | (should-not erc-channel-modes) | ||
| 1068 | (should (equal 0 (gethash ?q erc--channel-modes)))) | ||
| 1026 | 1069 | ||
| 1027 | (ert-info ("Fallback for Type B includes mode letter k") | 1070 | (should-not calls) |
| 1028 | (erc--update-channel-modes "+k" "h2") | 1071 | (advice-remove 'erc--handle-channel-mode 'erc-tests-spy))) |
| 1029 | (should (equal (pop calls) '(?b ?k t "h2"))) | ||
| 1030 | (should-not erc-channel-modes) | ||
| 1031 | (should (equal "h2" (gethash ?k erc--channel-modes))) | ||
| 1032 | (erc--update-channel-modes "-k" "*") | ||
| 1033 | (should (equal (pop calls) '(?b ?k nil "*"))) | ||
| 1034 | (should-not calls) | ||
| 1035 | (should-not (gethash ?k erc--channel-modes)) | ||
| 1036 | (should-not erc-channel-modes)) | ||
| 1037 | |||
| 1038 | (ert-info ("Fallback for Type C includes mode letter l") | ||
| 1039 | (erc--update-channel-modes "+l" "3") | ||
| 1040 | (should (equal (pop calls) '(?c ?l t "3"))) | ||
| 1041 | (should-not erc-channel-modes) | ||
| 1042 | (should (equal "3" (gethash ?l erc--channel-modes))) | ||
| 1043 | (erc--update-channel-modes "-l" nil) | ||
| 1044 | (should (equal (pop calls) '(?c ?l nil nil))) | ||
| 1045 | (should-not (gethash ?l erc--channel-modes)) | ||
| 1046 | (should-not erc-channel-modes)) | ||
| 1047 | |||
| 1048 | (ert-info ("Advertised supersedes heuristics") | ||
| 1049 | (setq erc-server-parameters | ||
| 1050 | '(("PREFIX" . "(ov)@+") | ||
| 1051 | ;; Add phony 5th type for this CHANMODES value for | ||
| 1052 | ;; robustness in case some server gets creative. | ||
| 1053 | ("CHANMODES" . "eIbq,k,flj,CFLMPQRSTcgimnprstuz,FAKE"))) | ||
| 1054 | (erc--update-channel-modes "+qu" "fool!*@*") | ||
| 1055 | (should (equal (pop calls) '(?d ?u t nil))) | ||
| 1056 | (should (equal (pop calls) '(?a ?q t "fool!*@*"))) | ||
| 1057 | (should (equal 1 (gethash ?q erc--channel-modes))) | ||
| 1058 | (should (eq t (gethash ?u erc--channel-modes))) | ||
| 1059 | (should (equal erc-channel-modes '("u"))) | ||
| 1060 | (should-not (erc-channel-user-owner-p "bob")) | ||
| 1061 | |||
| 1062 | ;; Remove fool!*@* from list mode "q". | ||
| 1063 | (erc--update-channel-modes "-uq" "fool!*@*") | ||
| 1064 | (should (equal (pop calls) '(?a ?q nil "fool!*@*"))) | ||
| 1065 | (should (equal (pop calls) '(?d ?u nil nil))) | ||
| 1066 | (should-not (gethash ?u erc--channel-modes)) | ||
| 1067 | (should-not erc-channel-modes) | ||
| 1068 | (should (equal 0 (gethash ?q erc--channel-modes)))) | ||
| 1069 | |||
| 1070 | (should-not calls)))) | ||
| 1071 | 1072 | ||
| 1072 | (ert-deftest erc--channel-modes () | 1073 | (ert-deftest erc--channel-modes () |
| 1073 | ;; Only mark :unstable when running locally. | 1074 | ;; Only mark :unstable when running locally. |
diff --git a/test/lisp/erc/resources/erc-d/erc-d-tests.el b/test/lisp/erc/resources/erc-d/erc-d-tests.el index f78ad80c43b..b161ea17305 100644 --- a/test/lisp/erc/resources/erc-d/erc-d-tests.el +++ b/test/lisp/erc/resources/erc-d/erc-d-tests.el | |||
| @@ -1221,7 +1221,7 @@ DIALOGS are symbols representing the base names of dialog files in | |||
| 1221 | (proc (apply #'start-process args))) | 1221 | (proc (apply #'start-process args))) |
| 1222 | (set-process-query-on-exit-flag proc nil) | 1222 | (set-process-query-on-exit-flag proc nil) |
| 1223 | (with-current-buffer buffer | 1223 | (with-current-buffer buffer |
| 1224 | (erc-d-t-search-for 5 "Starting") | 1224 | (erc-d-t-search-for 10 "Starting") |
| 1225 | (search-forward " (") | 1225 | (search-forward " (") |
| 1226 | (backward-char)) | 1226 | (backward-char)) |
| 1227 | (let ((pair (read buffer))) | 1227 | (let ((pair (read buffer))) |