aboutsummaryrefslogtreecommitdiffstats
path: root/test/lisp
diff options
context:
space:
mode:
authorNoah Peart2024-04-19 10:27:10 -0700
committerYuan Fu2024-04-21 21:49:19 -0700
commitac2a4f61bdd0dc3a71a544d25de7cb36d37f44f9 (patch)
tree6b9352c6d30c4f388ccc877967cdcfc25f8f3553 /test/lisp
parent5c51bc934ebb88dd9dd8b228e99c39518c92c54b (diff)
downloademacs-ac2a4f61bdd0dc3a71a544d25de7cb36d37f44f9.tar.gz
emacs-ac2a4f61bdd0dc3a71a544d25de7cb36d37f44f9.zip
Add rust-ts-mode font-locking tests (bug#70464)
* test/lisp/progmodes/rust-ts-mode-tests.el: New file for rust-ts-mode tests. * test/lisp/progmodes/rust-ts-mode-resources/font-lock.rs: New file with rust-ts-mode font-locking tests. New tests added for macro font-locking (bug#70464) and function signatures (bug#70465).
Diffstat (limited to 'test/lisp')
-rw-r--r--test/lisp/progmodes/rust-ts-mode-resources/font-lock.rs25
-rw-r--r--test/lisp/progmodes/rust-ts-mode-tests.el34
2 files changed, 59 insertions, 0 deletions
diff --git a/test/lisp/progmodes/rust-ts-mode-resources/font-lock.rs b/test/lisp/progmodes/rust-ts-mode-resources/font-lock.rs
new file mode 100644
index 00000000000..377cda0e3b9
--- /dev/null
+++ b/test/lisp/progmodes/rust-ts-mode-resources/font-lock.rs
@@ -0,0 +1,25 @@
1// -*- rust-ts-mode-indent-offset: 0 -*-
2// Trait with function signature
3trait Foo {
4 fn foo();
5// ^ font-lock-function-name-face
6}
7
8// Macros
9macro_rules! unsafe_foo {
10 ($env:expr, $name:ident $(, $args:expr)*) => {
11// ^ font-lock-variable-name-face
12// ^ font-lock-type-face
13// ^ font-lock-variable-name-face
14// ^ font-lock-type-face
15// ^ font-lock-operator-face
16// ^ font-lock-variable-name-face
17// ^ font-lock-type-face
18// ^ font-lock-operator-face
19 {
20 foo!($env, $name $(, $args)*);
21// ^ font-lock-variable-use-face
22// ^ font-lock-operator-face
23// ^ font-lock-operator-face
24 }
25 };
diff --git a/test/lisp/progmodes/rust-ts-mode-tests.el b/test/lisp/progmodes/rust-ts-mode-tests.el
new file mode 100644
index 00000000000..f718a57fc9e
--- /dev/null
+++ b/test/lisp/progmodes/rust-ts-mode-tests.el
@@ -0,0 +1,34 @@
1;;; rust-ts-mode-tests.el --- Tests for rust-ts-mode -*- lexical-binding: t; -*-
2
3;; Copyright (C) 2023-2024 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-font-lock)
24(require 'ert-x)
25(require 'treesit)
26
27(ert-deftest rust-ts-test-font-lock ()
28 (skip-unless (treesit-ready-p 'rust))
29 (let ((treesit-font-lock-level 4))
30 (ert-font-lock-test-file (ert-resource-file "font-lock.rs") 'rust-ts-mode)))
31
32(provide 'rust-ts-mode-tests)
33
34;;; rust-ts-mode-tests.el ends here