|
28 | 28 | (require 'flycheck-haskell)
|
29 | 29 |
|
30 | 30 | (require 'cl-lib)
|
| 31 | +(require 'dash) |
31 | 32 | (require 'ert)
|
32 | 33 |
|
33 | 34 |
|
|
54 | 55 | `(unwind-protect (progn ,@body)
|
55 | 56 | (flycheck-haskell-clear-config-cache)))
|
56 | 57 |
|
| 58 | +(defun flycheck-haskell-compare-sets (actual expected) |
| 59 | + "Compare ACTUAL and EXPECTED ignoring ordering." |
| 60 | + (should (equal '() (-difference actual expected)))) |
| 61 | + |
57 | 62 |
|
58 | 63 | ;;; Test cases
|
59 | 64 |
|
|
98 | 103 | (should (= (hash-table-count flycheck-haskell-config-cache) 0))))
|
99 | 104 |
|
100 | 105 | (ert-deftest flycheck-haskell-read-cabal-configuration/has-all-extensions ()
|
101 |
| - (should (equal (assq 'extensions (flycheck-haskell-read-test-config)) |
102 |
| - '(extensions "OverloadedStrings" |
103 |
| - "YouDontKnowThisOne" |
104 |
| - "GeneralizedNewtypeDeriving")))) |
| 106 | + (flycheck-haskell-compare-sets (assq 'extensions (flycheck-haskell-read-test-config)) |
| 107 | + '(extensions "OverloadedStrings" |
| 108 | + "YouDontKnowThisOne" |
| 109 | + "GeneralizedNewtypeDeriving"))) |
105 | 110 |
|
106 | 111 | (ert-deftest flycheck-haskell-read-cabal-configuration/has-all-languages ()
|
107 |
| - (should (equal (assq 'languages (flycheck-haskell-read-test-config)) |
108 |
| - '(languages "Haskell98" "SpamLanguage" "Haskell2010")))) |
| 112 | + (flycheck-haskell-compare-sets (assq 'languages (flycheck-haskell-read-test-config)) |
| 113 | + '(languages "Haskell98" "SpamLanguage" "Haskell2010"))) |
109 | 114 |
|
110 | 115 | (ert-deftest flycheck-haskell-read-cabal-configuration/source-dirs ()
|
111 | 116 | (let* ((builddirs '("lib/" "." "src/"))
|
112 | 117 | (expanddir (lambda (fn)
|
113 | 118 | (file-name-as-directory
|
114 | 119 | (expand-file-name fn flycheck-haskell-test-dir)))))
|
115 |
| - (should (equal |
116 |
| - (assq 'source-directories (flycheck-haskell-read-test-config)) |
117 |
| - (cons 'source-directories (-map expanddir builddirs)))))) |
| 120 | + (flycheck-haskell-compare-sets |
| 121 | + (assq 'source-directories (flycheck-haskell-read-test-config)) |
| 122 | + (cons 'source-directories (-map expanddir builddirs))))) |
118 | 123 |
|
119 | 124 | (ert-deftest flycheck-haskell-read-cabal-configuration/build-dirs ()
|
120 | 125 | (let* ((distdir (expand-file-name "dist/" flycheck-haskell-test-dir))
|
121 | 126 | (expanddir (lambda (fn) (expand-file-name fn distdir)))
|
122 | 127 | (builddirs '("build" "build/autogen"
|
123 | 128 | "build/flycheck-haskell-unknown-stuff/flycheck-haskell-unknown-stuff-tmp"
|
124 | 129 | "build/flycheck-haskell-test/flycheck-haskell-test-tmp")))
|
125 |
| - (should (equal |
126 |
| - (assq 'build-directories (flycheck-haskell-read-test-config)) |
127 |
| - (cons 'build-directories (-map expanddir builddirs)))))) |
| 130 | + (flycheck-haskell-compare-sets |
| 131 | + (assq 'build-directories (flycheck-haskell-read-test-config)) |
| 132 | + (cons 'build-directories (-map expanddir builddirs))))) |
128 | 133 |
|
129 | 134 | (ert-deftest flycheck-haskell-get-configuration/no-cache-entry ()
|
130 | 135 | (let* ((cabal-file flycheck-haskell-test-cabal-file))
|
|
156 | 161 | (ert-deftest flycheck-haskell-process-configuration/language-extensions ()
|
157 | 162 | (with-temp-buffer ; To scope the variables
|
158 | 163 | (flycheck-haskell-process-configuration (flycheck-haskell-read-test-config))
|
159 |
| - (should (equal flycheck-ghc-language-extensions |
160 |
| - '("OverloadedStrings" |
161 |
| - "YouDontKnowThisOne" |
162 |
| - "GeneralizedNewtypeDeriving" |
163 |
| - "Haskell98" |
164 |
| - "SpamLanguage" |
165 |
| - "Haskell2010"))) |
| 164 | + (flycheck-haskell-compare-sets |
| 165 | + flycheck-ghc-language-extensions |
| 166 | + '("OverloadedStrings" |
| 167 | + "YouDontKnowThisOne" |
| 168 | + "GeneralizedNewtypeDeriving" |
| 169 | + "Haskell98" |
| 170 | + "SpamLanguage" |
| 171 | + "Haskell2010")) |
166 | 172 | (should (local-variable-p 'flycheck-ghc-language-extensions))))
|
167 | 173 |
|
168 | 174 | (ert-deftest flycheck-haskell-process-configuration/search-path ()
|
|
173 | 179 | "build/flycheck-haskell-test/flycheck-haskell-test-tmp"))
|
174 | 180 | (sourcedir (lambda (fn) (file-name-as-directory
|
175 | 181 | (expand-file-name fn flycheck-haskell-test-dir))))
|
176 |
| - (sourcedirs '("lib/" "." "src/"))) |
| 182 | + (sourcedirs '("lib/" "." "src/")) |
| 183 | + (computed-path (append (-map builddir builddirs) |
| 184 | + (-map sourcedir sourcedirs)))) |
177 | 185 | (with-temp-buffer
|
178 | 186 | (flycheck-haskell-process-configuration (flycheck-haskell-read-test-config))
|
179 |
| - (should (equal flycheck-ghc-search-path |
180 |
| - (append (-map builddir builddirs) |
181 |
| - (-map sourcedir sourcedirs)))) |
| 187 | + (flycheck-haskell-compare-sets flycheck-ghc-search-path computed-path) |
182 | 188 | (should (local-variable-p 'flycheck-ghc-search-path)))))
|
183 | 189 |
|
184 | 190 | (provide 'flycheck-haskell-test)
|
|
0 commit comments