Skip to content

Commit 0f832da

Browse files
committed
tests: only use should for specific assertions
This improves debuggability of fails, because tests would only show the part that failed. There's no reason to wrap full code blocks to `should` because their execution may only exit past `should` if exception is thrown, which would be caught by `ert` anyway.
1 parent aa5bb16 commit 0f832da

File tree

1 file changed

+47
-47
lines changed

1 file changed

+47
-47
lines changed

tests/purescript-sort-imports-tests.el

+47-47
Original file line numberDiff line numberDiff line change
@@ -21,107 +21,107 @@
2121
(require 'purescript-sort-imports)
2222

2323
(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))
2727

2828
(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)
3434
"import A\n"))))
3535

3636
(ert-deftest two-idem ()
37-
(should (with-temp-buffer
38-
(insert "import A
37+
(with-temp-buffer
38+
(insert "import A
3939
import B
4040
")
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)
4444
"import A
4545
import B
4646
")))
47-
(should (with-temp-buffer
48-
(insert "import A (A, B, C)
47+
(with-temp-buffer
48+
(insert "import A (A, B, C)
4949
import B
5050
")
51-
(goto-char (point-min))
52-
(purescript-sort-imports)
53-
(string= (buffer-string)
51+
(goto-char (point-min))
52+
(purescript-sort-imports)
53+
(should (string= (buffer-string)
5454
"import A (A, B, C)
5555
import B
5656
")))
57-
(should (with-temp-buffer
58-
(insert "import A (mtl)
57+
(with-temp-buffer
58+
(insert "import A (mtl)
5959
import B
6060
")
61-
(goto-char (point-min))
62-
(purescript-sort-imports)
63-
(string= (buffer-string)
61+
(goto-char (point-min))
62+
(purescript-sort-imports)
63+
(should (string= (buffer-string)
6464
"import A (mtl)
6565
import B
6666
"))))
6767

6868
(ert-deftest two-rev ()
69-
(should (with-temp-buffer
70-
(insert "import B
69+
(with-temp-buffer
70+
(insert "import B
7171
import A
7272
")
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)
7676
"import A
7777
import B
7878
"))))
7979

8080
(ert-deftest file-structure ()
81-
(should (with-temp-buffer
82-
(insert "module A where
81+
(with-temp-buffer
82+
(insert "module A where
8383
import B
8484
import A
8585
")
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)
9191
"module A where
9292
import A
9393
import B
9494
")))
95-
(should (with-temp-buffer
96-
(insert "module C where
95+
(with-temp-buffer
96+
(insert "module C where
9797
9898
import B
9999
import A
100100
")
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)
106106
"module C where
107107
108108
import A
109109
import B
110110
"))))
111111

112112
(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)
115115
import Data.Aeson.Types
116116
import Data.Aeson.Parser.Internal (decodeWith, decodeStrictWith,
117117
eitherDecodeWith, eitherDecodeStrictWith,
118118
jsonEOF, json, jsonEOF', json')
119119
import Data.ByteString as B
120120
import Data.ByteString.Lazy as L
121121
")
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)
125125
"import Data.Aeson.Encode (encode)
126126
import Data.Aeson.Parser.Internal (decodeWith, decodeStrictWith,
127127
eitherDecodeWith, eitherDecodeStrictWith,

0 commit comments

Comments
 (0)