Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge clojure-mode tests into clojure-ts-mode #57

Merged
merged 209 commits into from
Oct 31, 2024
Merged
Changes from all commits
Commits
Show all changes
209 commits
Select commit Hold shift + click to select a range
8f214c9
Lay the groundwork of a test suite
bbatsov May 30, 2014
a1ecf40
Make it possible to check a range for a specific face
bbatsov May 30, 2014
38c4b4d
Add a couple more font-lock tests
bbatsov Jun 7, 2014
9c08ad2
Font-lock lambda params (%, %1, %2, etc)
bbatsov Jun 8, 2014
d4dbbdf
Fix font-locking bug for namespaced definitions
Jun 9, 2014
196d8d4
Add missing require
Jun 9, 2014
2f21638
Use different font-locking for "variables", types and functions
Jun 9, 2014
5f268e1
Font lock static method calls like SomeClass/someMethod
Jun 11, 2014
4aa8c8d
Font-lock SNAKE_CASE constants
Jun 11, 2014
1227c53
Correct the boundaries of nil/true/false font-locking
Jun 13, 2014
d50c5db
Add a couple of font-locking tests
Jun 13, 2014
badb6f2
Font-lock character literals
bbatsov Jun 16, 2014
1a9b88b
Font-lock cljx features
Jul 16, 2014
fa63ec4
Introduce a few custom faces for things not covered by the standard
Jul 21, 2014
ff01ae5
Fix font-locking of namespaced constructor calls
Aug 4, 2014
e3b81aa
Indentation fixes
Aug 4, 2014
43d7203
Simplify font-locking of types used as type hints
Aug 4, 2014
699c3b2
Refine keyword literals font-locking
Aug 4, 2014
d71ff52
Improve namespace font-locking
Aug 12, 2014
001ee7d
Fix the font-lock of interop calls like getX
Aug 13, 2014
4f64415
Font lock properly fully qualified type hints
bbatsov Aug 21, 2014
a8b250f
@(dynamic)variable shouldn't break fontlock
tanzoniteblack Aug 21, 2014
49ee7f8
Improve font-locking of punctuation characters
Aug 22, 2014
90d3a43
Fix font-locking of single-segment names in ns macro
Sep 2, 2014
e569ab8
Fix a ns font-locking bug
Sep 19, 2014
ef7cbf3
Font-lock properly fully-qualified static method invocations
Sep 21, 2014
0267302
Code style
Sep 21, 2014
e03cb1f
Fix the font-locking of classes in scenarios like URLDecoder/decode
Nov 1, 2014
a4dc62c
Update the copyright years
bbatsov Jan 10, 2015
1b7a61d
[Fix #274] Correct font-locking of punctuation character literals
Mar 5, 2015
697b547
Merge pull request #279 from m00nlight/font-lock-punct
bbatsov Mar 5, 2015
c1c4628
Fix font-locking of namespace-prefixed dynamic vars
bbatsov Mar 15, 2015
73f2635
[Fix #271] Add indentation tests
bbatsov May 17, 2015
ac2ae95
Rename clojure-mode-test.el to clojure-mode-font-lock-test.el
bbatsov May 17, 2015
e98c459
Fix doctring indentation issue in #241
sandhu Apr 27, 2015
9e13a00
Add tests and documentation for the indentation config changes
bbatsov Jun 20, 2015
009c639
Implement commands for navigating over logical sexps
Malabarba Jun 30, 2015
a9fc8cb
Fix font-locking tests
bbatsov Jul 22, 2015
ccf307e
[Fix #310,#311] clojure-expected-ns with src/cljc
expez Jul 29, 2015
c855d1e
Fix for error in `clojure-expected-ns`
Jul 30, 2015
eecf34e
Handle properly def* symbols, containing special chars
BrunoBonacci Aug 3, 2015
b0d3ed2
Merge pull request #316 from BrunoBonacci/fix-font-locking
bbatsov Aug 3, 2015
34658f0
[Fix #304] Indentation of forms with metadata specs
Malabarba Sep 10, 2015
db77aa7
[Fix #308 Fix #287 Fix #45] Corner-case indentation of multi-line sexps
Malabarba Sep 10, 2015
29ce149
[Fix #292] Indentation in reader conditionals
Malabarba Sep 10, 2015
fe0659d
[Fix #278] Understand namespace aliases in backtracking indent
Malabarba Sep 10, 2015
b708c7f
Rewrite the indent logic
Malabarba Sep 12, 2015
e5b6783
[Fix clojure-emacs/cider#1323] Sexp navigation near end of buffer
Malabarba Sep 15, 2015
bf62b1b
[Fix #325] Fix indent for spliced reader conditionals
Malabarba Sep 28, 2015
1018c6e
Font-lock namespaced keywords
Malabarba Sep 29, 2015
0882089
Merge pull request #326 from Malabarba/master
bbatsov Oct 1, 2015
a7609cf
[Fix #327] Indentation of a lonely close paren
Malabarba Oct 1, 2015
c1e84d0
[Fix #327] Indentation when a symbol ends in ? or '
Malabarba Oct 1, 2015
552edf7
[Fix #331] Indentation in buffers without a final newline
Malabarba Oct 13, 2015
c8b0551
Add regression tests for function specs
Malabarba Oct 19, 2015
9a1415c
[Fix #336] Fix empty indent tests
Malabarba Oct 25, 2015
279d464
Add a regression test for #335
Malabarba Oct 25, 2015
d816314
[Fix #338] Font-locking of stuff in backticks
Malabarba Oct 25, 2015
51bf899
Fix void-function in tests
Malabarba Oct 25, 2015
1b98911
[Fix #315] Indentation of unfinished sexps
Malabarba Oct 25, 2015
f9e7bdf
Fix tests broken by the / font-lock
Malabarba Oct 25, 2015
077e349
Improve clojure-find-def matching (support hyphens)
maio Oct 13, 2015
2adbe28
Merge pull request #333 from maio/patch-2
bbatsov Oct 26, 2015
358f9b7
Use cl-evenp in one of the tests
bbatsov Oct 26, 2015
a33c3e2
Don't treat the symbol default as def* macro.
Malabarba Nov 8, 2015
bff5ddc
[Fix #344] Indentation for extend-type
Malabarba Nov 8, 2015
ebf33a3
Add a test for namespaced default* symbols
Malabarba Nov 10, 2015
b4e8a20
[Fix #349] Indent and font-lock (let|when|while)-* forms
Malabarba Nov 27, 2015
0534a3e
Document indentation and font-locking of (let|when|while)-* forms
Malabarba Nov 27, 2015
18fd667
Make the ns regexp more permissive
Nov 26, 2015
89f18b3
Namespace font-locking according to clojure.lang.LispReader
Bost Nov 30, 2015
8e32037
[Fix #277] Apply font-lock-comment-face to #_
Malabarba Dec 7, 2015
3a6ce6b
[Fix #355] Font-lock properly single-char ns aliases
bbatsov Dec 13, 2015
0fda86e
[Fix #356] defprotocol docstring indentation
Malabarba Dec 29, 2015
2213197
Implement alignment of binding forms and map literals
Malabarba Nov 17, 2015
1ddadce
Update the copyright years
bbatsov Jan 2, 2016
59f4cdc
Add indentation tests for `specify` and `specify!`
bbatsov Jan 3, 2016
cfdf1c4
[Fix #360] Reindent after aligning
Malabarba Jan 16, 2016
3ec544c
Fix a stupid failing test
Malabarba Jan 16, 2016
e7749f5
Remove redundant file-local variables
bbatsov Jan 16, 2016
0027331
Fix the nil case for align tests
Malabarba Jan 16, 2016
8f111a5
[Fix #360] Convert END to a marker in clojure-align
Malabarba Jan 16, 2016
e60d0a7
[Fix #362] Define a custom option clojure-indent-style
Malabarba Jan 24, 2016
39262ae
[#361] Add a regression test
bbatsov Jan 29, 2016
0e671ec
Add a test for %& font-locking
Malabarba Jan 30, 2016
09abee8
Add a test for proxy indentation
Malabarba Feb 29, 2016
f196516
Add a test for the previous fix
Malabarba Mar 15, 2016
10c3591
Add a test case
arrdem Mar 27, 2016
35062b4
Make clojure-align cleanup commas
Malabarba Mar 28, 2016
44beeb0
Fix a silly test
Malabarba Mar 28, 2016
317b740
Add a test for align separation and fix the feature
Malabarba Apr 13, 2016
55b6fe7
Add tests for the escape char font-locking
Malabarba Apr 30, 2016
f199d20
Add threading macros related refactorings
benedekfazekas Apr 26, 2016
f2fb35b
Standardize threading tests
Malabarba May 11, 2016
da449f6
Fix dangling parens in more scenarios
Malabarba May 11, 2016
203c18a
Fix the test macro to support find-func
Malabarba May 11, 2016
8fa3e1f
Preserve previously removed line-breaks when unwinding
Malabarba May 11, 2016
c8ec6e7
Improve line-break handling with thread/unwind-first
Malabarba May 11, 2016
9c98734
Add a test for ns-sort
Malabarba May 13, 2016
f937471
Add cycling privacy, collection type, if/if-not
benedekfazekas May 15, 2016
294714b
Fix bug when passing lambda to define-clojure-indent, closes #383
arichiardi Jun 15, 2016
7e8a322
Merge pull request #384 from arichiardi/fix-lambda
Malabarba Jun 15, 2016
71b21c3
Fix multi-airty indention of deftype & defrecord (#389) (#390)
bpoweski Jun 27, 2016
4599b47
Add indentation rule for definterface (#395)
Jul 23, 2016
99b7412
Add tests for correct treatment of prefix syntax
vspinu Jul 23, 2016
ce815f9
Create separate clojure-mode-syntax-test suite
vspinu Jul 23, 2016
29ba69e
[Fix #399] Fix font-locking of prefix characters inside keywords (#401)
vspinu Aug 2, 2016
cbbf18a
Port let related refactorings from clj-refactor.el
benedekfazekas Oct 17, 2016
02f027d
Add a command to toggle between when and when-not
bbatsov Jan 21, 2017
7e23196
Add a command to toggle negation for an expression
bbatsov Jan 21, 2017
c76435b
Update the copyright years
bbatsov Mar 4, 2017
ef300cc
[Fix #429] Last occurrence sometimes not replaced for `move-to-let` (…
benedekfazekas Apr 7, 2017
18d6f4f
Remove ; from paragraph-start regexp during fill (#434)
vspinu Jun 9, 2017
0dfbdcc
Add byte-comp and `checkdoc` tests
xiongtx Jul 23, 2017
f92e7a9
Add doc-string tests
vspinu Aug 5, 2017
fb88b3b
Move to top-level before `re-search-backward` in `clojure-find-ns`
xiongtx Oct 31, 2017
5e5dbef
Bump the copyright years
bbatsov Jan 14, 2018
8cb9775
Drop support for cljx
bbatsov Jan 21, 2018
c0c74f6
[Fix #471] Add support for tagged maps (#472)
emoses Mar 12, 2018
b2f207f
Comment out failing tests
Bost Nov 19, 2017
32694c2
Numerous font-locking fixes and improvements
Bost Nov 6, 2017
6aa5c4f
Fix font-locking of namespaced keywords
Bost Mar 17, 2018
078cd1e
Fix regression to CIDER's dynamic syntax highlighting #474
Bost Mar 26, 2018
d473dc1
[clojure-emacs/cider#2281] Cache the results of clojure-project-dir
bbatsov May 26, 2018
17238f9
Don't cache ns in the test for clojure-find-ns
bbatsov Jun 26, 2018
07d9cf7
Make `beginning-of-defun` aware of clojure comment form
Aug 12, 2018
2a8e786
Fix bug in end-of-defun
Aug 24, 2018
7ad641e
[Fix #483] Support alignment for reader conditionals (#486)
vemv Aug 27, 2018
5e4ec40
[Fix #489] Inserting parens before comment form doesn't move point (#…
dpsutton Oct 1, 2018
037baeb
Fix font-lock of type hints
vspinu Oct 24, 2018
ec97912
Indent "let", "when" and "while" as function form if not at start (#497)
Macroz Jan 5, 2019
855bc2c
Clean up the indentation config logic
bbatsov Jan 5, 2019
f88c05a
Fix the broken build
bbatsov Jan 5, 2019
2cf589c
Fix font locking for non-alphanumeric chars in dynamic var names
cichli Feb 16, 2019
002a82d
[Fix #506] Makes display version command return the actual version
Feb 25, 2019
58d2421
[Fix comment in #445] Proper font lock for (s/def ::keyword) forms
Feb 25, 2019
4e4b03e
[Fix #508] Correct font-lock for namespaces
Feb 25, 2019
49b6a48
[Fix #445] More accurate font locking for strings in def forms
Feb 25, 2019
1d604db
Merge pull request #509 from carlosgeos/fix-508
cichli Feb 27, 2019
7793a4d
Merge pull request #507 from carlosgeos/fix-506
cichli Feb 27, 2019
fbf55ac
Merge pull request #505 from carlosgeos/fix-445
cichli Feb 27, 2019
5c594ae
[Fix #518] Ignore ns forms inside strings in clojure-find-ns (#519)
Malabarba Mar 25, 2019
b111dfc
[Fix #496] Highlight [[var]] style comments
rpkarlsson Apr 9, 2019
b2d6d39
Add refactoring command `clojure-rename-ns-alias` (#529)
anthonygalea Jul 1, 2019
a126773
[#422] Split def-refactor-test macro into 2 separate macros.
anthonygalea Jul 9, 2019
9c82c78
[#422] Convert tests to buttercup.
anthonygalea Jul 9, 2019
4dcf6b7
[Fix #511] Fix incorrect indentation of namespaced map (#533)
anthonygalea Jul 9, 2019
c629593
[Fix #531] Don't match strings when using `clojure-rename-ns-alias` (…
anthonygalea Jul 10, 2019
e203f91
Remove calls to provide and require for test-helper.
anthonygalea Jul 11, 2019
35bdde4
[Fix #410] Add refactoring: add an arity to a function.
anthonygalea Jul 11, 2019
756d694
Bump the copyright years
bbatsov Jul 12, 2019
9da2f8d
Update changelog and tests for clojure-unwind changes
yuhan0 Jul 16, 2019
93b9e7e
Enhance add arity refactoring (#541)
anthonygalea Jul 25, 2019
c933a4e
Support multiple consecutive reader comments (#_#_a b)
sulami Oct 1, 2019
fad40cc
Update the copyright years
bbatsov Mar 20, 2020
28024c5
update find-ns tests
yuhan0 Mar 19, 2020
fa3389a
[Fix #551] Indent `clojure-align` region before aligning (#552)
kylc Mar 21, 2020
c85c16f
Fix ns detection with namespaces containing numbers
yuhan0 Mar 21, 2020
7b1e9a2
Add tests for new rename-ns-alias functionality
yuhan0 Mar 20, 2020
d39d5d5
Fix bug when renaming ns aliases with common prefixes
yuhan0 Mar 23, 2020
8261674
[Fix #547] Fix character literal regexp (#560)
yuhan0 Mar 26, 2020
7b06524
Add test for quotes in tail of symbols/keywords
yuhan0 Mar 26, 2020
25d8595
Declare indentation spec for test util functions
yuhan0 Mar 23, 2020
d489b27
Add test and changelog entry
yuhan0 Apr 3, 2020
fb436f6
Fix ns detection bug
yuhan0 Apr 5, 2020
e9c328a
Add tests for paredit interaction
yuhan0 Apr 18, 2020
61f1088
Add delete-trailing-whitespace tests
yuhan0 Apr 18, 2020
234cade
Refactor clojure-no-space-after-tag
yuhan0 Apr 18, 2020
04267d8
Add tests for paredit reader tags
yuhan0 Apr 18, 2020
2fa5aae
Move test macros to utils file
yuhan0 Feb 22, 2021
8f08712
add indent spec to when-refactoring-with-point-it
yuhan0 Feb 22, 2021
ef04784
Add tests for toggling ignore forms
yuhan0 Feb 22, 2021
214bf02
Make indentation of special arguments customisable (#582)
hugoduncan Mar 1, 2021
a3c442a
Bump the copyright years
bbatsov Mar 22, 2021
c211a27
Rename ns aliases in selected region (#590)
yuhan0 May 2, 2021
70c1ac6
Fix for character literal font-lock (#588)
rvlo Mar 22, 2021
347dd1f
Mark put-clojure-indent safe for use in .dir-locals.el, etc.
rlbdv Jul 2, 2021
a815ab9
Update my email
bbatsov Nov 10, 2021
748e685
Add refactoring command for converting #() shorthand to (fn ...) (#601)
yuhan0 Nov 19, 2021
c1ae4be
Address some byte-compilation warnings
bbatsov Dec 30, 2021
1f87e5c
[Fix #608] Fix alignment issue involving margin comments.
samwagg Jan 23, 2022
17ecddb
Update indentation tests for consistent style.
samwagg Feb 4, 2022
aae566e
Fix infinite loop when reverse searching for next definition (#624)
OknoLombarda Jul 19, 2022
3727873
[Fix #625] Fix imenu displaying metadata instead of var name (#626)
OknoLombarda Jul 29, 2022
016c7b2
Use constant values instead of variables in clojure-match-next-def te…
OknoLombarda Jul 29, 2022
123e569
[Fix #581] Fix font locking for keywords starting with a number (#628)
OknoLombarda Aug 24, 2022
264c40e
[Fix #377] Fix font locking for def forms (#630)
OknoLombarda Aug 30, 2022
b41b92e
Make function definition regexp only look for 'clojure.core/defn' forms
Sep 3, 2022
0d5ce21
Nbb support
Dec 3, 2022
f5bc38b
Fix infinite loop when opening file containing "comment" (#651)
OknoLombarda Jun 23, 2023
6be228e
Fix clojure-sort-ns with comments in the end (#646)
p4v4n Jun 24, 2023
f9dd268
`clojure-find-ns`: add an option to suppress errors (#654)
vemv Aug 23, 2023
b823f3a
Replace `http` -> `https` everywhere (#655)
vemv Aug 23, 2023
2f834cc
Add and modify tests for checking multiple forms on same line
p4v4n Sep 6, 2023
788cc5a
Fix clojure-find-ns for ns forms preceded by whitespace (#661)
p4v4n Sep 7, 2023
e364228
Make `clojure-find-ns` work when preceded by other forms (#664)
p4v4n Sep 11, 2023
6bccf8c
Use Eldev (#669)
p4v4n Nov 5, 2023
27915a0
Don't highlight vars with colons as keywords (#670)
daveliepmann Nov 24, 2023
29e37c2
[Fix #671] Font-lock properly multi-digit lambda args (#672)
daveliepmann Nov 24, 2023
52c8626
Set lexical-binding in clojure-mode-font-lock-test.el
snogge Mar 5, 2024
897dd6c
Add tests and changelog
yuhan0 May 15, 2024
a49f9e1
Don't use custom logic to find source directory of clojure-mode.el
manphiz Jun 3, 2024
60fbb97
Merge clojure-mode tests into clojure-ts-mode
kommen Oct 30, 2024
a39b4d9
Disable tests merged from clojure-mode for now using eldev
kommen Oct 31, 2024
9f3d759
Merge remote-tracking branch 'origin/main' into add-clojure-mode-tests
kommen Oct 31, 2024
b3817dc
Don't lint tests merged from clojure-mode
kommen Oct 31, 2024
c259d30
Move over remaining test utils from the clojure-mode test-helper
kommen Oct 31, 2024
75349ec
Fix byte compile by excluding tests merged from clojure-mode
kommen Oct 31, 2024
1d7f84d
Move clojure-mode tests into their own directory to better keep track…
kommen Oct 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Eldev
Original file line number Diff line number Diff line change
@@ -25,3 +25,12 @@
enable-local-variables :safe))

(setq eldev-project-main-file "clojure-ts-mode.el")

;; Exclude tests merged from clojure-mode from running, linting and byte compiling
(setf eldev-test-fileset
`(:and ,eldev-test-fileset
(:not "./clojure-mode-tests/*")))
(setf eldev-standard-excludes
`(:or ,eldev-standard-excludes "./clojure-mode-tests/*"))
(setf eldev-lint-ignored-fileset
`(:or ,eldev-lint-ignored-fileset "./clojure-mode-tests/*"))
82 changes: 82 additions & 0 deletions clojure-mode-tests/clojure-mode-convert-collection-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
;;; clojure-mode-convert-collection-test.el --- Clojure Mode: convert collection type -*- lexical-binding: t; -*-

;; Copyright (C) 2016-2021 Benedek Fazekas <benedek.fazekas@gmail.com>

;; This file is not part of GNU Emacs.

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;; The convert collection code originally was implemented
;; as cycling collection type in clj-refactor.el and is the work
;; of the clj-reafctor.el team.

;;; Code:

(require 'clojure-mode)
(require 'buttercup)
(require 'test-helper "test/utils/test-helper")

(describe "clojure-convert-collection-to-map"
(when-refactoring-it "should convert a list to a map"
"(:a 1 :b 2)"
"{:a 1 :b 2}"
(backward-sexp)
(down-list)
(clojure-convert-collection-to-map)))

(describe "clojure-convert-collection-to-vector"
(when-refactoring-it "should convert a map to a vector"
"{:a 1 :b 2}"
"[:a 1 :b 2]"
(backward-sexp)
(down-list)
(clojure-convert-collection-to-vector)))

(describe "clojure-convert-collection-to-set"
(when-refactoring-it "should convert a vector to a set"
"[1 2 3]"
"#{1 2 3}"
(backward-sexp)
(down-list)
(clojure-convert-collection-to-set)))

(describe "clojure-convert-collection-to-list"
(when-refactoring-it "should convert a set to a list"
"#{1 2 3}"
"(1 2 3)"
(backward-sexp)
(down-list)
(clojure-convert-collection-to-list)))

(describe "clojure-convert-collection-to-quoted-list"
(when-refactoring-it "should convert a set to a quoted list"
"#{1 2 3}"
"'(1 2 3)"
(backward-sexp)
(down-list)
(clojure-convert-collection-to-quoted-list)))

(describe "clojure-convert-collection-to-set"
(when-refactoring-it "should convert a quoted list to a set"
"'(1 2 3)"
"#{1 2 3}"
(backward-sexp)
(down-list)
(clojure-convert-collection-to-set)))

(provide 'clojure-mode-convert-collection-test)

;;; clojure-mode-convert-collection-test.el ends here
194 changes: 194 additions & 0 deletions clojure-mode-tests/clojure-mode-cycling-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
;;; clojure-mode-cycling-test.el --- Clojure Mode: cycling things tests -*- lexical-binding: t; -*-

;; Copyright (C) 2016-2021 Benedek Fazekas <benedek.fazekas@gmail.com>

;; This file is not part of GNU Emacs.

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;; The cycling privacy and if/if-not code is ported from
;; clj-refactor.el and the work of the clj-reafctor.el team.

;;; Code:

(require 'clojure-mode)
(require 'buttercup)

(describe "clojure-cycle-privacy"

(when-refactoring-it "should turn a public defn into a private defn"
"(defn add [a b]
(+ a b))"

"(defn- add [a b]
(+ a b))"

(clojure-cycle-privacy))

(when-refactoring-it "should also work from the beginning of a sexp"
"(defn- add [a b]
(+ a b))"

"(defn add [a b]
(+ a b))"

(backward-sexp)
(clojure-cycle-privacy))

(when-refactoring-it "should use metadata when clojure-use-metadata-for-privacy is set to true"
"(defn add [a b]
(+ a b))"

"(defn ^:private add [a b]
(+ a b))"

(let ((clojure-use-metadata-for-privacy t))
(clojure-cycle-privacy)))

(when-refactoring-it "should turn a private defn into a public defn"
"(defn- add [a b]
(+ a b))"

"(defn add [a b]
(+ a b))"

(clojure-cycle-privacy))

(when-refactoring-it "should turn a private defn with metadata into a public defn"
"(defn ^:private add [a b]
(+ a b))"

"(defn add [a b]
(+ a b))"

(let ((clojure-use-metadata-for-privacy t))
(clojure-cycle-privacy)))

(when-refactoring-it "should also work with pre-existing metadata"
"(def ^:dynamic config
\"docs\"
{:env \"staging\"})"

"(def ^:private ^:dynamic config
\"docs\"
{:env \"staging\"})"

(clojure-cycle-privacy))

(when-refactoring-it "should turn a private def with metadata into a public def"
"(def ^:private config
\"docs\"
{:env \"staging\"})"

"(def config
\"docs\"
{:env \"staging\"})"

(clojure-cycle-privacy)))

(describe "clojure-cycle-if"

(when-refactoring-it "should cycle inner if"
"(if this
(if that
(then AAA)
(else BBB))
(otherwise CCC))"

"(if this
(if-not that
(else BBB)
(then AAA))
(otherwise CCC))"

(beginning-of-buffer)
(search-forward "BBB)")
(clojure-cycle-if))

(when-refactoring-it "should cycle outer if"
"(if-not this
(if that
(then AAA)
(else BBB))
(otherwise CCC))"

"(if this
(otherwise CCC)
(if that
(then AAA)
(else BBB)))"

(beginning-of-buffer)
(search-forward "BBB))")
(clojure-cycle-if)))

(describe "clojure-cycle-when"

(when-refactoring-it "should cycle inner when"
"(when this
(when that
(aaa)
(bbb))
(ccc))"

"(when this
(when-not that
(aaa)
(bbb))
(ccc))"

(beginning-of-buffer)
(search-forward "bbb)")
(clojure-cycle-when))

(when-refactoring-it "should cycle outer when"
"(when-not this
(when that
(aaa)
(bbb))
(ccc))"

"(when this
(when that
(aaa)
(bbb))
(ccc))"

(beginning-of-buffer)
(search-forward "bbb))")
(clojure-cycle-when)))

(describe "clojure-cycle-not"

(when-refactoring-it "should add a not when missing"
"(ala bala portokala)"
"(not (ala bala portokala))"

(beginning-of-buffer)
(search-forward "bala")
(clojure-cycle-not))

(when-refactoring-it "should remove a not when present"
"(not (ala bala portokala))"
"(ala bala portokala)"

(beginning-of-buffer)
(search-forward "bala")
(clojure-cycle-not)))

(provide 'clojure-mode-cycling-test)

;;; clojure-mode-cycling-test.el ends here
Loading