|
| 1 | +//! Strict combo oracle probes, batch 119: buffer modification hooks with |
| 2 | +//! invisible text + narrowing + overlays combo, marker tracking through |
| 3 | +//! undo with indirect buffers, and text-property merge edge cases |
| 4 | +//! (front-sticky + rear-nonsticky on same boundary). |
| 5 | +//! |
| 6 | +//! Tests are parity locks unless annotated with a surfaced divergence. |
| 7 | +
|
| 8 | +use super::common::assert_oracle_parity; |
| 9 | +use super::common::return_if_neovm_enable_oracle_proptest_not_set; |
| 10 | + |
| 11 | +#[test] |
| 12 | +fn div_t3_buffer_mod_hooks_invisible_narrow_combo() { |
| 13 | + return_if_neovm_enable_oracle_proptest_not_set!(); |
| 14 | + assert_oracle_parity( |
| 15 | + r####" |
| 16 | +(let ((log nil)) |
| 17 | + (with-temp-buffer |
| 18 | + (insert "visible1 INVISIBLE visible2") |
| 19 | + (let ((o (make-overlay 9 17))) |
| 20 | + (overlay-put o 'invisible t)) |
| 21 | + (add-text-properties 1 8 '(face bold)) |
| 22 | + (add-hook 'before-change-functions |
| 23 | + (lambda (beg end) (push (list 'before beg end) log)) |
| 24 | + nil t) |
| 25 | + (add-hook 'after-change-functions |
| 26 | + (lambda (beg end len) (push (list 'after beg end len) log)) |
| 27 | + nil t) |
| 28 | + (narrow-to-region 1 25) |
| 29 | + (goto-char 20) |
| 30 | + (insert "X") |
| 31 | + (delete-region 2 5) |
| 32 | + (let ((inhibit-modification-hooks t) |
| 33 | + (insert "Y")) |
| 34 | + (push 'inhibited log)) |
| 35 | + (list (buffer-string) |
| 36 | + (buffer-substring-no-properties 1 20) |
| 37 | + (length (nreverse log)) |
| 38 | + (point-min) |
| 39 | + (point-max)))) |
| 40 | +"####, |
| 41 | + ); |
| 42 | +} |
| 43 | + |
| 44 | +#[test] |
| 45 | +fn div_t3_marker_undo_indirect_buffer() { |
| 46 | + return_if_neovm_enable_oracle_proptest_not_set!(); |
| 47 | + assert_oracle_parity( |
| 48 | + r####" |
| 49 | +(let* ((base (get-buffer-create " *probe-mu-base*")) |
| 50 | + (ind (make-indirect-buffer base " *probe-mu-ind*")) |
| 51 | + (m-base (make-marker)) |
| 52 | + (m-ind (make-marker))) |
| 53 | + (unwind-protect |
| 54 | + (progn |
| 55 | + (with-current-buffer base |
| 56 | + (buffer-enable-undo) |
| 57 | + (insert "abcdefghijklmno") |
| 58 | + (set-marker m-base 5) |
| 59 | + (undo-boundary)) |
| 60 | + (with-current-buffer ind |
| 61 | + (set-marker m-ind 10) |
| 62 | + (narrow-to-region 3 13) |
| 63 | + (goto-char 7) |
| 64 | + (undo-boundary) |
| 65 | + (delete-region 5 8) |
| 66 | + (list (marker-position m-base) |
| 67 | + (marker-position m-ind) |
| 68 | + (buffer-string) |
| 69 | + (eq (marker-buffer m-base) base) |
| 70 | + (eq (marker-buffer m-ind) ind))) |
| 71 | + (with-current-buffer base |
| 72 | + (undo) |
| 73 | + (list (marker-position m-base) |
| 74 | + (buffer-string)))) |
| 75 | + (when (buffer-live-p ind) (kill-buffer ind)) |
| 76 | + (when (buffer-live-p base) (kill-buffer base)))) |
| 77 | +"####, |
| 78 | + ); |
| 79 | +} |
| 80 | + |
| 81 | +#[test] |
| 82 | +fn div_t3_text_property_merge_boundary_stickiness() { |
| 83 | + return_if_neovm_enable_oracle_proptest_not_set!(); |
| 84 | + assert_oracle_parity( |
| 85 | + r####" |
| 86 | +(with-temp-buffer |
| 87 | + (insert "abcdefghijklmno") |
| 88 | + (add-text-properties 1 5 '(face bold front-sticky nil rear-nonsticky (face))) |
| 89 | + (add-text-properties 6 10 '(face italic front-sticky (face) rear-nonsticky nil)) |
| 90 | + (add-text-properties 11 15 '(face underline)) |
| 91 | + (goto-char 5) |
| 92 | + (insert "X") |
| 93 | + (goto-char 11) |
| 94 | + (insert "Y") |
| 95 | + (list (buffer-string) |
| 96 | + (text-properties-at 4) |
| 97 | + (text-properties-at 6) |
| 98 | + (text-properties-at 7) |
| 99 | + (text-properties-at 11) |
| 100 | + (text-properties-at 13) |
| 101 | + (get-text-property 6 'face) |
| 102 | + (get-text-property 7 'face))) |
| 103 | +"####, |
| 104 | + ); |
| 105 | +} |
| 106 | + |
| 107 | +#[test] |
| 108 | +fn div_t3_overlay_invisible_search_replace_combo() { |
| 109 | + return_if_neovm_enable_oracle_proptest_not_set!(); |
| 110 | + assert_oracle_parity( |
| 111 | + r####" |
| 112 | +(with-temp-buffer |
| 113 | + (insert "find REPLACE1 hidden REPLACE2 find") |
| 114 | + (let ((o (make-overlay 16 24))) |
| 115 | + (overlay-put o 'invisible t)) |
| 116 | + (goto-char 1) |
| 117 | + (let (positions) |
| 118 | + (while (search-forward "REPLACE" nil t) |
| 119 | + (push (match-beginning 0) positions) |
| 120 | + (replace-match "DONE")) |
| 121 | + (list (nreverse positions) |
| 122 | + (buffer-string) |
| 123 | + (buffer-substring 1 30) |
| 124 | + (overlays-in 1 30) |
| 125 | + (length (overlays-in 1 30))))) |
| 126 | +"####, |
| 127 | + ); |
| 128 | +} |
0 commit comments