Skip to content

Commit

Permalink
Add mode tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
brownts committed Aug 31, 2024
1 parent fefec00 commit 63dec06
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/gpr-ts-mode-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,23 @@ there is no error in the parse tree."
(beginning-of-line)))
(indent-region (point-min) (point-max)))

(defun mode-transform (&optional version)
"Mode transform function for test.
If VERSION is nil, the expected mode is \\='gpr-ts-mode\\='. If VERSION
is not nil, for an Emacs major version at or above VERSION, the expected
mode is \\='gpr-ts-mode\\=', otherwise the expected mode is
\\='fundamental-mode\\='."
(let ((inhibit-message t) ; Suppress 'Ignoring unknown mode ...'.
(expected-mode
(cond (version
(if (>= emacs-major-version version)
'gpr-ts-mode
'fundamental-mode))
(t 'gpr-ts-mode))))
(set-auto-mode)
(should (eq major-mode expected-mode))))

(defun navigation-transform (binding &optional arg)
"Navigation transform function for test.
Expand Down
39 changes: 39 additions & 0 deletions test/resources/mode.erts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Code: mode-transform

Name: Mode on first line (gpr-ts)

=-=
-- -*- mode: gpr-ts -*-
abstract project Test is
end Test;
=-=-=

Name: Mode in local variable (gpr-ts)

=-=
abstract project Test is
end Test;
-- Local Variables:
-- mode: gpr-ts
-- End:
=-=-=

Code: (lambda () (mode-transform 30))

Name: Mode on first line (gpr)

=-=
-- -*- mode: gpr -*-
abstract project Test is
end Test;
=-=-=

Name: Mode in local variable (gpr)

=-=
abstract project Test is
end Test;
-- Local Variables:
-- mode: gpr
-- End:
=-=-=

0 comments on commit 63dec06

Please sign in to comment.