1 ;;; transformers-tests.el --- company-mode tests -*- lexical-binding: t -*-
3 ;; Copyright (C) 2015 Free Software Foundation, Inc.
5 ;; Author: Dmitry Gutov
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
22 (require 'company-tests)
24 (ert-deftest company-occurrence-prefer-closest-above ()
26 (save-window-excursion
27 (set-window-buffer nil (current-buffer))
35 (let ((company-backend 'company-dabbrev)
36 (company-occurrence-weight-function
37 'company-occurrence-prefer-closest-above))
38 (should (equal '("foo1" "foo0" "foo3" "foo2" "foo4")
39 (company-sort-by-occurrence
40 '("foo0" "foo1" "foo2" "foo3" "foo4"))))))))
42 (ert-deftest company-occurrence-prefer-any-closest ()
44 (save-window-excursion
45 (set-window-buffer nil (current-buffer))
53 (let ((company-backend 'company-dabbrev)
54 (company-occurrence-weight-function
55 'company-occurrence-prefer-any-closest))
56 (should (equal '("foo1" "foo3" "foo0" "foo2" "foo4")
57 (company-sort-by-occurrence
58 '("foo0" "foo1" "foo2" "foo3" "foo4"))))))))