|
| 1 | +;;; haskell-completions-tests.el --- Tests for Haskell Completion package |
| 2 | + |
| 3 | +;; Copyright © 2015 Athur Fayzrakhmanov. All rights reserved. |
| 4 | + |
| 5 | +;; This file is part of haskell-mode package. |
| 6 | +;; You can contact with authors using GitHub issue tracker: |
| 7 | +;; https://github.com/haskell/haskell-mode/issues |
| 8 | + |
| 9 | +;; This file 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, or (at your option) |
| 12 | +;; any later version. |
| 13 | + |
| 14 | +;; This file 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. |
| 18 | + |
| 19 | +;; You should have received a copy of the GNU General Public License |
| 20 | +;; along with GNU Emacs; see the file COPYING. If not, write to |
| 21 | +;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 22 | +;; Boston, MA 02110-1301, USA. |
| 23 | + |
| 24 | +;;; Commentary: |
| 25 | + |
| 26 | +;; This package provides regression tests for haskell-completions package. |
| 27 | + |
| 28 | +;;; Code: |
| 29 | + |
| 30 | +(require 'ert) |
| 31 | +(require 'haskell-mode) |
| 32 | +(require 'haskell-completions) |
| 33 | + |
| 34 | + |
| 35 | +(ert-deftest haskell-completions-can-grab-prefix-test () |
| 36 | + "Tests the function `haskell-completions-can-grab-prefix'." |
| 37 | + (with-temp-buffer |
| 38 | + (haskell-mode) |
| 39 | + (should (eql nil (haskell-completions-can-grab-prefix))) |
| 40 | + (insert " ") |
| 41 | + (should (eql nil (haskell-completions-can-grab-prefix))) |
| 42 | + (insert "a") |
| 43 | + (should (eql t (haskell-completions-can-grab-prefix))) |
| 44 | + (save-excursion |
| 45 | + (insert " ") |
| 46 | + (should (eql nil (haskell-completions-can-grab-prefix))) |
| 47 | + (insert "bc-") |
| 48 | + (should (eql t (haskell-completions-can-grab-prefix))) |
| 49 | + (insert "\n") |
| 50 | + (should (eql nil (haskell-completions-can-grab-prefix))) |
| 51 | + (insert "def:#!") |
| 52 | + (should (eql t (haskell-completions-can-grab-prefix)))) |
| 53 | + (should (eql t (haskell-completions-can-grab-prefix))) |
| 54 | + ;; punctuation tests |
| 55 | + (save-excursion (insert ")")) |
| 56 | + (should (eql t (haskell-completions-can-grab-prefix))) |
| 57 | + (save-excursion (insert ",")) |
| 58 | + (should (eql t (haskell-completions-can-grab-prefix))) |
| 59 | + (save-excursion (insert "'")) |
| 60 | + (should (eql t (haskell-completions-can-grab-prefix))) |
| 61 | + ;; should return nil in the middle of word |
| 62 | + (save-excursion (insert "bcd")) |
| 63 | + (should (eql nil (haskell-completions-can-grab-prefix))) |
| 64 | + ;; region case |
| 65 | + (let ((p (point))) |
| 66 | + (goto-char (point-min)) |
| 67 | + (push-mark) |
| 68 | + (goto-char p) |
| 69 | + (activate-mark) |
| 70 | + (should (eql nil (haskell-completions-can-grab-prefix)))))) |
| 71 | + |
| 72 | + |
| 73 | +(provide 'haskell-completions-tests) |
| 74 | +;;; haskell-completions-tests.el ends here |
0 commit comments