|
| 1 | +;;; haskell-decl-scan-tests.el -*- lexical-binding: t -*- |
| 2 | + |
| 3 | +;; Copyright © 2016 Chris Gregory. 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-decl-scan package. |
| 27 | + |
| 28 | +;;; Code: |
| 29 | + |
| 30 | +(require 'ert) |
| 31 | +(require 'haskell-decl-scan) |
| 32 | +(require 'haskell-test-utils) |
| 33 | + |
| 34 | +(ert-deftest haskell-ds-backward-decl-1 () |
| 35 | + "Test running haskell-ds-backward-decl" |
| 36 | + (with-temp-buffer |
| 37 | + (insert-lines "" "fun :: Int -> Int" "fun = id" |
| 38 | + "" "f2 :: Int" "f2 = 3" "") |
| 39 | + (goto-char (point-max)) |
| 40 | + (should (haskell-ds-backward-decl)) |
| 41 | + (should (looking-at-p "f2 :: Int")) |
| 42 | + (should (haskell-ds-backward-decl)) |
| 43 | + (should (looking-at-p "fun :: Int -> Int")) |
| 44 | + (should-not (haskell-ds-backward-decl)) |
| 45 | + (should (= (point-min) (point))))) |
| 46 | + |
| 47 | +(ert-deftest haskell-ds-backward-decl-2 () |
| 48 | + "Test running haskell-ds-backward-decl" |
| 49 | + (with-temp-buffer |
| 50 | + (insert-lines "" "" "fun :: Int -> Int" |
| 51 | + "" "" "fun = id" |
| 52 | + "" "" "f2 :: Int" |
| 53 | + "" "" "f2 = 3" |
| 54 | + "" "" "") |
| 55 | + (goto-char (point-max)) |
| 56 | + (should (haskell-ds-backward-decl)) |
| 57 | + (should (looking-at-p "f2 :: Int")) |
| 58 | + (should (haskell-ds-backward-decl)) |
| 59 | + (should (looking-at-p "fun :: Int -> Int")) |
| 60 | + (should-not (haskell-ds-backward-decl)) |
| 61 | + (should (= (point-min) (point))))) |
| 62 | + |
| 63 | +(ert-deftest haskell-ds-forward-decl-1 () |
| 64 | + "Test running haskell-ds-backward-decl" |
| 65 | + (with-temp-buffer |
| 66 | + (insert-lines "" "fun :: Int -> Int" "fun = id" |
| 67 | + "" "f2 :: Int" "f2 = 3" |
| 68 | + "") |
| 69 | + (goto-char (point-min)) |
| 70 | + (should (haskell-ds-forward-decl)) |
| 71 | + (should (looking-at-p "$")) |
| 72 | + (should (= (point) (save-excursion (goto-line 4) (point)))) |
| 73 | + (should (haskell-ds-forward-decl)) |
| 74 | + (should (looking-at-p "f2 :: Int")) |
| 75 | + (should (= (point-max) (haskell-ds-forward-decl))))) |
| 76 | + |
| 77 | +(ert-deftest haskell-ds-forward-decl-2 () |
| 78 | + "Test running haskell-ds-backward-decl" |
| 79 | + (with-temp-buffer |
| 80 | + (insert-lines "" "" "fun :: Int -> Int" |
| 81 | + "" "" "fun = id" |
| 82 | + "" "" "f2 :: Int" |
| 83 | + "" "" "f2 = 3" |
| 84 | + "" "" "") |
| 85 | + (goto-char (point-min)) |
| 86 | + (should (haskell-ds-forward-decl)) |
| 87 | + (should (looking-at-p "$")) |
| 88 | + (should (= (point) (save-excursion (goto-line 7) (point)))) |
| 89 | + (should (haskell-ds-forward-decl)) |
| 90 | + (should (looking-at-p "f2 :: Int")) |
| 91 | + (should (haskell-ds-forward-decl)) |
| 92 | + (should (= (point) (save-excursion (goto-line 13) (point)))) |
| 93 | + (should (= (point-max) (progn (haskell-ds-forward-decl) (point)))))) |
| 94 | + |
| 95 | +(provide 'haskell-decl-scan-tests) |
| 96 | + |
| 97 | +;;; haskell-decl-scan-tests.el ends here |
0 commit comments