From 85601f50f236686da662b1b00e01df0a0abe761b Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Wed, 22 Jul 2026 11:10:34 +0200 Subject: Update markdown-mode, rust-mode and yaml-mode. Remove unused snippets --- .emacs.d/lisp/rust-mode-tests.el | 62 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) (limited to '.emacs.d/lisp/rust-mode-tests.el') diff --git a/.emacs.d/lisp/rust-mode-tests.el b/.emacs.d/lisp/rust-mode-tests.el index 259afb2..c8e3e9a 100644 --- a/.emacs.d/lisp/rust-mode-tests.el +++ b/.emacs.d/lisp/rust-mode-tests.el @@ -1979,6 +1979,28 @@ this_is_not_a_string();)" "union" font-lock-variable-name-face "bar" font-lock-type-face))) +(ert-deftest rust-test-raw-context-sensitive () + (rust-test-font-lock + "let raw = 7; let foo = &raw const raw; let bar = &raw mut raw;" + '("let" font-lock-keyword-face + ;; The first raw is a variable name. + "raw" font-lock-variable-name-face + "let" font-lock-keyword-face + "foo" font-lock-variable-name-face + "&" rust-ampersand-face + ;; The second raw is a contextual keyword. + "raw" font-lock-keyword-face + "const" font-lock-keyword-face + ;; The third raw is a value. + "let" font-lock-keyword-face + "bar" font-lock-variable-name-face + "&" rust-ampersand-face + ;; The fourth raw is a contextual keyword. + "raw" font-lock-keyword-face + "mut" font-lock-keyword-face + ;; The fifth raw is a value. + ))) + (ert-deftest indent-method-chains-no-align () (let ((rust-indent-method-chain nil)) (test-indent " @@ -3693,6 +3715,7 @@ let b = 1;" (insert "note: `ZZZ` could also refer to the constant imported here -> b\n --> file4.rs:12:34\n\n") (insert " ::: file5.rs:12:34\n\n") (insert "thread 'main' panicked at src/file7.rs:12:34:\n\n") + (insert "thread 'aaa::bbb' (19178688) panicked at crates/a/src/b.rs:13:9:\n\n") (insert "[src/file8.rs:159:5] symbol_value(SOME_VAR) = Some(\n\n") (insert " at file9.rs:12:34\n\n") ;; should not match @@ -3714,7 +3737,8 @@ let b = 1;" (("file5.rs" "12" "34" compilation-info "file5.rs:12:34")) ((like-previous-one "82" back-to-indentation compilation-info "82") (like-previous-one "132" back-to-indentation compilation-info "132")) - (("src/file7.rs" "12" "34" nil "src/file7.rs:12:34")) + (("src/file7.rs" "12" "34" nil "src/file7.rs:12:34") + ("crates/a/src/b.rs" "13" "9" nil "crates/a/src/b.rs:13:9")) (("src/file8.rs" "159" "5" compilation-info "src/file8.rs:159:5")) (("file9.rs" "12" "34" compilation-info "file9.rs:12:34"))) (mapcar #'rust-collect-matches @@ -3809,3 +3833,39 @@ let b = 1;" (string-match "^C-c C" ,match))) t)) (should (< 0 match-count))))) + +;; Toggle mutability tests + +(ert-deftest rust-toggle-mutability-let () + "Test toggling let <-> let mut." + (with-temp-buffer + (rust-mode) + (insert " let x = 5;") + (rust-toggle-mutability) + (should (string= (buffer-string) " let mut x = 5;")) + (rust-toggle-mutability) + (should (string= (buffer-string) " let x = 5;")))) + +(ert-deftest rust-toggle-mutability-ref () + "Test toggling & <-> &mut." + (with-temp-buffer + (rust-mode) + (insert " let y = & x;") + (goto-char (line-end-position)) + (rust-toggle-mutability) + (should (string-match-p "&mut " (buffer-string))) + (goto-char (line-end-position)) + (rust-toggle-mutability) + (should (string-match-p "& x" (buffer-string))))) + +(ert-deftest rust-toggle-mutability-self () + "Test toggling &self <-> &mut self." + (with-temp-buffer + (rust-mode) + (insert " fn foo(&self) {") + (goto-char (line-end-position)) + (rust-toggle-mutability) + (should (string-match-p "&mut self" (buffer-string))) + (goto-char (line-end-position)) + (rust-toggle-mutability) + (should (string-match-p "&self" (buffer-string))))) -- cgit v1.3