aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Martín2023-01-08 14:04:24 +0100
committerYuan Fu2023-01-13 00:55:24 -0800
commitc6bbf9cc270dedb8adcafdd0c7ff902611176993 (patch)
tree22eeed8c288832430fac66b07e5b3ef57f79ce0e
parenta760364f5f36ad4ded67b0fd5ca4ef59c9b2d705 (diff)
downloademacs-c6bbf9cc270dedb8adcafdd0c7ff902611176993.tar.gz
emacs-c6bbf9cc270dedb8adcafdd0c7ff902611176993.zip
Add c-ts-mode tests
* test/lisp/progmodes/c-ts-mode-resources/indent.erts: New .erts file to test indentation of typical C constructs and prevent regression of bug fixes. * test/lisp/progmodes/c-ts-mode-tests.el: New file with c-ts-mode tests.
-rw-r--r--test/lisp/progmodes/c-ts-mode-resources/indent.erts44
-rw-r--r--test/lisp/progmodes/c-ts-mode-tests.el31
2 files changed, 75 insertions, 0 deletions
diff --git a/test/lisp/progmodes/c-ts-mode-resources/indent.erts b/test/lisp/progmodes/c-ts-mode-resources/indent.erts
new file mode 100644
index 00000000000..5defcbd3c83
--- /dev/null
+++ b/test/lisp/progmodes/c-ts-mode-resources/indent.erts
@@ -0,0 +1,44 @@
1Code:
2 (lambda ()
3 (c-ts-mode)
4 (indent-region (point-min) (point-max)))
5
6Name: Basic
7
8=-=
9int
10main (void)
11{
12 return 0;
13}
14=-=-=
15
16Name: Hanging Braces (GNU Style)
17
18=-=
19int
20main (void)
21{
22 if (true)
23 {
24 }
25}
26=-=-=
27
28Name: Multiline Parameter List (bug#60398)
29
30=-=
31int f2(int x,
32 int y) {
33 return x + y;
34};
35=-=-=
36
37Name: Multiline Block Comments (bug#60270)
38
39=-=
40/**
41 * @some_func:
42 * @arg1:
43 */
44=-=-=
diff --git a/test/lisp/progmodes/c-ts-mode-tests.el b/test/lisp/progmodes/c-ts-mode-tests.el
new file mode 100644
index 00000000000..8606faf9913
--- /dev/null
+++ b/test/lisp/progmodes/c-ts-mode-tests.el
@@ -0,0 +1,31 @@
1;;; c-ts-mode-tests.el --- Tests for Tree-sitter-based C mode -*- lexical-binding: t; -*-
2
3;; Copyright (C) 2023 Free Software Foundation, Inc.
4
5;; This file is part of GNU Emacs.
6
7;; GNU Emacs is free software: you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation, either version 3 of the License, or
10;; (at your option) any later version.
11
12;; GNU Emacs is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
19
20;;; Code:
21
22(require 'ert)
23(require 'ert-x)
24(require 'treesit)
25
26(ert-deftest c-ts-mode-test-indentation ()
27 (skip-unless (treesit-ready-p 'c))
28 (ert-test-erts-file (ert-resource-file "indent.erts")))
29
30(provide 'c-ts-mode-tests)
31;;; c-ts-mode-tests.el ends here