branch: elpa/d-mode
commit 3e5a5d523d7580b2a42f376cbf83bdd9ac296bbd
Author: Vladimir Panteleev <[email protected]>
Commit: Vladimir Panteleev <[email protected]>
tests: Add test case for pull request #35
---
d-mode-test.el | 16 ++++++++++++++++
tests/I0035.d | 10 ++++++++++
2 files changed, 26 insertions(+)
diff --git a/d-mode-test.el b/d-mode-test.el
index efd952f..76ab7e2 100644
--- a/d-mode-test.el
+++ b/d-mode-test.el
@@ -236,10 +236,26 @@ Called from the #run snippet of individual test files."
(line-number-at-pos (cdr x)))
imenu--index-alist))
+(defun d-test-indent ()
+ "Re-indent the current file.
+
+If the resulting indentation ends up being different, raise an error."
+ (condition-case nil
+ (progn (c-indent-region (point-min) (point-max)) t)
+ (error
+ (let ((orig (buffer-string)))
+ (let (buffer-read-only)
+ (c-indent-region (point-min) (point-max)))
+ (error (concat "Test case has been indented differently.\n"
+
"Expected:\n--------------------\n%s\n--------------------\n"
+ "Got:\n--------------------\n%s\n--------------------\n")
+ orig (buffer-string))))))
+
;; Run the tests
(ert-deftest d-mode-basic ()
(should (equal (do-one-test "tests/imenu.d") t))
(should (equal (do-one-test "tests/I0021.d") t))
+ (should (equal (do-one-test "tests/I0035.d") t))
(should (equal (do-one-test "tests/I0039.d") t))
(should (equal (do-one-test "tests/I0064.d") t))
(should (equal (do-one-test "tests/I0069.txt") t))
diff --git a/tests/I0035.d b/tests/I0035.d
new file mode 100644
index 0000000..1bf1aab
--- /dev/null
+++ b/tests/I0035.d
@@ -0,0 +1,10 @@
+// #run: (d-test-indent)
+
+static if (true)
+ {
+ void[0] a;
+ }
+else static if (true)
+ {
+ void[0] a;
+ }