Skip to content

Commit 4d651ab

Browse files
authored
Merge pull request #197 from tromey/syntax-propertize
Syntax propertize
2 parents a436945 + ee7043b commit 4d651ab

File tree

2 files changed

+109
-287
lines changed

2 files changed

+109
-287
lines changed

rust-mode-tests.el

Lines changed: 2 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,6 @@ very very very long string
309309
deindented
310310
1
311311
(lambda ()
312-
;; The indentation will fail in some cases if the syntax properties are
313-
;; not set. This only happens when font-lock fontifies the buffer.
314-
(font-lock-fontify-buffer)
315312
(indent-region 1 (+ 1 (buffer-size))))
316313
indented)))
317314

@@ -951,7 +948,7 @@ Convert the line-column information from that list into a buffer position value.
951948

952949
;;; FIXME: Maybe add an ERT explainer function (something that shows the
953950
;;; surrounding code of the final point, not just the position).
954-
(defun rust-test-motion (source-code init-pos final-pos manip-func &optional &rest args)
951+
(defun rust-test-motion (source-code init-pos final-pos manip-func &rest args)
955952
"Test that MANIP-FUNC moves point from INIT-POS to FINAL-POS.
956953
957954
If ARGS are provided, send them to MANIP-FUNC.
@@ -960,12 +957,11 @@ INIT-POS, FINAL-POS are position symbols found in `rust-test-positions-alist'."
960957
(with-temp-buffer
961958
(rust-mode)
962959
(insert source-code)
963-
(font-lock-fontify-buffer)
964960
(goto-char (rust-get-buffer-pos init-pos))
965961
(apply manip-func args)
966962
(should (equal (point) (rust-get-buffer-pos final-pos)))))
967963

968-
(defun rust-test-region (source-code init-pos reg-beg reg-end manip-func &optional &rest args)
964+
(defun rust-test-region (source-code init-pos reg-beg reg-end manip-func &rest args)
969965
"Test that MANIP-FUNC marks region from REG-BEG to REG-END.
970966
971967
INIT-POS is the initial position of point.
@@ -974,7 +970,6 @@ All positions are position symbols found in `rust-test-positions-alist'."
974970
(with-temp-buffer
975971
(rust-mode)
976972
(insert source-code)
977-
(font-lock-fontify-buffer)
978973
(goto-char (rust-get-buffer-pos init-pos))
979974
(apply manip-func args)
980975
(should (equal (list (region-beginning) (region-end))
@@ -1377,24 +1372,6 @@ this_is_not_a_string();)"
13771372
"r\" this is a comment\n" font-lock-comment-face
13781373
"\"this is a string\"" font-lock-string-face)))
13791374

1380-
(ert-deftest font-lock-raw-string-constant ()
1381-
;; There was an issue in which a multi-line raw string would be fontified
1382-
;; correctly if inserted, but then incorrectly if one of the lines was then
1383-
;; edited. This test replicates how font-lock responds when text in the
1384-
;; buffer is modified in order to reproduce it.
1385-
(with-temp-buffer
1386-
(rust-mode)
1387-
(font-lock-fontify-buffer)
1388-
(insert "const BOO:&str = r#\"\nBOO\"#;")
1389-
(beginning-of-buffer)
1390-
(insert " ")
1391-
(font-lock-after-change-function 1 2 0)
1392-
1393-
(should (equal 'font-lock-string-face (get-text-property 19 'face))) ;; Opening "r" of raw string
1394-
(should (equal 'font-lock-string-face (get-text-property 27 'face))) ;; Closing "#" of raw string
1395-
(should (equal nil (get-text-property 28 'face))) ;; Semicolon--should not be part of the string
1396-
))
1397-
13981375
(ert-deftest font-lock-runaway-raw-string ()
13991376
(rust-test-font-lock
14001377
"const Z = r#\"my raw string\";\n// oops this is still in the string"
@@ -2567,34 +2544,6 @@ type Foo<T> where T: Copy = Box<T>;
25672544
'(7 9))))
25682545

25692546

2570-
(ert-deftest font-lock-extend-region-in-string ()
2571-
2572-
(with-temp-buffer
2573-
(rust-mode)
2574-
(insert "
2575-
fn foo() {
2576-
let x = r\"
2577-
Fontification needs to include this whole string or none of it.
2578-
\"
2579-
}")
2580-
(font-lock-fontify-buffer)
2581-
(let ((font-lock-beg 13)
2582-
(font-lock-end 42))
2583-
(rust-font-lock-extend-region)
2584-
(should (<= font-lock-beg 13))
2585-
(should (>= font-lock-end 106))
2586-
)
2587-
(let ((font-lock-beg 42)
2588-
(font-lock-end 108))
2589-
(rust-font-lock-extend-region)
2590-
(should (<= font-lock-beg 25))
2591-
(should (>= font-lock-end 108)))
2592-
(let ((font-lock-beg 1)
2593-
(font-lock-end 12))
2594-
(rust-font-lock-extend-region)
2595-
(should (<= font-lock-beg 1))
2596-
(should (>= font-lock-end 12)))))
2597-
25982547
(ert-deftest redo-syntax-after-change-far-from-point ()
25992548
(let*
26002549
((tmp-file-name (make-temp-file "rust-mdoe-test-issue104"))
@@ -2618,18 +2567,6 @@ Fontification needs to include this whole string or none of it.
26182567
)
26192568
)
26202569

2621-
(ert-deftest rust-test-revert-hook-preserves-point ()
2622-
(with-temp-buffer
2623-
;; Insert some code, and put point in the middle.
2624-
(insert "fn foo() {}\n")
2625-
(insert "fn bar() {}\n")
2626-
(insert "fn baz() {}\n")
2627-
(goto-char (point-min))
2628-
(forward-line 1)
2629-
(let ((initial-point (point)))
2630-
(rust--after-revert-hook)
2631-
(should (equal initial-point (point))))))
2632-
26332570
(defun test-imenu (code expected-items)
26342571
(with-temp-buffer
26352572
(rust-mode)

0 commit comments

Comments
 (0)