File: test-strings-and-comments.el

package info (click to toggle)
lua-mode 20151025-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 240 kB
  • ctags: 145
  • sloc: lisp: 2,533; makefile: 34; sh: 26
file content (99 lines) | stat: -rw-r--r-- 3,031 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
;; -*- flycheck-disabled-checkers: (emacs-lisp-checkdoc) -*-

(load (concat (file-name-directory (or load-file-name (buffer-file-name)
                                       default-directory))
              "utils.el") nil 'nomessage 'nosuffix)

(defmacro should= (lhs rhs)
  `(should (equal ,lhs ,rhs)))

(describe "Test indent-new-comment-line"
  (it "works with -- ..."
    (expect (lua-buffer-strs
             (lua-insert-goto-<> '("-- foobar <>"))
             (execute-kbd-macro (kbd "M-j")))
            :to-equal
            '("-- foobar"
              "-- "))

    (expect (lua-buffer-strs
             (lua-insert-goto-<> '("xyzzy -- foobar <>"))
             (execute-kbd-macro (kbd "M-j")))
            :to-equal
            '("xyzzy -- foobar"
              "-- "))

    (expect (lua-buffer-strs
             (lua-insert-goto-<> '("xyz<> xyzzy -- foobar"))
             (execute-kbd-macro (kbd "M-j")))
            :to-equal
            '("xyz"
              "xyzzy -- foobar")))


  (it "works with ---- ...."
    (expect (lua-buffer-strs
             (lua-insert-goto-<> '("---- foobar <>"))
             (execute-kbd-macro (kbd "M-j")))
            :to-equal
            '("---- foobar"
              "---- "))

    (expect (lua-buffer-strs
             (lua-insert-goto-<> '("xyzzy ---- foobar <>"))
             (execute-kbd-macro (kbd "M-j")))
            :to-equal
            '("xyzzy ---- foobar"
              "---- ")))

  (it "doesn't recognize \"--\" inside strings and comments"
    (expect (lua-buffer-strs
             (lua-insert-goto-<> '("\"-- \" .. foobar <>"))
             (execute-kbd-macro (kbd "M-j")))
            :to-equal
            '("\"-- \" .. foobar"
              ""))

    (expect (lua-buffer-strs
             (lua-insert-goto-<> '("'-- ' .. foobar <>"))
             (execute-kbd-macro (kbd "M-j")))
            :to-equal
            '("'-- ' .. foobar"
              ""))

    (expect (lua-buffer-strs
             (lua-insert-goto-<> '("[[-- ]] .. foobar <>"))
             (execute-kbd-macro (kbd "M-j")))
            :to-equal
            '("[[-- ]] .. foobar"
              ""))

    (expect (lua-buffer-strs
             (lua-insert-goto-<> '("--[[-- ]] .. foobar <>"))
             (execute-kbd-macro (kbd "M-j")))
            :to-equal
            '("--[[-- ]] .. foobar"
              ""))

    (expect (lua-buffer-strs
             (lua-insert-goto-<> '("---[[-- ]] .. foobar <>"))
             (execute-kbd-macro (kbd "M-j")))
            :to-equal
            '("---[[-- ]] .. foobar"
              "---")))

  (it "works when the comment is empty"
    (expect (lua-buffer-strs
             (lua-insert-goto-<> '("-- <>"))
             (execute-kbd-macro (kbd "M-j")))
            :to-equal
            '("--"
              "--"))

    ;; Let's make sure that whitespace is optional.
    (expect (lua-buffer-strs
             (lua-insert-goto-<> '("--<>"))
             (execute-kbd-macro (kbd "M-j")))
            :to-equal
            '("--"
              "--"))))