Skip to content

Commit b65822b

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 b65822b

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

tests/purescript-sort-imports-tests.el

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,64 +21,64 @@
2121
(require 'purescript-sort-imports)
2222

2323
(ert-deftest empty-buffer ()
24-
(should (with-temp-buffer
24+
(with-temp-buffer
2525
(purescript-sort-imports)
26-
t)))
26+
t))
2727

2828
(ert-deftest single-line ()
29-
(should (with-temp-buffer
29+
(with-temp-buffer
3030
(insert "import A\n")
3131
(goto-char (point-min))
3232
(purescript-sort-imports)
33-
(string= (buffer-string)
34-
"import A\n"))))
33+
(should (string= (buffer-string)
34+
"import A\n"))))
3535

3636
(ert-deftest two-idem ()
37-
(should (with-temp-buffer
37+
(with-temp-buffer
3838
(insert "import A
3939
import B
4040
")
4141
(goto-char (point-min))
4242
(purescript-sort-imports)
43-
(string= (buffer-string)
44-
"import A
43+
(should (string= (buffer-string)
44+
"import A
4545
import B
4646
")))
47-
(should (with-temp-buffer
47+
(with-temp-buffer
4848
(insert "import A (A, B, C)
4949
import B
5050
")
5151
(goto-char (point-min))
5252
(purescript-sort-imports)
53-
(string= (buffer-string)
54-
"import A (A, B, C)
53+
(should (string= (buffer-string)
54+
"import A (A, B, C)
5555
import B
5656
")))
57-
(should (with-temp-buffer
57+
(with-temp-buffer
5858
(insert "import A (mtl)
5959
import B
6060
")
6161
(goto-char (point-min))
6262
(purescript-sort-imports)
63-
(string= (buffer-string)
64-
"import A (mtl)
63+
(should (string= (buffer-string)
64+
"import A (mtl)
6565
import B
6666
"))))
6767

6868
(ert-deftest two-rev ()
69-
(should (with-temp-buffer
69+
(with-temp-buffer
7070
(insert "import B
7171
import A
7272
")
7373
(goto-char (point-min))
7474
(purescript-sort-imports)
75-
(string= (buffer-string)
76-
"import A
75+
(should (string= (buffer-string)
76+
"import A
7777
import B
7878
"))))
7979

8080
(ert-deftest file-structure ()
81-
(should (with-temp-buffer
81+
(with-temp-buffer
8282
(insert "module A where
8383
import B
8484
import A
@@ -87,12 +87,12 @@ import A
8787
(goto-char (point-min))
8888
(forward-line 1)
8989
(purescript-sort-imports)
90-
(string= (buffer-string)
91-
"module A where
90+
(should (string= (buffer-string)
91+
"module A where
9292
import A
9393
import B
9494
")))
95-
(should (with-temp-buffer
95+
(with-temp-buffer
9696
(insert "module C where
9797
9898
import B
@@ -102,15 +102,15 @@ import A
102102
(goto-char (point-min))
103103
(forward-line 2)
104104
(purescript-sort-imports)
105-
(string= (buffer-string)
106-
"module C where
105+
(should (string= (buffer-string)
106+
"module C where
107107
108108
import A
109109
import B
110110
"))))
111111

112112
(ert-deftest bos-270 ()
113-
(should (with-temp-buffer
113+
(with-temp-buffer
114114
(insert "import Data.Aeson.Encode (encode)
115115
import Data.Aeson.Types
116116
import Data.Aeson.Parser.Internal (decodeWith, decodeStrictWith,
@@ -121,8 +121,8 @@ import Data.ByteString.Lazy as L
121121
")
122122
(goto-char (point-min))
123123
(purescript-sort-imports)
124-
(string= (buffer-string)
125-
"import Data.Aeson.Encode (encode)
124+
(should (string= (buffer-string)
125+
"import Data.Aeson.Encode (encode)
126126
import Data.Aeson.Parser.Internal (decodeWith, decodeStrictWith,
127127
eitherDecodeWith, eitherDecodeStrictWith,
128128
jsonEOF, json, jsonEOF', json')

0 commit comments

Comments
 (0)