annotate tests/automated/completion-tests.el @ 5940:c608d4b0b75e cygwin64 tip

rescue lost branch from 64bit.backup
author Henry Thompson <ht@markup.co.uk>
date Thu, 16 Dec 2021 18:48:58 +0000
parents 2014ff433daf
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5634
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
1 ;; Copyright (C) 2012 Free Software Foundation, Inc.
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
2
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
3 ;; Author: Aidan Kehoe <kehoea@parhasard.net>
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
4 ;; Maintainers: Aidan Kehoe <kehoea@parhasard.net>
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
5 ;; Created: 2012
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
6 ;; Keywords: tests
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
7
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
8 ;; This file is part of XEmacs.
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
9
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
10 ;; XEmacs is free software: you can redistribute it and/or modify it
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by the
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
12 ;; Free Software Foundation, either version 3 of the License, or (at your
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
13 ;; option) any later version.
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
14
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
16 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
17 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
18 ;; for more details.
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
19
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
21 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>.
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
22
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
23 ;;; Synched up with: Not in FSF.
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
24
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
25 ;; This file tests pseudo-alist, obarray and hash-table arguments to
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
26 ;; #'try-completion, #'all-completions and #'test-completion. It doesn't
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
27 ;; test function arguments as COLLECTION.
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
28
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
29 (require 'cl)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
30
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
31 (or (featurep 'xemacs)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
32 (defmacro Assert (assertion &optional failing-case)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
33 ;; This file can actually execute on GNU, though it exposes some bugs
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
34 ;; as of So 1 Jan 2012 14:41:32 GMT, described in
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
35 ;; http://mid.gmane.org/20224.27302.821804.284656@parhasard.net .
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
36 `(condition-case err
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
37 (assert ,assertion nil
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
38 ,@(if (memq (car-safe assertion)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
39 '(eq eql equal equalp = string= < <= > >=))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
40 (list
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
41 (concat (if failing-case
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
42 (concat failing-case ", ")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
43 "")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
44 "%S should be `"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
45 (symbol-name (car assertion))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
46 "' to %S but isn't")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
47 (cadr assertion)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
48 (caddr assertion))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
49 (list failing-case)))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
50 (error
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
51 (message "error executing %S, %S, %S" ',assertion ,failing-case
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
52 err)))))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
53
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
54 (let* ((strings '("del-alist" "delay-mode-hooks" "delete" "delete*"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
55 "delete-and-extract-region" "delete-annotation"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
56 "delete-auto-save-file-if-necessary" "delete-backward-char"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
57 "delete-blank-lines" "delete-char"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
58 "delete-completion-window" "delete-console"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
59 "delete-debug-class-to-check" "delete-device"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
60 "delete-directory" "delete-duplicates" "delete-dups"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
61 "delete-extent" "delete-extract-rectangle" "delete-field"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
62 "delete-file" "delete-forward-p" "delete-frame"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
63 "delete-horizontal-space" "delete-if" "delete-if-not"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
64 "delete-indentation" "delete-itimer" "delete-matching-lines"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
65 "delete-menu-item" "delete-non-matching-lines"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
66 "delete-other-frames" "delete-other-windows"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
67 "delete-overlay" "delete-primary-selection" "delete-process"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
68 "delete-rectangle" "delete-region" "delete-selection-mode"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
69 "delete-text-in-column" "delete-to-left-margin"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
70 "delete-window" "delete-windows-on" "delq" "remote-compile"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
71 "remote-path-file-handler-function" "remove" "remove*"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
72 "remove-alist" "remove-char-table" "remove-database"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
73 "remove-directory" "remove-duplicates"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
74 "remove-face-property" "remove-from-invisibility-spec"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
75 "remove-glyph-property" "remove-gutter-element"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
76 "remove-hook" "remove-if" "remove-if-not"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
77 "remove-local-hook" "remove-message"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
78 "remove-progress-feedback" "remove-range-table"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
79 "remove-specifier"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
80 "remove-specifier-specs-matching-tag-set-cdrs"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
81 "remove-text-properties" "sublis"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
82 "submenu-generate-accelerator-spec" "subr-arity"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
83 "subr-interactive" "subr-max-args" "subr-min-args"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
84 "subr-name" "subregexp-context-p" "subrp" "subseq" "subsetp"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
85 "subsidiary-coding-system" "subst" "subst-char-in-region"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
86 "subst-char-in-string" "subst-if" "subst-if-not"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
87 "substitute" "substitute-command-keys" "substitute-env-vars"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
88 "substitute-if" "substitute-if-not"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
89 "substitute-in-file-name" "substitute-key-definition"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
90 "substring" "substring-no-properties" "subtract-time"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
91 "subwindow-height" "subwindow-image-instance-p"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
92 "subwindow-width" "subwindow-xid" "subwindowp"))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
93 (list (let ((count -1))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
94 (mapcar #'(lambda (string)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
95 (incf count)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
96 (case (% count 3)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
97 (0 string)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
98 (1 (cons (make-symbol string) nil))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
99 (2 (cons string (make-symbol string))))) strings)))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
100 (vector (loop
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
101 for string in strings
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
102 with vector = (make-vector 511 0)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
103 with count = -1
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
104 with symbol = nil
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
105 do
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
106 (setq symbol (intern string vector)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
107 count (1+ count))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
108 (case (% count 3)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
109 (0 (set symbol nil))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
110 (1 (fset symbol (symbol-function 'ignore)))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
111 (2 (setf (symbol-plist symbol) 'hello)))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
112 finally return vector))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
113 (init-hash-table
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
114 #'(lambda ()
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
115 (loop
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
116 for string in strings
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
117 with hash-table = (make-hash-table :test #'equal)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
118 with count = -1
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
119 do
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
120 (incf count)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
121 (case (% count 3)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
122 (0 (setf (gethash (make-symbol string) hash-table)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
123 'hello))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
124 (1 (setf (gethash string hash-table) 'everyone))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
125 (2 (setf (gethash string hash-table) nil)))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
126 finally return hash-table)))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
127 (hash-table (funcall init-hash-table))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
128 ;; The following three could be circular lists, but that's not
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
129 ;; portable to GNU.
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
130 (list-list (make-list (length strings) list))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
131 (vector-list (make-list (length strings) vector))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
132 (hash-table-list (make-list (length strings) hash-table))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
133 scratch-hash-table cleared)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
134 (macrolet
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
135 ((Assert-with-collections (assertion failing-case)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
136 `(progn
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
137 (Assert ,(subst 'list 'collection assertion :test #'eq)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
138 ,(replace-regexp-in-string "collection" "list" failing-case))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
139 (Assert ,(subst 'vector 'collection assertion :test #'eq)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
140 ,(replace-regexp-in-string "collection" "vector"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
141 failing-case))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
142 (Assert ,(subst 'hash-table 'collection assertion :test #'eq)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
143 ,(replace-regexp-in-string "collection" "hash-table"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
144 failing-case)))))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
145 ;; #'try-completion.
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
146 (Assert (every #'try-completion strings list-list)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
147 "check #'try-completion gives no false negatives, list")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
148 (Assert (every #'try-completion strings vector-list)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
149 "check #'try-completion gives no false negatives, vector")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
150 (Assert (every #'try-completion strings hash-table-list)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
151 "check #'try-completion gives no false negatives, hash-table")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
152 (Assert-with-collections
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
153 (null (try-completion "iX/ZXLwiOU+a " collection))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
154 "check #'try-completion with no match, collection")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
155 (Assert-with-collections
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
156 (eq t (try-completion "delq" collection))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
157 "check #'try-completion with an exact match, collection")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
158 (Assert-with-collections
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
159 (equal "delq"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
160 (let ((completion-ignore-case t))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
161 (try-completion "DElq" collection)))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
162 "check #'try-completion with a case-insensitive match, collection")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
163 (Assert-with-collections
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
164 (equal "del" (try-completion "de" collection))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
165 "check #'try-completion where it needs to complete, collection")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
166 (Assert (equal "del" (try-completion "de" list #'consp))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
167 "check #'try-completion, list, it needs to complete, predicate")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
168 (Assert
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
169 (equal "del" (try-completion "de" vector #'fboundp))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
170 "check #'try-completion, vector, it needs to complete, predicate")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
171 (Assert
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
172 (equal "del" (try-completion "de" hash-table #'(lambda (key value)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
173 (eq 'everyone value))))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
174 "check #'try-completion, hash-table, it needs to complete, predicate")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
175 (Assert
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
176 ;; The actual result here is undefined, the important thing is we don't
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
177 ;; segfault.
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
178 (prog1
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
179 t
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
180 (try-completion "de"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
181 (setq cleared nil
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
182 scratch-hash-table (funcall init-hash-table))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
183 #'(lambda (key value)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
184 (if cleared
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
185 (eq 'everyone value)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
186 (clrhash scratch-hash-table)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
187 (garbage-collect)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
188 (setq cleared t)))))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
189 "check #'try-completion doesn't crash when hash table modified")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
190
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
191 ;; #'all-completions
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
192 (Assert (every #'all-completions strings list-list)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
193 "check #'all-completions gives no false negatives, list")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
194 (Assert (every #'all-completions strings vector-list)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
195 "check #'all-completions gives no false negatives, vector")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
196 (Assert (every #'all-completions strings hash-table-list)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
197 "check #'all-completions gives no false negatives, hash-table")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
198 (Assert-with-collections
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
199 (null (all-completions "iX/ZXLwiOU+a " collection))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
200 "check #'all-completion with no match, collection")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
201 (Assert-with-collections
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
202 (equal '("delq") (all-completions "delq" collection))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
203 "check #'all-completions with an exact match, collection")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
204 (Assert-with-collections
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
205 (equal '("delq") (let ((completion-ignore-case t))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
206 (all-completions "dElQ" collection)))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
207 "check #'all-completions with a case-insensitive match, collection")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
208 (Assert
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
209 (equal
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
210 '("delay-mode-hooks" "delete-and-extract-region"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
211 "delete-backward-char" "delete-completion-window" "delete-device"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
212 "delete-dups" "delete-field" "delete-frame" "delete-if-not"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
213 "delete-matching-lines" "delete-other-frames"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
214 "delete-primary-selection" "delete-region" "delete-to-left-margin"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
215 "delq")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
216 (sort (all-completions "de" vector #'fboundp) #'string-lessp))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
217 "check #'all-completions where it need to complete, vector")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
218 (Assert
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
219 (eql (length (all-completions "de" hash-table #'(lambda (key value)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
220 (eq 'everyone value))))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
221 15)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
222 "check #'all-completions gives enough results with predicate, hash")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
223 (Assert
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
224 (equal (sort
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
225 (all-completions
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
226 "de" list #'(lambda (object) (and (consp object)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
227 (null (cdr object)))))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
228 #'string-lessp)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
229 (sort
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
230 (all-completions
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
231 "de" hash-table #'(lambda (key value)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
232 (eq 'everyone value)))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
233 #'string-lessp))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
234 "check #'all-completion with complex predicates behaves well")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
235 (Assert-with-collections
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
236 (equal (sort* (all-completions "" collection) #'string-lessp) strings)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
237 "check #'all-completions, empty string, with collection")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
238 (Assert
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
239 ;; The actual result here is undefined, the important thing is we don't
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
240 ;; segfault.
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
241 (prog1
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
242 t
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
243 (all-completions "de"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
244 (setq cleared nil
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
245 scratch-hash-table (funcall init-hash-table))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
246 #'(lambda (key value)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
247 (if cleared
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
248 (eq 'everyone value)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
249 (clrhash scratch-hash-table)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
250 (garbage-collect)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
251 (setq cleared t)))))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
252 "check #'all-completions doesn't crash when hash table modified")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
253 ;; #'test-completion
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
254 (Assert (every #'test-completion strings list-list)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
255 "check #'test-completion gives no false negatives, list")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
256 (Assert (every #'test-completion strings vector-list)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
257 "check #'test-completion gives no false negatives, vector")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
258 (Assert (every #'test-completion strings hash-table-list)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
259 "check #'test-completion gives no false negatives, hash-table")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
260 (Assert-with-collections
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
261 (null (test-completion "iX/ZXLwiOU+a " collection))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
262 "check #'test-completion with no match, collection")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
263 (Assert-with-collections
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
264 (eq t (test-completion "delq" collection))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
265 "check #'test-completion with an exact match, collection")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
266 (Assert-with-collections
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
267 (null (let (completion-ignore-case) (test-completion "DElq" collection)))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
268 "check #'test-completion fails correctly if case-sensitive, collection")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
269 (Assert-with-collections
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
270 (eq t (let ((completion-ignore-case t))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
271 (test-completion "DElq" collection)))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
272 "check #'test-completion with a case-insensitive match, collection")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
273 (Assert-with-collections
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
274 (null (test-completion "de" collection))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
275 "check #'test-completion gives nil if no exact match, collection")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
276 (Assert (null (test-completion "de" list #'consp))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
277 "check #'test-completion, list, no exact match, predicate")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
278 (Assert (eq t (test-completion "delete-matching-lines" list #'consp))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
279 "check #'test-completion, list, exact match, predicate")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
280 (Assert (null (test-completion "de" vector #'fboundp))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
281 "check #'test-completion, vector, no exact match, predicate")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
282 (Assert (eq t (test-completion "delete-to-left-margin" vector #'fboundp))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
283 "check #'test-completion, vector, exact match, predicate")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
284 (Assert
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
285 (null (test-completion "de" hash-table #'(lambda (key value)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
286 (eq 'everyone value))))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
287 "check #'test-completion, hash-table, it needs to complete, predicate")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
288 (Assert
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
289 (eq t (test-completion "delete-frame" hash-table
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
290 #'(lambda (key value) (eq 'everyone value))))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
291 "check #'test-completion, hash-table, exact match, predicate")
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
292 (Assert
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
293 ;; The actual result here is undefined, the important thing is we don't
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
294 ;; segfault.
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
295 (prog1
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
296 t
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
297 (test-completion "delete-frame"
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
298 (setq cleared nil
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
299 scratch-hash-table (funcall init-hash-table))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
300 #'(lambda (key value)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
301 (if cleared
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
302 (eq 'everyone value)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
303 (clrhash scratch-hash-table)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
304 (garbage-collect)
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
305 (setq cleared t)))))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
306 "check #'all-completions doesn't crash when hash table modified")))
2014ff433daf Support hash COLLECTIONs, #'{all,try}-completion{s,}; add #'test-completion
Aidan Kehoe <kehoea@parhasard.net>
parents:
diff changeset
307