Skip to content

Commit 3589de6

Browse files
committed
add tests
1 parent 0f1c299 commit 3589de6

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

test/dap-test.el

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,13 @@
123123
(should (dap-python--equal actual expected))
124124
(should (dap-python--equal (dap-python--nearest-test expected) "::TestClass::test_foo"))))
125125

126-
(defun dap-launch-test--delete-string-comments (s)
126+
(defun dap-launch-test--sanitize-json (s)
127127
"Delete all comments in S."
128128
(with-temp-buffer
129129
(insert s)
130130
(goto-char (point-min))
131131

132-
(dap-launch-remove-comments)
132+
(dap-launch-sanitize-json)
133133
(buffer-string)))
134134

135135
(ert-deftest dap-launch-test--delete-comments ()
@@ -139,21 +139,34 @@
139139
/* \" // non-string */
140140
\"// string\"
141141
\"/*string*/\"")
142-
(post-exp (dap-launch-test--delete-string-comments orig)))
142+
(post-exp (dap-launch-test--sanitize-json orig)))
143143
(should (string= post-exp "
144144
145145
146146
147147
\"// string\"
148148
\"/*string*/\""))))
149149

150+
(ert-deftest dap-launch-test--delete-commas ()
151+
(let ((orig "{
152+
\"abc\": 123,
153+
}")
154+
(post-exp (dap-launch-test--sanitize-json orig)))
155+
(should (string= post-exp "{
156+
\"abc\": 123
157+
}"))))
158+
150159
(ert-deftest dap-launch-test--comment-in-string ()
151160
(let ((orig "\"// orig\""))
152-
(should (string= orig (dap-launch-test--delete-string-comments orig)))))
161+
(should (string= orig (dap-launch-test--sanitize-json orig)))))
153162

154163
(ert-deftest dap-launch-test--comment-star ()
155164
(let ((orig "/* * **/"))
156-
(should (string-empty-p (dap-launch-test--delete-string-comments orig)))))
165+
(should (string-empty-p (dap-launch-test--sanitize-json orig)))))
166+
167+
(ert-deftest dap-launch-test--comma-in-string ()
168+
(let ((orig "\"abc, ]\""))
169+
(should (string= orig (dap-launch-test--sanitize-json orig)))))
157170

158171

159172
(defmacro dap-variables--define-compare-test (name conf expanded

0 commit comments

Comments
 (0)