|
22 | 22 | (should (custom-variable-p 'netlinx-mode-grammar-location)) |
23 | 23 | (should (custom-variable-p 'netlinx-mode-grammar-version)) |
24 | 24 | (should (custom-variable-p 'netlinx-mode-help-file)) |
| 25 | + (should (custom-variable-p 'netlinx-mode-indent-offset)) |
25 | 26 | (should (stringp netlinx-mode-grammar-location)) |
26 | | - (should (stringp netlinx-mode-grammar-version))) |
| 27 | + (should (stringp netlinx-mode-grammar-version)) |
| 28 | + (should (integerp netlinx-mode-indent-offset)) |
| 29 | + (should (= netlinx-mode-indent-offset 4))) |
27 | 30 |
|
28 | 31 | ;;; Face Tests |
29 | 32 |
|
|
122 | 125 | "Test that the package provides the netlinx-mode feature." |
123 | 126 | (should (featurep 'netlinx-mode))) |
124 | 127 |
|
| 128 | +;;; Indentation Tests |
| 129 | + |
| 130 | +(ert-deftest netlinx-mode-test-indent-rules-defined () |
| 131 | + "Test that indentation rules are defined." |
| 132 | + (should (boundp 'netlinx-mode--indent-rules)) |
| 133 | + (should (listp netlinx-mode--indent-rules)) |
| 134 | + (should (assq 'netlinx netlinx-mode--indent-rules))) |
| 135 | + |
| 136 | +(ert-deftest netlinx-mode-test-indent-offset-safe () |
| 137 | + "Test that indent-offset has a safety predicate." |
| 138 | + (should (get 'netlinx-mode-indent-offset 'safe-local-variable)) |
| 139 | + (should (funcall (get 'netlinx-mode-indent-offset 'safe-local-variable) 4)) |
| 140 | + (should (funcall (get 'netlinx-mode-indent-offset 'safe-local-variable) 2)) |
| 141 | + (should-not (funcall (get 'netlinx-mode-indent-offset 'safe-local-variable) "not-a-number"))) |
| 142 | + |
| 143 | +(ert-deftest netlinx-mode-test-indent-configuration () |
| 144 | + "Test that indentation is configured when mode is activated." |
| 145 | + (with-temp-buffer |
| 146 | + (cl-letf (((symbol-function 'netlinx-mode--ensure-grammar) #'ignore) |
| 147 | + ((symbol-function 'treesit-ready-p) (lambda (&rest _) t)) |
| 148 | + ((symbol-function 'treesit-parser-create) #'ignore) |
| 149 | + ((symbol-function 'treesit-major-mode-setup) #'ignore)) |
| 150 | + (netlinx-mode) |
| 151 | + (should (local-variable-p 'treesit-simple-indent-rules)) |
| 152 | + (should (eq treesit-simple-indent-rules netlinx-mode--indent-rules))))) |
| 153 | + |
| 154 | +;;; Comment Configuration Tests |
| 155 | + |
| 156 | +(ert-deftest netlinx-mode-test-comment-start () |
| 157 | + "Test that comment-start is configured correctly." |
| 158 | + (with-temp-buffer |
| 159 | + (cl-letf (((symbol-function 'netlinx-mode--ensure-grammar) #'ignore) |
| 160 | + ((symbol-function 'treesit-ready-p) (lambda (&rest _) t)) |
| 161 | + ((symbol-function 'treesit-parser-create) #'ignore) |
| 162 | + ((symbol-function 'treesit-major-mode-setup) #'ignore)) |
| 163 | + (netlinx-mode) |
| 164 | + (should (local-variable-p 'comment-start)) |
| 165 | + (should (string= comment-start "// "))))) |
| 166 | + |
| 167 | +(ert-deftest netlinx-mode-test-comment-end () |
| 168 | + "Test that comment-end is configured correctly." |
| 169 | + (with-temp-buffer |
| 170 | + (cl-letf (((symbol-function 'netlinx-mode--ensure-grammar) #'ignore) |
| 171 | + ((symbol-function 'treesit-ready-p) (lambda (&rest _) t)) |
| 172 | + ((symbol-function 'treesit-parser-create) #'ignore) |
| 173 | + ((symbol-function 'treesit-major-mode-setup) #'ignore)) |
| 174 | + (netlinx-mode) |
| 175 | + (should (local-variable-p 'comment-end)) |
| 176 | + (should (string= comment-end ""))))) |
| 177 | + |
| 178 | +(ert-deftest netlinx-mode-test-comment-start-skip () |
| 179 | + "Test that comment-start-skip is configured correctly." |
| 180 | + (with-temp-buffer |
| 181 | + (cl-letf (((symbol-function 'netlinx-mode--ensure-grammar) #'ignore) |
| 182 | + ((symbol-function 'treesit-ready-p) (lambda (&rest _) t)) |
| 183 | + ((symbol-function 'treesit-parser-create) #'ignore) |
| 184 | + ((symbol-function 'treesit-major-mode-setup) #'ignore)) |
| 185 | + (netlinx-mode) |
| 186 | + (should (local-variable-p 'comment-start-skip)) |
| 187 | + (should (stringp comment-start-skip))))) |
| 188 | + |
125 | 189 | (provide 'netlinx-mode-test) |
126 | 190 |
|
127 | 191 | ;;; netlinx-mode-test.el ends here |
0 commit comments