|
| 1 | +;;; clojure-ts-mode-navigation-test.el --- Clojure[TS] Mode: code navigation test suite -*- lexical-binding: t; -*- |
| 2 | + |
| 3 | +;; Copyright (C) 2025 Roman Rudakov |
| 4 | + |
| 5 | +;; Author: Roman Rudakov <rrudakov@fastmail.com> |
| 6 | + |
| 7 | +;; This program is free software; you can redistribute it and/or modify |
| 8 | +;; it under the terms of the GNU General Public License as published by |
| 9 | +;; the Free Software Foundation, either version 3 of the License, or |
| 10 | +;; (at your option) any later version. |
| 11 | + |
| 12 | +;; This program is distributed in the hope that it will be useful, |
| 13 | +;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | +;; GNU General Public License for more details. |
| 16 | + |
| 17 | +;; You should have received a copy of the GNU General Public License |
| 18 | +;; along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 19 | + |
| 20 | +;;; Commentary: |
| 21 | + |
| 22 | +;; Verify that Emacs' built-in navigation commands work as expected. |
| 23 | + |
| 24 | +;;; Code: |
| 25 | + |
| 26 | +(require 'clojure-ts-mode) |
| 27 | +(require 'buttercup) |
| 28 | +(require 'test-helper "test/test-helper") |
| 29 | + |
| 30 | +(describe "function literals" |
| 31 | + (describe "forward-sexp" |
| 32 | + (when-refactoring-with-point-it "should navigate to a closing paren if point is before an opening paren" |
| 33 | + "#|(-> (.-value (.-target %)))" |
| 34 | + "#(-> (.-value (.-target %)))|" |
| 35 | + (forward-sexp)) |
| 36 | + (when-refactoring-with-point-it "should navigate to a closing paren if point is before a # character" |
| 37 | + "|#(-> (.-value (.-target %)))" |
| 38 | + "#(-> (.-value (.-target %)))|" |
| 39 | + (forward-sexp))) |
| 40 | + |
| 41 | + (describe "backward-up-list" |
| 42 | + (when-refactoring-with-point-it "should navigate to the beginning of a parent expression" |
| 43 | + "#(-> |(.-value (.-target %)))" |
| 44 | + "|#(-> (.-value (.-target %)))" |
| 45 | + (backward-up-list))) |
| 46 | + |
| 47 | + (describe "raise-sexp" |
| 48 | + (when-refactoring-with-point-it "should keep balanced parenthesis" |
| 49 | + "#(-> |(.-value (.-target %)))" |
| 50 | + "|(.-value (.-target %))" |
| 51 | + (raise-sexp)))) |
| 52 | + |
| 53 | +(describe "sets" |
| 54 | + (describe "forward-sexp" |
| 55 | + (when-refactoring-with-point-it "should navigate to a closing paren if point is before an opening paren" |
| 56 | + "#|{1 2 3}" |
| 57 | + "#{1 2 3}|" |
| 58 | + (forward-sexp)) |
| 59 | + (when-refactoring-with-point-it "should navigate to a closing paren if point is before a # character" |
| 60 | + "|#{1 2 3}" |
| 61 | + "#{1 2 3}|" |
| 62 | + (forward-sexp))) |
| 63 | + |
| 64 | + (describe "backward-up-list" |
| 65 | + (when-refactoring-with-point-it "should navigate to the beginning of a parent expression" |
| 66 | + "#{1 |2 3}" |
| 67 | + "|#{1 2 3}" |
| 68 | + (backward-up-list))) |
| 69 | + |
| 70 | + (describe "raise-sexp" |
| 71 | + (when-refactoring-with-point-it "should not keep unwanted characters" |
| 72 | + "#{1 |2 3}" |
| 73 | + "|2" |
| 74 | + (raise-sexp)))) |
| 75 | + |
| 76 | +(describe "nodes with metadata" |
| 77 | + (describe "forward-sexp" |
| 78 | + (when-refactoring-with-point-it "should navigate to a closing paren if point is before an opening paren" |
| 79 | + "^String |[arg]" |
| 80 | + "^String [arg]|" |
| 81 | + (forward-sexp)) |
| 82 | + ;; This is not perfect, but with the current grammar we cannot handle it better. |
| 83 | + (when-refactoring-with-point-it "should naigate to a closing paren if point is before metadata" |
| 84 | + "|^String [arg]" |
| 85 | + "^String [arg]|" |
| 86 | + (forward-sexp)))) |
| 87 | + |
| 88 | +(provide 'clojure-ts-mode-navigation-test) |
| 89 | +;;; clojure-ts-mode-navigation-test.el ends here |
0 commit comments