diff options
| author | Christophe Troestler <Christophe.Troestler@umons.ac.be> | 2021-12-27 12:12:56 +0100 |
|---|---|---|
| committer | Christophe Troestler <Christophe.Troestler@umons.ac.be> | 2021-12-27 19:58:26 +0100 |
| commit | 2d4d2d2722db0ed589f4ba9e7b9ded4bee45eec7 (patch) | |
| tree | 66cb9487e9ab413e5fb8ff26126349745211496e /rust-mode-tests.el | |
| parent | a56e65c984feb814420a64de95522fd6e228fbca (diff) | |
| download | rust-mode-2d4d2d2722db0ed589f4ba9e7b9ded4bee45eec7.tar.gz | |
Add tests to check the syntax highlighting of &
Diffstat (limited to 'rust-mode-tests.el')
| -rw-r--r-- | rust-mode-tests.el | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/rust-mode-tests.el b/rust-mode-tests.el index 24c2682..0d9f06b 100644 --- a/rust-mode-tests.el +++ b/rust-mode-tests.el @@ -1354,6 +1354,92 @@ list of substrings of `STR' each followed by its face." "mut" font-lock-keyword-face "bar" font-lock-variable-name-face))) +(ert-deftest font-lock-ampersand () + (rust-test-font-lock + "f(&a)" + '("&" rust-ampersand-face)) + (rust-test-font-lock + "a && b &&& c" + nil) + (rust-test-font-lock + "&'a v" + '("&" rust-ampersand-face + "a" font-lock-variable-name-face)) + (rust-test-font-lock + "&'static v" + '("&" rust-ampersand-face + "static" font-lock-keyword-face)) + (rust-test-font-lock + "&mut v" + '("&" rust-ampersand-face + "mut" font-lock-keyword-face)) + (rust-test-font-lock + "&f(&x)" + '("&" rust-ampersand-face + "&" rust-ampersand-face)) + (rust-test-font-lock + "fn f(x: &X)" + '("fn" font-lock-keyword-face + "f" font-lock-function-name-face + "x" font-lock-variable-name-face + "&" rust-ampersand-face + "X" font-lock-type-face)) + (rust-test-font-lock + "f(&X{x})" + '("&" rust-ampersand-face + "X" font-lock-type-face)) + (rust-test-font-lock + "let x: &'_ f64 = &1.;" + '("let" font-lock-keyword-face + "x" font-lock-variable-name-face + "&" rust-ampersand-face + "_" font-lock-variable-name-face + "f64" font-lock-type-face + "&" rust-ampersand-face)) + (rust-test-font-lock + "let x = &&1;" + '("let" font-lock-keyword-face + "x" font-lock-variable-name-face + "&&" rust-ampersand-face)) + (rust-test-font-lock + "let x = &*y;" + '("let" font-lock-keyword-face + "x" font-lock-variable-name-face + "&" rust-ampersand-face)) + (rust-test-font-lock + "let x = &::std::f64::consts::PI;" + '("let" font-lock-keyword-face + "x" font-lock-variable-name-face + "&" rust-ampersand-face + "std" font-lock-constant-face + "f64" font-lock-type-face + "consts" font-lock-constant-face + "PI" font-lock-type-face)) + (rust-test-font-lock + "let x = &(1, 2);" + '("let" font-lock-keyword-face + "x" font-lock-variable-name-face + "&" rust-ampersand-face)) + (rust-test-font-lock + "let x = &{1};" + '("let" font-lock-keyword-face + "x" font-lock-variable-name-face + "&" rust-ampersand-face)) + (rust-test-font-lock + "let f = &|x| {x + 1};" + '("let" font-lock-keyword-face + "f" font-lock-variable-name-face + "&" rust-ampersand-face)) + (rust-test-font-lock + "let x: &_ = &1;" + '("let" font-lock-keyword-face + "x" font-lock-variable-name-face + "&" rust-ampersand-face + "&" rust-ampersand-face)) + (rust-test-font-lock + "&[1,2]" + '("&" rust-ampersand-face))) + (ert-deftest font-lock-if-let-binding () (rust-test-font-lock "if let Some(var) = some_var { /* no-op */ }" |
