|
21 | 21 | (require 'purescript-sort-imports) |
22 | 22 |
|
23 | 23 | (ert-deftest empty-buffer () |
24 | | - (should (with-temp-buffer |
25 | | - (purescript-sort-imports) |
26 | | - t))) |
| 24 | + (with-temp-buffer |
| 25 | + (purescript-sort-imports) |
| 26 | + t)) |
27 | 27 |
|
28 | 28 | (ert-deftest single-line () |
29 | | - (should (with-temp-buffer |
30 | | - (insert "import A\n") |
31 | | - (goto-char (point-min)) |
32 | | - (purescript-sort-imports) |
33 | | - (string= (buffer-string) |
| 29 | + (with-temp-buffer |
| 30 | + (insert "import A\n") |
| 31 | + (goto-char (point-min)) |
| 32 | + (purescript-sort-imports) |
| 33 | + (should (string= (buffer-string) |
34 | 34 | "import A\n")))) |
35 | 35 |
|
36 | 36 | (ert-deftest two-idem () |
37 | | - (should (with-temp-buffer |
38 | | - (insert "import A |
| 37 | + (with-temp-buffer |
| 38 | + (insert "import A |
39 | 39 | import B |
40 | 40 | ") |
41 | | - (goto-char (point-min)) |
42 | | - (purescript-sort-imports) |
43 | | - (string= (buffer-string) |
| 41 | + (goto-char (point-min)) |
| 42 | + (purescript-sort-imports) |
| 43 | + (should (string= (buffer-string) |
44 | 44 | "import A |
45 | 45 | import B |
46 | 46 | "))) |
47 | | - (should (with-temp-buffer |
48 | | - (insert "import qualified A |
| 47 | + (with-temp-buffer |
| 48 | + (insert "import A (A, B, C) |
49 | 49 | import B |
50 | 50 | ") |
51 | | - (goto-char (point-min)) |
52 | | - (purescript-sort-imports) |
53 | | - (string= (buffer-string) |
54 | | - "import qualified A |
| 51 | + (goto-char (point-min)) |
| 52 | + (purescript-sort-imports) |
| 53 | + (should (string= (buffer-string) |
| 54 | + "import A (A, B, C) |
55 | 55 | import B |
56 | 56 | "))) |
57 | | - (should (with-temp-buffer |
58 | | - (insert "import qualified \"mtl\" A |
| 57 | + (with-temp-buffer |
| 58 | + (insert "import A (mtl) |
59 | 59 | import B |
60 | 60 | ") |
61 | | - (goto-char (point-min)) |
62 | | - (purescript-sort-imports) |
63 | | - (string= (buffer-string) |
64 | | - "import qualified \"mtl\" A |
| 61 | + (goto-char (point-min)) |
| 62 | + (purescript-sort-imports) |
| 63 | + (should (string= (buffer-string) |
| 64 | + "import A (mtl) |
65 | 65 | import B |
66 | 66 | ")))) |
67 | 67 |
|
68 | 68 | (ert-deftest two-rev () |
69 | | - (should (with-temp-buffer |
70 | | - (insert "import B |
| 69 | + (with-temp-buffer |
| 70 | + (insert "import B |
71 | 71 | import A |
72 | 72 | ") |
73 | | - (goto-char (point-min)) |
74 | | - (purescript-sort-imports) |
75 | | - (string= (buffer-string) |
| 73 | + (goto-char (point-min)) |
| 74 | + (purescript-sort-imports) |
| 75 | + (should (string= (buffer-string) |
76 | 76 | "import A |
77 | 77 | import B |
78 | 78 | ")))) |
79 | 79 |
|
80 | 80 | (ert-deftest file-structure () |
81 | | - (should (with-temp-buffer |
82 | | - (insert "module A where |
| 81 | + (with-temp-buffer |
| 82 | + (insert "module A where |
83 | 83 | import B |
84 | 84 | import A |
85 | 85 | ") |
86 | | - ;; test at line 2 |
87 | | - (goto-char (point-min)) |
88 | | - (forward-line 1) |
89 | | - (purescript-sort-imports) |
90 | | - (string= (buffer-string) |
| 86 | + ;; test at line 2 |
| 87 | + (goto-char (point-min)) |
| 88 | + (forward-line 1) |
| 89 | + (purescript-sort-imports) |
| 90 | + (should (string= (buffer-string) |
91 | 91 | "module A where |
92 | 92 | import A |
93 | 93 | import B |
94 | 94 | "))) |
95 | | - (should (with-temp-buffer |
96 | | - (insert "module C where |
| 95 | + (with-temp-buffer |
| 96 | + (insert "module C where |
97 | 97 |
|
98 | 98 | import B |
99 | 99 | import A |
100 | 100 | ") |
101 | | - ;; test at line 3 |
102 | | - (goto-char (point-min)) |
103 | | - (forward-line 2) |
104 | | - (purescript-sort-imports) |
105 | | - (string= (buffer-string) |
| 101 | + ;; test at line 3 |
| 102 | + (goto-char (point-min)) |
| 103 | + (forward-line 2) |
| 104 | + (purescript-sort-imports) |
| 105 | + (should (string= (buffer-string) |
106 | 106 | "module C where |
107 | 107 |
|
108 | 108 | import A |
109 | 109 | import B |
110 | 110 | ")))) |
111 | 111 |
|
112 | 112 | (ert-deftest bos-270 () |
113 | | - (should (with-temp-buffer |
114 | | - (insert "import Data.Aeson.Encode (encode) |
| 113 | + (with-temp-buffer |
| 114 | + (insert "import Data.Aeson.Encode (encode) |
115 | 115 | import Data.Aeson.Types |
116 | 116 | import Data.Aeson.Parser.Internal (decodeWith, decodeStrictWith, |
117 | 117 | eitherDecodeWith, eitherDecodeStrictWith, |
118 | 118 | jsonEOF, json, jsonEOF', json') |
119 | | -import qualified Data.ByteString as B |
120 | | -import qualified Data.ByteString.Lazy as L |
| 119 | +import Data.ByteString as B |
| 120 | +import Data.ByteString.Lazy as L |
121 | 121 | ") |
122 | | - (goto-char (point-min)) |
123 | | - (purescript-sort-imports) |
124 | | - (string= (buffer-string) |
| 122 | + (goto-char (point-min)) |
| 123 | + (purescript-sort-imports) |
| 124 | + (should (string= (buffer-string) |
125 | 125 | "import Data.Aeson.Encode (encode) |
126 | 126 | import Data.Aeson.Parser.Internal (decodeWith, decodeStrictWith, |
127 | 127 | eitherDecodeWith, eitherDecodeStrictWith, |
128 | 128 | jsonEOF, json, jsonEOF', json') |
129 | 129 | import Data.Aeson.Types |
130 | | -import qualified Data.ByteString as B |
131 | | -import qualified Data.ByteString.Lazy as L |
| 130 | +import Data.ByteString as B |
| 131 | +import Data.ByteString.Lazy as L |
132 | 132 | ")))) |
133 | 133 |
|
134 | 134 | (provide 'purescript-sort-imports-tests) |
0 commit comments