|
| 1 | +;;; haskell-load-tests.el |
| 2 | + |
| 3 | +;;; Code: |
| 4 | + |
| 5 | +(require 'ert) |
| 6 | +(require 'haskell-test-utils) |
| 7 | + |
| 8 | +(require 'haskell-load) |
| 9 | + |
| 10 | +(defun insert-errors () |
| 11 | + (insert "import Control.Applicativ\nimport Data.Mayb\nimport Data.String") |
| 12 | + (goto-char 1) |
| 13 | + (let ((applicativ (progn |
| 14 | + (search-forward "Control.Applicativ") |
| 15 | + (make-overlay (match-beginning 0) (match-end 0))))) |
| 16 | + (overlay-put applicativ 'haskell-check t) |
| 17 | + (overlay-put applicativ 'haskell-msg-type 'error) |
| 18 | + (overlay-put applicativ 'haskell-msg "Could not find module ‘Control.Applicativ’\n Perhaps you meant Control.Applicative (from base-4.8.1.0)\n Use -v to see a list of the files searched for.")) |
| 19 | + (let ((mayb (progn |
| 20 | + (search-forward "Data.Mayb") |
| 21 | + (make-overlay (match-beginning 0) (match-end 0))))) |
| 22 | + (overlay-put mayb 'haskell-check t) |
| 23 | + (overlay-put mayb 'haskell-msg-type 'error) |
| 24 | + (overlay-put mayb 'haskell-msg "Could not find module ‘Data.Mayb’\n Perhaps you meant\n Data.Maybe (from base-4.8.1.0)\n Data.Map (from containers-0.5.6.2@conta_LKCPrTJwOTOLk4OU37YmeN)\n Use -v to see a list of the files searched for.")) |
| 25 | + (goto-char 1)) |
| 26 | + |
| 27 | +(ert-deftest goto-first-error-before () |
| 28 | + (with-temp-switch-to-buffer |
| 29 | + (insert-errors) |
| 30 | + (haskell-goto-first-error) |
| 31 | + (should (looking-at-p "Control.Applicativ")))) |
| 32 | + |
| 33 | +(ert-deftest goto-first-error-after () |
| 34 | + (with-temp-switch-to-buffer |
| 35 | + (insert-errors) |
| 36 | + (search-forward "Data.String") |
| 37 | + (haskell-goto-first-error) |
| 38 | + (should (looking-at-p "Control.Applicativ")))) |
| 39 | + |
| 40 | +(ert-deftest goto-first-error-between () |
| 41 | + (with-temp-switch-to-buffer |
| 42 | + (insert-errors) |
| 43 | + (search-forward "import Data.Mayb") |
| 44 | + (haskell-goto-first-error) |
| 45 | + (should (looking-at-p "Control.Applicativ")))) |
| 46 | + |
| 47 | +(ert-deftest goto-next-error-before () |
| 48 | + (with-temp-switch-to-buffer |
| 49 | + (insert-errors) |
| 50 | + (haskell-goto-next-error) |
| 51 | + (should (looking-at-p "Control.Applicativ")))) |
| 52 | + |
| 53 | +(ert-deftest goto-next-error-between () |
| 54 | + (with-temp-switch-to-buffer |
| 55 | + (insert-errors) |
| 56 | + (search-forward "import" nil nil 2) |
| 57 | + (haskell-goto-next-error) |
| 58 | + (should (looking-at-p "Data.Mayb")))) |
| 59 | + |
| 60 | +(ert-deftest goto-next-error-after () |
| 61 | + (with-temp-switch-to-buffer |
| 62 | + (insert-errors) |
| 63 | + (search-forward "import" nil nil 3) |
| 64 | + (haskell-goto-next-error) |
| 65 | + (should (looking-at-p " Data.String")))) |
| 66 | + |
| 67 | +(ert-deftest goto-prev-error-before () |
| 68 | + (with-temp-switch-to-buffer |
| 69 | + (insert-errors) |
| 70 | + (haskell-goto-prev-error) |
| 71 | + (should (looking-at-p "import Control.Applicativ")))) |
| 72 | + |
| 73 | +(ert-deftest goto-prev-error-between () |
| 74 | + (with-temp-switch-to-buffer |
| 75 | + (insert-errors) |
| 76 | + (search-forward "import" nil nil 2) |
| 77 | + (haskell-goto-prev-error) |
| 78 | + (should (looking-at-p "Control.Applicativ")))) |
| 79 | + |
| 80 | +(ert-deftest goto-prev-error-after () |
| 81 | + (with-temp-switch-to-buffer |
| 82 | + (insert-errors) |
| 83 | + (search-forward "import Data.String") |
| 84 | + (haskell-goto-prev-error) |
| 85 | + (should (looking-at-p "Data.Mayb")))) |
0 commit comments