diff options
| author | john muhl | 2025-03-21 12:15:02 -0500 |
|---|---|---|
| committer | Po Lu | 2025-08-25 09:59:04 +0800 |
| commit | c5656af2ff5f2ee4a683540db792ccece6db4e43 (patch) | |
| tree | dd0eaaab38f36e99b9613854243da73bb5a906bd /test/lisp/progmodes | |
| parent | 38a07757425c711e037c526f2c76d342a81e7c17 (diff) | |
| download | emacs-c5656af2ff5f2ee4a683540db792ccece6db4e43.tar.gz emacs-c5656af2ff5f2ee4a683540db792ccece6db4e43.zip | |
; Add tests for 'lua-mode'
* test/lisp/progmodes/lua-mode-resources/font-lock.lua:
* test/lisp/progmodes/lua-mode-resources/hide-show.lua:
* test/lisp/progmodes/lua-mode-resources/indent.erts:
* test/lisp/progmodes/lua-mode-resources/movement.erts:
* test/lisp/progmodes/lua-mode-resources/which-function.lua:
* test/lisp/progmodes/lua-mode-tests.el: New file.
Diffstat (limited to 'test/lisp/progmodes')
| -rw-r--r-- | test/lisp/progmodes/lua-mode-resources/font-lock.lua | 184 | ||||
| -rw-r--r-- | test/lisp/progmodes/lua-mode-resources/hide-show.lua | 35 | ||||
| -rw-r--r-- | test/lisp/progmodes/lua-mode-resources/indent.erts | 1061 | ||||
| -rw-r--r-- | test/lisp/progmodes/lua-mode-resources/movement.erts | 637 | ||||
| -rw-r--r-- | test/lisp/progmodes/lua-mode-resources/which-function.lua | 3 | ||||
| -rw-r--r-- | test/lisp/progmodes/lua-mode-tests.el | 60 |
6 files changed, 1980 insertions, 0 deletions
diff --git a/test/lisp/progmodes/lua-mode-resources/font-lock.lua b/test/lisp/progmodes/lua-mode-resources/font-lock.lua new file mode 100644 index 00000000000..bcf77b632c2 --- /dev/null +++ b/test/lisp/progmodes/lua-mode-resources/font-lock.lua | |||
| @@ -0,0 +1,184 @@ | |||
| 1 | #!/usr/bin/env lua | ||
| 2 | -- ^ font-lock-comment-face | ||
| 3 | -- Comment | ||
| 4 | -- <- font-lock-comment-delimiter-face | ||
| 5 | -- ^ font-lock-comment-face | ||
| 6 | --[[ | ||
| 7 | -- ^ font-lock-comment-face | ||
| 8 | Multi-line comment | ||
| 9 | -- ^ font-lock-comment-face | ||
| 10 | ]] | ||
| 11 | -- <- font-lock-comment-face | ||
| 12 | local line_comment = "comment" -- comment | ||
| 13 | -- ^ font-lock-comment-face | ||
| 14 | |||
| 15 | -- Definition | ||
| 16 | local function f1() end | ||
| 17 | -- ^ font-lock-function-name-face | ||
| 18 | local f2 = function() end | ||
| 19 | -- ^ font-lock-function-name-face | ||
| 20 | local tb = { f1 = function() end } | ||
| 21 | -- ^ font-lock-function-name-face | ||
| 22 | function tb.f2() end | ||
| 23 | -- ^ font-lock-function-name-face | ||
| 24 | function tb:f3() end | ||
| 25 | -- ^ font-lock-function-name-face | ||
| 26 | tbl.f4 = function() end | ||
| 27 | -- ^ font-lock-function-name-face | ||
| 28 | function x.y:z() end | ||
| 29 | -- ^ font-lock-function-name-face | ||
| 30 | |||
| 31 | -- Keyword | ||
| 32 | if true then | ||
| 33 | -- <- font-lock-keyword-face | ||
| 34 | -- ^ font-lock-keyword-face | ||
| 35 | elseif true then | ||
| 36 | -- <- font-lock-keyword-face | ||
| 37 | else end | ||
| 38 | -- <- font-lock-keyword-face | ||
| 39 | -- ^ font-lock-keyword-face | ||
| 40 | local p = {} | ||
| 41 | -- ^ font-lock-keyword-face | ||
| 42 | for k,v in pairs({}) do end | ||
| 43 | -- <- font-lock-keyword-face | ||
| 44 | -- ^ font-lock-keyword-face | ||
| 45 | repeat if true then break end until false | ||
| 46 | -- <- font-lock-keyword-face | ||
| 47 | -- ^ font-lock-keyword-face | ||
| 48 | -- ^ font-lock-keyword-face | ||
| 49 | while true do end | ||
| 50 | -- <- font-lock-keyword-face | ||
| 51 | -- ^ font-lock-keyword-face | ||
| 52 | function fn() return true end | ||
| 53 | -- <- font-lock-keyword-face | ||
| 54 | -- ^ font-lock-keyword-face | ||
| 55 | goto label1 | ||
| 56 | -- ^ font-lock-keyword-face | ||
| 57 | ::label1:: | ||
| 58 | if true and not false or nil then | ||
| 59 | -- ^ font-lock-keyword-face | ||
| 60 | -- ^ font-lock-keyword-face | ||
| 61 | -- ^ font-lock-keyword-face | ||
| 62 | end | ||
| 63 | |||
| 64 | -- String | ||
| 65 | local _ | ||
| 66 | _ = "x" | ||
| 67 | -- ^ font-lock-string-face | ||
| 68 | _ = 'x' | ||
| 69 | -- ^ font-lock-string-face | ||
| 70 | _ = "x\ty" | ||
| 71 | -- ^ font-lock-string-face | ||
| 72 | -- ^ font-lock-string-face | ||
| 73 | _ = "x\"y" | ||
| 74 | -- ^ font-lock-string-face | ||
| 75 | -- ^ font-lock-string-face | ||
| 76 | _ = 'x\'y' | ||
| 77 | -- ^ font-lock-string-face | ||
| 78 | -- ^ font-lock-string-face | ||
| 79 | _ = "x\z | ||
| 80 | y" | ||
| 81 | -- ^ font-lock-string-face | ||
| 82 | _ = "x\0900y" | ||
| 83 | -- ^ font-lock-string-face | ||
| 84 | _ = "x\09y" | ||
| 85 | -- ^ font-lock-string-face | ||
| 86 | _ = "x\0y" | ||
| 87 | -- ^ font-lock-string-face | ||
| 88 | _ = "x\u{1f602}y" | ||
| 89 | -- ^ font-lock-string-face | ||
| 90 | _ = [[x]] | ||
| 91 | -- ^ font-lock-string-face | ||
| 92 | _ = [=[x]=] | ||
| 93 | -- ^ font-lock-string-face | ||
| 94 | |||
| 95 | -- Assignment | ||
| 96 | local n = 0 | ||
| 97 | -- ^ font-lock-variable-name-face | ||
| 98 | for i=0,9 do end | ||
| 99 | -- ^ font-lock-variable-name-face | ||
| 100 | |||
| 101 | -- Constant | ||
| 102 | ::label2:: | ||
| 103 | -- ^ font-lock-constant-face | ||
| 104 | goto label2 | ||
| 105 | -- ^ font-lock-constant-face | ||
| 106 | |||
| 107 | -- Builtin | ||
| 108 | assert() | ||
| 109 | -- <- font-lock-builtin-face | ||
| 110 | bit32() | ||
| 111 | -- <- font-lock-builtin-face | ||
| 112 | collectgarbage() | ||
| 113 | -- <- font-lock-builtin-face | ||
| 114 | coroutine() | ||
| 115 | -- <- font-lock-builtin-face | ||
| 116 | debug() | ||
| 117 | -- <- font-lock-builtin-face | ||
| 118 | dofile() | ||
| 119 | -- <- font-lock-builtin-face | ||
| 120 | error() | ||
| 121 | -- <- font-lock-builtin-face | ||
| 122 | getmetatable() | ||
| 123 | -- <- font-lock-builtin-face | ||
| 124 | io() | ||
| 125 | -- <- font-lock-builtin-face | ||
| 126 | ipairs() | ||
| 127 | -- <- font-lock-builtin-face | ||
| 128 | load() | ||
| 129 | -- <- font-lock-builtin-face | ||
| 130 | loadfile() | ||
| 131 | -- <- font-lock-builtin-face | ||
| 132 | math() | ||
| 133 | -- <- font-lock-builtin-face | ||
| 134 | next() | ||
| 135 | -- <- font-lock-builtin-face | ||
| 136 | os() | ||
| 137 | -- <- font-lock-builtin-face | ||
| 138 | package() | ||
| 139 | -- <- font-lock-builtin-face | ||
| 140 | pairs() | ||
| 141 | -- <- font-lock-builtin-face | ||
| 142 | pcall() | ||
| 143 | -- <- font-lock-builtin-face | ||
| 144 | print() | ||
| 145 | -- <- font-lock-builtin-face | ||
| 146 | rawequal() | ||
| 147 | -- <- font-lock-builtin-face | ||
| 148 | rawget() | ||
| 149 | -- <- font-lock-builtin-face | ||
| 150 | rawlen() | ||
| 151 | -- <- font-lock-builtin-face | ||
| 152 | rawset() | ||
| 153 | -- <- font-lock-builtin-face | ||
| 154 | require() | ||
| 155 | -- <- font-lock-builtin-face | ||
| 156 | select() | ||
| 157 | -- <- font-lock-builtin-face | ||
| 158 | setmetatable() | ||
| 159 | -- <- font-lock-builtin-face | ||
| 160 | string() | ||
| 161 | -- <- font-lock-builtin-face | ||
| 162 | table() | ||
| 163 | -- <- font-lock-builtin-face | ||
| 164 | tonumber() | ||
| 165 | -- <- font-lock-builtin-face | ||
| 166 | tostring() | ||
| 167 | -- <- font-lock-builtin-face | ||
| 168 | type() | ||
| 169 | -- <- font-lock-builtin-face | ||
| 170 | utf8() | ||
| 171 | -- <- font-lock-builtin-face | ||
| 172 | warn() | ||
| 173 | -- <- font-lock-builtin-face | ||
| 174 | xpcall() | ||
| 175 | -- <- font-lock-builtin-face | ||
| 176 | print(_G) | ||
| 177 | -- ^ font-lock-builtin-face | ||
| 178 | print(_VERSION) | ||
| 179 | -- ^ font-lock-builtin-face | ||
| 180 | |||
| 181 | -- Variable | ||
| 182 | function fn(x, y) end | ||
| 183 | -- ^ font-lock-variable-name-face | ||
| 184 | -- ^ font-lock-variable-name-face | ||
diff --git a/test/lisp/progmodes/lua-mode-resources/hide-show.lua b/test/lisp/progmodes/lua-mode-resources/hide-show.lua new file mode 100644 index 00000000000..a23b46437bf --- /dev/null +++ b/test/lisp/progmodes/lua-mode-resources/hide-show.lua | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | --[[ | ||
| 2 | This is a | ||
| 3 | comment block. | ||
| 4 | ]] | ||
| 5 | local function fun () | ||
| 6 | print("fun") | ||
| 7 | end | ||
| 8 | local f = (function () | ||
| 9 | print(1) | ||
| 10 | end) | ||
| 11 | for i = 1, 10 do | ||
| 12 | print(i) | ||
| 13 | end | ||
| 14 | repeat | ||
| 15 | print("repeat") | ||
| 16 | until false | ||
| 17 | while true do | ||
| 18 | print("while") | ||
| 19 | end | ||
| 20 | do | ||
| 21 | print(1) | ||
| 22 | end | ||
| 23 | if true then | ||
| 24 | print(1) | ||
| 25 | elseif false then | ||
| 26 | print(0) | ||
| 27 | else | ||
| 28 | print(0) | ||
| 29 | end | ||
| 30 | function f1 (has, | ||
| 31 | lots, | ||
| 32 | of, | ||
| 33 | parameters) | ||
| 34 | print("ok") | ||
| 35 | end | ||
diff --git a/test/lisp/progmodes/lua-mode-resources/indent.erts b/test/lisp/progmodes/lua-mode-resources/indent.erts new file mode 100644 index 00000000000..8b4d8dd0921 --- /dev/null +++ b/test/lisp/progmodes/lua-mode-resources/indent.erts | |||
| @@ -0,0 +1,1061 @@ | |||
| 1 | Code: | ||
| 2 | (lambda () | ||
| 3 | (lua-mode) | ||
| 4 | (setq-local indent-tabs-mode nil) | ||
| 5 | (setq-local lua-indent-level 2) | ||
| 6 | (indent-region (point-min) (point-max))) | ||
| 7 | |||
| 8 | Name: Function Indent 1 | ||
| 9 | |||
| 10 | =-= | ||
| 11 | function f1(n) | ||
| 12 | print(n) | ||
| 13 | return n + 1 | ||
| 14 | end | ||
| 15 | =-= | ||
| 16 | function f1(n) | ||
| 17 | print(n) | ||
| 18 | return n + 1 | ||
| 19 | end | ||
| 20 | =-=-= | ||
| 21 | |||
| 22 | Name: Function Indent 2 | ||
| 23 | |||
| 24 | =-= | ||
| 25 | local function f2(n) | ||
| 26 | print(n) | ||
| 27 | return n * 2 | ||
| 28 | end | ||
| 29 | =-= | ||
| 30 | local function f2(n) | ||
| 31 | print(n) | ||
| 32 | return n * 2 | ||
| 33 | end | ||
| 34 | =-=-= | ||
| 35 | |||
| 36 | Name: Function Indent 3 | ||
| 37 | |||
| 38 | =-= | ||
| 39 | local f3 = function(n) | ||
| 40 | print(n) | ||
| 41 | return n / 3 | ||
| 42 | end | ||
| 43 | =-= | ||
| 44 | local f3 = function(n) | ||
| 45 | print(n) | ||
| 46 | return n / 3 | ||
| 47 | end | ||
| 48 | =-=-= | ||
| 49 | |||
| 50 | Name: Function Indent 4 | ||
| 51 | |||
| 52 | =-= | ||
| 53 | function f4(...) | ||
| 54 | local f = function (...) | ||
| 55 | if ok | ||
| 56 | then print(1) | ||
| 57 | else print(0) | ||
| 58 | end | ||
| 59 | end | ||
| 60 | return f | ||
| 61 | end | ||
| 62 | =-= | ||
| 63 | function f4(...) | ||
| 64 | local f = function (...) | ||
| 65 | if ok | ||
| 66 | then print(1) | ||
| 67 | else print(0) | ||
| 68 | end | ||
| 69 | end | ||
| 70 | return f | ||
| 71 | end | ||
| 72 | =-=-= | ||
| 73 | |||
| 74 | Name: Function Indent 5 | ||
| 75 | |||
| 76 | =-= | ||
| 77 | function f5(...) | ||
| 78 | local f = function (...) | ||
| 79 | if ok | ||
| 80 | then | ||
| 81 | print(1) | ||
| 82 | else | ||
| 83 | print(0) | ||
| 84 | end | ||
| 85 | end | ||
| 86 | return f | ||
| 87 | end | ||
| 88 | =-= | ||
| 89 | function f5(...) | ||
| 90 | local f = function (...) | ||
| 91 | if ok | ||
| 92 | then | ||
| 93 | print(1) | ||
| 94 | else | ||
| 95 | print(0) | ||
| 96 | end | ||
| 97 | end | ||
| 98 | return f | ||
| 99 | end | ||
| 100 | =-=-= | ||
| 101 | |||
| 102 | Name: Function Indent 6 | ||
| 103 | |||
| 104 | =-= | ||
| 105 | function f6(...) | ||
| 106 | local f = function (...) | ||
| 107 | if ok then | ||
| 108 | print(1) | ||
| 109 | else | ||
| 110 | print(0) | ||
| 111 | end | ||
| 112 | end | ||
| 113 | return f | ||
| 114 | end | ||
| 115 | =-= | ||
| 116 | function f6(...) | ||
| 117 | local f = function (...) | ||
| 118 | if ok then | ||
| 119 | print(1) | ||
| 120 | else | ||
| 121 | print(0) | ||
| 122 | end | ||
| 123 | end | ||
| 124 | return f | ||
| 125 | end | ||
| 126 | =-=-= | ||
| 127 | |||
| 128 | Name: Function Indent 7 | ||
| 129 | |||
| 130 | =-= | ||
| 131 | f7(function() | ||
| 132 | print'ok' | ||
| 133 | end) | ||
| 134 | =-= | ||
| 135 | f7(function() | ||
| 136 | print'ok' | ||
| 137 | end) | ||
| 138 | =-=-= | ||
| 139 | |||
| 140 | Name: Function Indent 8 | ||
| 141 | |||
| 142 | =-= | ||
| 143 | ;(function () | ||
| 144 | return true | ||
| 145 | end)() | ||
| 146 | =-= | ||
| 147 | ;(function () | ||
| 148 | return true | ||
| 149 | end)() | ||
| 150 | =-=-= | ||
| 151 | |||
| 152 | Name: Conditional Indent 1 | ||
| 153 | |||
| 154 | =-= | ||
| 155 | if true then | ||
| 156 | print(true) | ||
| 157 | return 1 | ||
| 158 | elseif false then | ||
| 159 | print(false) | ||
| 160 | return -1 | ||
| 161 | else | ||
| 162 | print(nil) | ||
| 163 | return 0 | ||
| 164 | end | ||
| 165 | =-= | ||
| 166 | if true then | ||
| 167 | print(true) | ||
| 168 | return 1 | ||
| 169 | elseif false then | ||
| 170 | print(false) | ||
| 171 | return -1 | ||
| 172 | else | ||
| 173 | print(nil) | ||
| 174 | return 0 | ||
| 175 | end | ||
| 176 | =-=-= | ||
| 177 | |||
| 178 | Name: Conditional Indent 2 | ||
| 179 | |||
| 180 | =-= | ||
| 181 | if true | ||
| 182 | then | ||
| 183 | print(true) | ||
| 184 | return 1 | ||
| 185 | elseif false | ||
| 186 | then | ||
| 187 | print(false) | ||
| 188 | return -1 | ||
| 189 | else | ||
| 190 | print(nil) | ||
| 191 | return 0 | ||
| 192 | end | ||
| 193 | =-= | ||
| 194 | if true | ||
| 195 | then | ||
| 196 | print(true) | ||
| 197 | return 1 | ||
| 198 | elseif false | ||
| 199 | then | ||
| 200 | print(false) | ||
| 201 | return -1 | ||
| 202 | else | ||
| 203 | print(nil) | ||
| 204 | return 0 | ||
| 205 | end | ||
| 206 | =-=-= | ||
| 207 | |||
| 208 | Name: Conditional Indent 3 | ||
| 209 | |||
| 210 | =-= | ||
| 211 | if true | ||
| 212 | then return 1 | ||
| 213 | elseif false | ||
| 214 | then return -1 | ||
| 215 | else return 0 | ||
| 216 | end | ||
| 217 | =-= | ||
| 218 | if true | ||
| 219 | then return 1 | ||
| 220 | elseif false | ||
| 221 | then return -1 | ||
| 222 | else return 0 | ||
| 223 | end | ||
| 224 | =-=-= | ||
| 225 | |||
| 226 | Name: Loop Indent 1 | ||
| 227 | |||
| 228 | =-= | ||
| 229 | for k,v in pairs({}) do | ||
| 230 | print(k) | ||
| 231 | print(v) | ||
| 232 | end | ||
| 233 | =-= | ||
| 234 | for k,v in pairs({}) do | ||
| 235 | print(k) | ||
| 236 | print(v) | ||
| 237 | end | ||
| 238 | =-=-= | ||
| 239 | |||
| 240 | Name: Loop Indent 2 | ||
| 241 | |||
| 242 | =-= | ||
| 243 | for i=1,10 | ||
| 244 | do print(i) | ||
| 245 | end | ||
| 246 | =-= | ||
| 247 | for i=1,10 | ||
| 248 | do print(i) | ||
| 249 | end | ||
| 250 | =-=-= | ||
| 251 | |||
| 252 | Name: Loop Indent 3 | ||
| 253 | |||
| 254 | =-= | ||
| 255 | while n < 10 do | ||
| 256 | n = n + 1 | ||
| 257 | print(n) | ||
| 258 | end | ||
| 259 | =-= | ||
| 260 | while n < 10 do | ||
| 261 | n = n + 1 | ||
| 262 | print(n) | ||
| 263 | end | ||
| 264 | =-=-= | ||
| 265 | |||
| 266 | Name: Loop Indent 4 | ||
| 267 | |||
| 268 | =-= | ||
| 269 | while n < 10 | ||
| 270 | do | ||
| 271 | n = n + 1 | ||
| 272 | print(n) | ||
| 273 | end | ||
| 274 | =-= | ||
| 275 | while n < 10 | ||
| 276 | do | ||
| 277 | n = n + 1 | ||
| 278 | print(n) | ||
| 279 | end | ||
| 280 | =-=-= | ||
| 281 | |||
| 282 | Name: Loop Indent 5 | ||
| 283 | |||
| 284 | =-= | ||
| 285 | for i=0,9 do | ||
| 286 | repeat n = n+1 | ||
| 287 | until n > 99 | ||
| 288 | end | ||
| 289 | =-= | ||
| 290 | for i=0,9 do | ||
| 291 | repeat n = n+1 | ||
| 292 | until n > 99 | ||
| 293 | end | ||
| 294 | =-=-= | ||
| 295 | |||
| 296 | Name: Loop Indent 6 | ||
| 297 | |||
| 298 | =-= | ||
| 299 | repeat | ||
| 300 | z = z * 2 | ||
| 301 | print(z) | ||
| 302 | until z > 12 | ||
| 303 | =-= | ||
| 304 | repeat | ||
| 305 | z = z * 2 | ||
| 306 | print(z) | ||
| 307 | until z > 12 | ||
| 308 | =-=-= | ||
| 309 | |||
| 310 | Name: Loop Indent 7 | ||
| 311 | |||
| 312 | =-= | ||
| 313 | for i,x in ipairs(t) do | ||
| 314 | while i < 9 | ||
| 315 | do | ||
| 316 | local n = t[x] | ||
| 317 | repeat n = n + 1 | ||
| 318 | until n > #t | ||
| 319 | while n < 99 | ||
| 320 | do | ||
| 321 | print(n) | ||
| 322 | end | ||
| 323 | end | ||
| 324 | print(t[i]) | ||
| 325 | end | ||
| 326 | =-= | ||
| 327 | for i,x in ipairs(t) do | ||
| 328 | while i < 9 | ||
| 329 | do | ||
| 330 | local n = t[x] | ||
| 331 | repeat n = n + 1 | ||
| 332 | until n > #t | ||
| 333 | while n < 99 | ||
| 334 | do | ||
| 335 | print(n) | ||
| 336 | end | ||
| 337 | end | ||
| 338 | print(t[i]) | ||
| 339 | end | ||
| 340 | =-=-= | ||
| 341 | |||
| 342 | Name: Loop Indent 8 | ||
| 343 | |||
| 344 | =-= | ||
| 345 | do | ||
| 346 | local a = b | ||
| 347 | print(a + 1) | ||
| 348 | end | ||
| 349 | =-= | ||
| 350 | do | ||
| 351 | local a = b | ||
| 352 | print(a + 1) | ||
| 353 | end | ||
| 354 | =-=-= | ||
| 355 | |||
| 356 | Name: Bracket Indent 1 | ||
| 357 | |||
| 358 | =-= | ||
| 359 | fn( | ||
| 360 | ) | ||
| 361 | =-= | ||
| 362 | fn( | ||
| 363 | ) | ||
| 364 | =-=-= | ||
| 365 | |||
| 366 | Name: Bracket Indent 2 | ||
| 367 | |||
| 368 | =-= | ||
| 369 | tb={ | ||
| 370 | } | ||
| 371 | =-= | ||
| 372 | tb={ | ||
| 373 | } | ||
| 374 | =-=-= | ||
| 375 | |||
| 376 | Name: Multi-line String Indent 1 | ||
| 377 | |||
| 378 | =-= | ||
| 379 | local s = [[ | ||
| 380 | Multi-line | ||
| 381 | string content | ||
| 382 | ]] | ||
| 383 | =-=-= | ||
| 384 | |||
| 385 | Name: Multi-line String Indent 2 | ||
| 386 | |||
| 387 | =-= | ||
| 388 | function f() | ||
| 389 | local str = [[ | ||
| 390 | multi-line | ||
| 391 | string | ||
| 392 | ]] | ||
| 393 | return true | ||
| 394 | end | ||
| 395 | =-= | ||
| 396 | function f() | ||
| 397 | local str = [[ | ||
| 398 | multi-line | ||
| 399 | string | ||
| 400 | ]] | ||
| 401 | return true | ||
| 402 | end | ||
| 403 | =-=-= | ||
| 404 | |||
| 405 | Name: Multi-line Comment Indent 1 | ||
| 406 | |||
| 407 | =-= | ||
| 408 | --[[ | ||
| 409 | Multi-line | ||
| 410 | comment content | ||
| 411 | ]] | ||
| 412 | =-=-= | ||
| 413 | |||
| 414 | Name: Multi-line Comment Indent 2 | ||
| 415 | |||
| 416 | =-= | ||
| 417 | function f() | ||
| 418 | --[[ | ||
| 419 | multi-line | ||
| 420 | comment | ||
| 421 | ]] | ||
| 422 | return true | ||
| 423 | end | ||
| 424 | =-=-= | ||
| 425 | |||
| 426 | Name: Multi-line Comment Indent 3 | ||
| 427 | |||
| 428 | =-= | ||
| 429 | --[[ | ||
| 430 | Long comment. | ||
| 431 | ]] | ||
| 432 | =-=-= | ||
| 433 | |||
| 434 | Name: Comment Indent 1 | ||
| 435 | |||
| 436 | =-= | ||
| 437 | local fn1 = function (a, b) | ||
| 438 | -- comment | ||
| 439 | return a + b | ||
| 440 | end | ||
| 441 | =-= | ||
| 442 | local fn1 = function (a, b) | ||
| 443 | -- comment | ||
| 444 | return a + b | ||
| 445 | end | ||
| 446 | =-=-= | ||
| 447 | |||
| 448 | Name: Comment Indent 2 | ||
| 449 | |||
| 450 | =-= | ||
| 451 | local tb1 = { | ||
| 452 | first = 1, | ||
| 453 | -- comment | ||
| 454 | second = 2, | ||
| 455 | } | ||
| 456 | =-= | ||
| 457 | local tb1 = { | ||
| 458 | first = 1, | ||
| 459 | -- comment | ||
| 460 | second = 2, | ||
| 461 | } | ||
| 462 | =-=-= | ||
| 463 | |||
| 464 | Name: Comment Indent 3 | ||
| 465 | |||
| 466 | =-= | ||
| 467 | local tb9 = { one = 1, | ||
| 468 | -- comment | ||
| 469 | two = 2 } | ||
| 470 | =-= | ||
| 471 | local tb9 = { one = 1, | ||
| 472 | -- comment | ||
| 473 | two = 2 } | ||
| 474 | =-=-= | ||
| 475 | |||
| 476 | Name: Argument Indent 1 | ||
| 477 | |||
| 478 | =-= | ||
| 479 | h( | ||
| 480 | "string", | ||
| 481 | 1000 | ||
| 482 | ) | ||
| 483 | =-= | ||
| 484 | h( | ||
| 485 | "string", | ||
| 486 | 1000 | ||
| 487 | ) | ||
| 488 | =-=-= | ||
| 489 | |||
| 490 | Name: Argument Indent 2 | ||
| 491 | |||
| 492 | =-= | ||
| 493 | local p = h( | ||
| 494 | "string", | ||
| 495 | 1000 | ||
| 496 | ) | ||
| 497 | =-= | ||
| 498 | local p = h( | ||
| 499 | "string", | ||
| 500 | 1000 | ||
| 501 | ) | ||
| 502 | =-=-= | ||
| 503 | |||
| 504 | Name: Argument Indent 3 | ||
| 505 | |||
| 506 | =-= | ||
| 507 | fn(1, | ||
| 508 | 2, | ||
| 509 | 3) | ||
| 510 | =-= | ||
| 511 | fn(1, | ||
| 512 | 2, | ||
| 513 | 3) | ||
| 514 | =-=-= | ||
| 515 | |||
| 516 | Name: Argument Indent 4 | ||
| 517 | |||
| 518 | =-= | ||
| 519 | fn( 1, 2, | ||
| 520 | 3, 4 ) | ||
| 521 | =-= | ||
| 522 | fn( 1, 2, | ||
| 523 | 3, 4 ) | ||
| 524 | =-=-= | ||
| 525 | |||
| 526 | Name: Argument Indent 5 | ||
| 527 | |||
| 528 | =-= | ||
| 529 | f({ | ||
| 530 | x = 1, | ||
| 531 | y = 2, | ||
| 532 | z = 3, | ||
| 533 | }) | ||
| 534 | =-= | ||
| 535 | f({ | ||
| 536 | x = 1, | ||
| 537 | y = 2, | ||
| 538 | z = 3, | ||
| 539 | }) | ||
| 540 | =-=-= | ||
| 541 | |||
| 542 | Name: Argument Indent 6 | ||
| 543 | |||
| 544 | =-= | ||
| 545 | f({ x = 1, | ||
| 546 | y = 2, | ||
| 547 | z = 3, }) | ||
| 548 | =-= | ||
| 549 | f({ x = 1, | ||
| 550 | y = 2, | ||
| 551 | z = 3, }) | ||
| 552 | =-=-= | ||
| 553 | |||
| 554 | Name: Argument Indent 7 | ||
| 555 | |||
| 556 | =-= | ||
| 557 | Test({ | ||
| 558 | a=1 | ||
| 559 | }) | ||
| 560 | =-= | ||
| 561 | Test({ | ||
| 562 | a=1 | ||
| 563 | }) | ||
| 564 | =-=-= | ||
| 565 | |||
| 566 | Name: Argument Indent 8 | ||
| 567 | |||
| 568 | =-= | ||
| 569 | Test({ | ||
| 570 | a = 1, | ||
| 571 | b = 2, | ||
| 572 | }, | ||
| 573 | nil) | ||
| 574 | =-= | ||
| 575 | Test({ | ||
| 576 | a = 1, | ||
| 577 | b = 2, | ||
| 578 | }, | ||
| 579 | nil) | ||
| 580 | =-=-= | ||
| 581 | |||
| 582 | Name: Argument Indent 9 | ||
| 583 | |||
| 584 | =-= | ||
| 585 | Test(nil, { | ||
| 586 | a = 1, | ||
| 587 | b = 2, | ||
| 588 | }) | ||
| 589 | =-= | ||
| 590 | Test(nil, { | ||
| 591 | a = 1, | ||
| 592 | b = 2, | ||
| 593 | }) | ||
| 594 | =-=-= | ||
| 595 | |||
| 596 | Name: Argument Indent 10 | ||
| 597 | |||
| 598 | =-= | ||
| 599 | fn( -- comment | ||
| 600 | 1, | ||
| 601 | 2) | ||
| 602 | =-= | ||
| 603 | fn( -- comment | ||
| 604 | 1, | ||
| 605 | 2) | ||
| 606 | =-=-= | ||
| 607 | |||
| 608 | Name: Parameter Indent 1 | ||
| 609 | |||
| 610 | =-= | ||
| 611 | function f1( | ||
| 612 | a, | ||
| 613 | b | ||
| 614 | ) | ||
| 615 | print(a,b) | ||
| 616 | end | ||
| 617 | =-= | ||
| 618 | function f1( | ||
| 619 | a, | ||
| 620 | b | ||
| 621 | ) | ||
| 622 | print(a,b) | ||
| 623 | end | ||
| 624 | =-=-= | ||
| 625 | |||
| 626 | Name: Parameter Indent 2 | ||
| 627 | |||
| 628 | =-= | ||
| 629 | local function f2(a, | ||
| 630 | b) | ||
| 631 | print(a,b) | ||
| 632 | end | ||
| 633 | =-= | ||
| 634 | local function f2(a, | ||
| 635 | b) | ||
| 636 | print(a,b) | ||
| 637 | end | ||
| 638 | =-=-= | ||
| 639 | |||
| 640 | Name: Parameter Indent 3 | ||
| 641 | |||
| 642 | =-= | ||
| 643 | local f3 = function( a, b, | ||
| 644 | c, d ) | ||
| 645 | print(a,b,c,d) | ||
| 646 | end | ||
| 647 | =-= | ||
| 648 | local f3 = function( a, b, | ||
| 649 | c, d ) | ||
| 650 | print(a,b,c,d) | ||
| 651 | end | ||
| 652 | =-=-= | ||
| 653 | |||
| 654 | Name: Parameter Indent 4 | ||
| 655 | |||
| 656 | =-= | ||
| 657 | local f4 = function(-- comment | ||
| 658 | a, b, c) | ||
| 659 | =-= | ||
| 660 | local f4 = function(-- comment | ||
| 661 | a, b, c) | ||
| 662 | =-=-= | ||
| 663 | |||
| 664 | Name: Table Indent 1 | ||
| 665 | |||
| 666 | =-= | ||
| 667 | local Other = { | ||
| 668 | First={up={Step=true,Jump=true}, | ||
| 669 | down={Step=true,Jump=true}, | ||
| 670 | left={Step=true,Jump=true}, | ||
| 671 | right={Step=true,Jump=true}}, | ||
| 672 | Second={up={Step=true,Jump=true}, | ||
| 673 | down={Step=true,Jump=true}, | ||
| 674 | left={Step=true,Jump=true}, | ||
| 675 | right={Step=true,Jump=true}}, | ||
| 676 | Third={up={Goto=true}, | ||
| 677 | down={Goto=true}, | ||
| 678 | left={Goto=true}, | ||
| 679 | right={Goto=true}} | ||
| 680 | } | ||
| 681 | =-= | ||
| 682 | local Other = { | ||
| 683 | First={up={Step=true,Jump=true}, | ||
| 684 | down={Step=true,Jump=true}, | ||
| 685 | left={Step=true,Jump=true}, | ||
| 686 | right={Step=true,Jump=true}}, | ||
| 687 | Second={up={Step=true,Jump=true}, | ||
| 688 | down={Step=true,Jump=true}, | ||
| 689 | left={Step=true,Jump=true}, | ||
| 690 | right={Step=true,Jump=true}}, | ||
| 691 | Third={up={Goto=true}, | ||
| 692 | down={Goto=true}, | ||
| 693 | left={Goto=true}, | ||
| 694 | right={Goto=true}} | ||
| 695 | } | ||
| 696 | =-=-= | ||
| 697 | |||
| 698 | Name: Table Indent 2 | ||
| 699 | |||
| 700 | =-= | ||
| 701 | local Other = { | ||
| 702 | a = 1, | ||
| 703 | b = 2, | ||
| 704 | c = 3, | ||
| 705 | } | ||
| 706 | =-= | ||
| 707 | local Other = { | ||
| 708 | a = 1, | ||
| 709 | b = 2, | ||
| 710 | c = 3, | ||
| 711 | } | ||
| 712 | =-=-= | ||
| 713 | |||
| 714 | Name: Table Indent 3 | ||
| 715 | |||
| 716 | =-= | ||
| 717 | local a = { -- hello world! | ||
| 718 | b = 10 | ||
| 719 | } | ||
| 720 | =-= | ||
| 721 | local a = { -- hello world! | ||
| 722 | b = 10 | ||
| 723 | } | ||
| 724 | =-=-= | ||
| 725 | |||
| 726 | Name: Continuation Indent 1 | ||
| 727 | |||
| 728 | =-= | ||
| 729 | local very_long_variable_name = | ||
| 730 | "ok".. | ||
| 731 | "ok" | ||
| 732 | =-= | ||
| 733 | local very_long_variable_name = | ||
| 734 | "ok".. | ||
| 735 | "ok" | ||
| 736 | =-=-= | ||
| 737 | |||
| 738 | Name: Continuation Indent 2 | ||
| 739 | |||
| 740 | =-= | ||
| 741 | local n = a + | ||
| 742 | b * | ||
| 743 | c / | ||
| 744 | 1 | ||
| 745 | =-= | ||
| 746 | local n = a + | ||
| 747 | b * | ||
| 748 | c / | ||
| 749 | 1 | ||
| 750 | =-=-= | ||
| 751 | |||
| 752 | Name: Continuation Indent 3 | ||
| 753 | |||
| 754 | =-= | ||
| 755 | local x = "A".. | ||
| 756 | "B" | ||
| 757 | .."C" | ||
| 758 | =-= | ||
| 759 | local x = "A".. | ||
| 760 | "B" | ||
| 761 | .."C" | ||
| 762 | =-=-= | ||
| 763 | |||
| 764 | Name: Continuation Indent 4 | ||
| 765 | |||
| 766 | =-= | ||
| 767 | if a | ||
| 768 | and b | ||
| 769 | and c then | ||
| 770 | if x | ||
| 771 | and y then | ||
| 772 | local x = 1 + | ||
| 773 | 2 * | ||
| 774 | 3 | ||
| 775 | end | ||
| 776 | elseif a | ||
| 777 | or b | ||
| 778 | or c then | ||
| 779 | end | ||
| 780 | =-= | ||
| 781 | if a | ||
| 782 | and b | ||
| 783 | and c then | ||
| 784 | if x | ||
| 785 | and y then | ||
| 786 | local x = 1 + | ||
| 787 | 2 * | ||
| 788 | 3 | ||
| 789 | end | ||
| 790 | elseif a | ||
| 791 | or b | ||
| 792 | or c then | ||
| 793 | end | ||
| 794 | =-=-= | ||
| 795 | |||
| 796 | Code: | ||
| 797 | (lambda () | ||
| 798 | (lua-mode) | ||
| 799 | (setq-local lua-indent-level 4) | ||
| 800 | (setq-local indent-tabs-mode nil) | ||
| 801 | (indent-region (point-min) (point-max))) | ||
| 802 | |||
| 803 | Name: End Indent 1 | ||
| 804 | |||
| 805 | =-= | ||
| 806 | function f(x) | ||
| 807 | for y=1,x.y do | ||
| 808 | for x=1,x.z do | ||
| 809 | if x.y and x.z then | ||
| 810 | if y <= x then | ||
| 811 | y = y + 1 | ||
| 812 | end end end end | ||
| 813 | return {x,y} or {math.random(),math.random()} | ||
| 814 | end | ||
| 815 | =-= | ||
| 816 | function f(x) | ||
| 817 | for y=1,x.y do | ||
| 818 | for x=1,x.z do | ||
| 819 | if x.y and x.z then | ||
| 820 | if y <= x then | ||
| 821 | y = y + 1 | ||
| 822 | end end end end | ||
| 823 | return {x,y} or {math.random(),math.random()} | ||
| 824 | end | ||
| 825 | =-=-= | ||
| 826 | |||
| 827 | Name: End Indent 2 | ||
| 828 | |||
| 829 | =-= | ||
| 830 | for y=1,x.y do | ||
| 831 | for x=1,x.z do | ||
| 832 | if x.y and x.z then | ||
| 833 | if y <= x then | ||
| 834 | y = y + 1 | ||
| 835 | end | ||
| 836 | end end end | ||
| 837 | =-= | ||
| 838 | for y=1,x.y do | ||
| 839 | for x=1,x.z do | ||
| 840 | if x.y and x.z then | ||
| 841 | if y <= x then | ||
| 842 | y = y + 1 | ||
| 843 | end | ||
| 844 | end end end | ||
| 845 | =-=-= | ||
| 846 | |||
| 847 | Name: Nested Function Indent 1 | ||
| 848 | |||
| 849 | =-= | ||
| 850 | function a(...) | ||
| 851 | return (function (x) | ||
| 852 | return x | ||
| 853 | end)(foo(...)) | ||
| 854 | end | ||
| 855 | =-= | ||
| 856 | function a(...) | ||
| 857 | return (function (x) | ||
| 858 | return x | ||
| 859 | end)(foo(...)) | ||
| 860 | end | ||
| 861 | =-=-= | ||
| 862 | |||
| 863 | Name: Nested Function Indent 2 | ||
| 864 | |||
| 865 | =-= | ||
| 866 | function b(n) | ||
| 867 | local x = 1 | ||
| 868 | return function (i) | ||
| 869 | return function (...) | ||
| 870 | return (function (n, ...) | ||
| 871 | return function (f, ...) | ||
| 872 | return (function (...) | ||
| 873 | if ... and x < 9 then | ||
| 874 | x = x + 1 | ||
| 875 | return ... | ||
| 876 | end end)(n(f, ...)) | ||
| 877 | end, ... | ||
| 878 | end)(i(...)) | ||
| 879 | end end end | ||
| 880 | =-= | ||
| 881 | function b(n) | ||
| 882 | local x = 1 | ||
| 883 | return function (i) | ||
| 884 | return function (...) | ||
| 885 | return (function (n, ...) | ||
| 886 | return function (f, ...) | ||
| 887 | return (function (...) | ||
| 888 | if ... and x < 9 then | ||
| 889 | x = x + 1 | ||
| 890 | return ... | ||
| 891 | end end)(n(f, ...)) | ||
| 892 | end, ... | ||
| 893 | end)(i(...)) | ||
| 894 | end end end | ||
| 895 | =-=-= | ||
| 896 | |||
| 897 | Name: Nested Function Indent 3 | ||
| 898 | |||
| 899 | =-= | ||
| 900 | function c(f) | ||
| 901 | local f1 = function (...) | ||
| 902 | if nil ~= ... then | ||
| 903 | return f(...) | ||
| 904 | end | ||
| 905 | end | ||
| 906 | return function (i) | ||
| 907 | return function (...) | ||
| 908 | local fn = function (n, ...) | ||
| 909 | local x = function (f, ...) | ||
| 910 | return f1(n(f, ...)) | ||
| 911 | end | ||
| 912 | return x | ||
| 913 | end | ||
| 914 | return fn(i(...)) | ||
| 915 | end | ||
| 916 | end | ||
| 917 | end | ||
| 918 | =-= | ||
| 919 | function c(f) | ||
| 920 | local f1 = function (...) | ||
| 921 | if nil ~= ... then | ||
| 922 | return f(...) | ||
| 923 | end | ||
| 924 | end | ||
| 925 | return function (i) | ||
| 926 | return function (...) | ||
| 927 | local fn = function (n, ...) | ||
| 928 | local x = function (f, ...) | ||
| 929 | return f1(n(f, ...)) | ||
| 930 | end | ||
| 931 | return x | ||
| 932 | end | ||
| 933 | return fn(i(...)) | ||
| 934 | end | ||
| 935 | end | ||
| 936 | end | ||
| 937 | =-=-= | ||
| 938 | |||
| 939 | Name: Nested Function Indent 4 | ||
| 940 | |||
| 941 | =-= | ||
| 942 | function d(f) | ||
| 943 | local f1 = function (c, f, ...) | ||
| 944 | if ... then | ||
| 945 | if f(...) then | ||
| 946 | return ... | ||
| 947 | else | ||
| 948 | return c(f, ...) | ||
| 949 | end end end | ||
| 950 | return function (i) | ||
| 951 | return function (...) | ||
| 952 | return (function (n, ...) | ||
| 953 | local function j (f, ...) | ||
| 954 | return f1(j, f, n(f, ...)) | ||
| 955 | end | ||
| 956 | return j, ... | ||
| 957 | end)(i(...)) | ||
| 958 | end end end | ||
| 959 | =-= | ||
| 960 | function d(f) | ||
| 961 | local f1 = function (c, f, ...) | ||
| 962 | if ... then | ||
| 963 | if f(...) then | ||
| 964 | return ... | ||
| 965 | else | ||
| 966 | return c(f, ...) | ||
| 967 | end end end | ||
| 968 | return function (i) | ||
| 969 | return function (...) | ||
| 970 | return (function (n, ...) | ||
| 971 | local function j (f, ...) | ||
| 972 | return f1(j, f, n(f, ...)) | ||
| 973 | end | ||
| 974 | return j, ... | ||
| 975 | end)(i(...)) | ||
| 976 | end end end | ||
| 977 | =-=-= | ||
| 978 | |||
| 979 | Name: Nested Function Indent 5 | ||
| 980 | |||
| 981 | =-= | ||
| 982 | function e (n, t) | ||
| 983 | return function (i) | ||
| 984 | return function (...) | ||
| 985 | return ( | ||
| 986 | function (n, ...) | ||
| 987 | local x, y, z = 0, {} | ||
| 988 | return (function (f, ...) | ||
| 989 | return (function (i, ...) return i(i, ...) end)( | ||
| 990 | function (i, ...) | ||
| 991 | return f(function (x, ...) | ||
| 992 | return i(i, ...)(x, ...) | ||
| 993 | end, ...) | ||
| 994 | end) | ||
| 995 | end)(function (j) | ||
| 996 | return function(f, ...) | ||
| 997 | return (function (c, f, ...) | ||
| 998 | if ... then | ||
| 999 | if n+1 == x then | ||
| 1000 | local y1, x1 = y, x | ||
| 1001 | y, x = {}, 0 | ||
| 1002 | return (function (...) | ||
| 1003 | z = ... | ||
| 1004 | return ... | ||
| 1005 | end)(t(y1-1, x1-1, ...)) | ||
| 1006 | else | ||
| 1007 | x = x - 1 | ||
| 1008 | return c(f, | ||
| 1009 | (function (...) | ||
| 1010 | z = ... | ||
| 1011 | return ... | ||
| 1012 | end)(t(y, x, ...))) | ||
| 1013 | end | ||
| 1014 | elseif x ~= 0 then | ||
| 1015 | x = 0 | ||
| 1016 | return z, y | ||
| 1017 | end end)(j, f, n(f, ...)) | ||
| 1018 | end end), ... | ||
| 1019 | end)(i(...)) | ||
| 1020 | end end end | ||
| 1021 | =-= | ||
| 1022 | function e (n, t) | ||
| 1023 | return function (i) | ||
| 1024 | return function (...) | ||
| 1025 | return ( | ||
| 1026 | function (n, ...) | ||
| 1027 | local x, y, z = 0, {} | ||
| 1028 | return (function (f, ...) | ||
| 1029 | return (function (i, ...) return i(i, ...) end)( | ||
| 1030 | function (i, ...) | ||
| 1031 | return f(function (x, ...) | ||
| 1032 | return i(i, ...)(x, ...) | ||
| 1033 | end, ...) | ||
| 1034 | end) | ||
| 1035 | end)(function (j) | ||
| 1036 | return function(f, ...) | ||
| 1037 | return (function (c, f, ...) | ||
| 1038 | if ... then | ||
| 1039 | if n+1 == x then | ||
| 1040 | local y1, x1 = y, x | ||
| 1041 | y, x = {}, 0 | ||
| 1042 | return (function (...) | ||
| 1043 | z = ... | ||
| 1044 | return ... | ||
| 1045 | end)(t(y1-1, x1-1, ...)) | ||
| 1046 | else | ||
| 1047 | x = x - 1 | ||
| 1048 | return c(f, | ||
| 1049 | (function (...) | ||
| 1050 | z = ... | ||
| 1051 | return ... | ||
| 1052 | end)(t(y, x, ...))) | ||
| 1053 | end | ||
| 1054 | elseif x ~= 0 then | ||
| 1055 | x = 0 | ||
| 1056 | return z, y | ||
| 1057 | end end)(j, f, n(f, ...)) | ||
| 1058 | end end), ... | ||
| 1059 | end)(i(...)) | ||
| 1060 | end end end | ||
| 1061 | =-=-= | ||
diff --git a/test/lisp/progmodes/lua-mode-resources/movement.erts b/test/lisp/progmodes/lua-mode-resources/movement.erts new file mode 100644 index 00000000000..04a52e6bd01 --- /dev/null +++ b/test/lisp/progmodes/lua-mode-resources/movement.erts | |||
| @@ -0,0 +1,637 @@ | |||
| 1 | Code: | ||
| 2 | (lambda () | ||
| 3 | (lua-mode) | ||
| 4 | (beginning-of-defun 1)) | ||
| 5 | |||
| 6 | Point-Char: | | ||
| 7 | |||
| 8 | Name: beginning-of-defun moves to start of function declaration | ||
| 9 | |||
| 10 | =-= | ||
| 11 | local function Test() | ||
| 12 | if true then | ||
| 13 | print(1) | ||
| 14 | else | ||
| 15 | print(0) | ||
| 16 | end| | ||
| 17 | end | ||
| 18 | =-= | ||
| 19 | |local function Test() | ||
| 20 | if true then | ||
| 21 | print(1) | ||
| 22 | else | ||
| 23 | print(0) | ||
| 24 | end | ||
| 25 | end | ||
| 26 | =-=-= | ||
| 27 | |||
| 28 | Code: | ||
| 29 | (lambda () | ||
| 30 | (lua-mode) | ||
| 31 | (end-of-defun 1)) | ||
| 32 | |||
| 33 | Point-Char: | | ||
| 34 | |||
| 35 | Name: end-of-defun moves to end of function declaration | ||
| 36 | |||
| 37 | =-= | ||
| 38 | local function Test() | ||
| 39 | if true then | ||
| 40 | pr|int(1) | ||
| 41 | else | ||
| 42 | print(0) | ||
| 43 | end | ||
| 44 | end | ||
| 45 | |||
| 46 | local t = Test() | ||
| 47 | =-= | ||
| 48 | local function Test() | ||
| 49 | if true then | ||
| 50 | print(1) | ||
| 51 | else | ||
| 52 | print(0) | ||
| 53 | end | ||
| 54 | end | ||
| 55 | | | ||
| 56 | local t = Test() | ||
| 57 | =-=-= | ||
| 58 | |||
| 59 | Name: end-of-defun moves to end of function definition | ||
| 60 | |||
| 61 | =-= | ||
| 62 | local t = { | ||
| 63 | f = function() | ||
| 64 | re|turn true | ||
| 65 | end, | ||
| 66 | } | ||
| 67 | =-= | ||
| 68 | local t = { | ||
| 69 | f = function() | ||
| 70 | return true | ||
| 71 | | end, | ||
| 72 | } | ||
| 73 | =-=-= | ||
| 74 | |||
| 75 | Code: | ||
| 76 | (lambda () | ||
| 77 | (lua-mode) | ||
| 78 | (forward-sentence 1)) | ||
| 79 | |||
| 80 | Point-Char: | | ||
| 81 | |||
| 82 | Name: forward-sentence moves over if statements | ||
| 83 | |||
| 84 | =-= | ||
| 85 | function f() | ||
| 86 | |if true then | ||
| 87 | print(1) | ||
| 88 | elseif false then | ||
| 89 | print(0) | ||
| 90 | else | ||
| 91 | print(2) | ||
| 92 | end | ||
| 93 | end | ||
| 94 | =-= | ||
| 95 | function f() | ||
| 96 | if true then | ||
| 97 | print(1) | ||
| 98 | elseif false then | ||
| 99 | print(0) | ||
| 100 | else | ||
| 101 | print(2) | ||
| 102 | end | ||
| 103 | end| | ||
| 104 | =-=-= | ||
| 105 | |||
| 106 | Name: forward-sentence moves over variable declaration | ||
| 107 | |||
| 108 | =-= | ||
| 109 | |local n = 1 | ||
| 110 | |||
| 111 | print(n) | ||
| 112 | =-= | ||
| 113 | local n = 1| | ||
| 114 | |||
| 115 | print(n) | ||
| 116 | =-=-= | ||
| 117 | |||
| 118 | Name: forward-sentence moves over for statements | ||
| 119 | |||
| 120 | =-= | ||
| 121 | |for k, v in pairs({}) do | ||
| 122 | print(k, v) | ||
| 123 | end | ||
| 124 | |||
| 125 | print(1) | ||
| 126 | =-= | ||
| 127 | for k, v in pairs({}) do | ||
| 128 | print(k, v) | ||
| 129 | end| | ||
| 130 | |||
| 131 | print(1) | ||
| 132 | =-=-= | ||
| 133 | |||
| 134 | Name: forward-sentence moves over do statements | ||
| 135 | |||
| 136 | =-= | ||
| 137 | |do | ||
| 138 | local x = 1 | ||
| 139 | local y = 2 | ||
| 140 | |||
| 141 | print(x, y) | ||
| 142 | end | ||
| 143 | |||
| 144 | print(1) | ||
| 145 | =-= | ||
| 146 | do | ||
| 147 | local x = 1 | ||
| 148 | local y = 2| | ||
| 149 | |||
| 150 | print(x, y) | ||
| 151 | end | ||
| 152 | |||
| 153 | print(1) | ||
| 154 | =-=-= | ||
| 155 | |||
| 156 | Name: forward-sentence moves over while statements | ||
| 157 | |||
| 158 | =-= | ||
| 159 | local i = 0 | ||
| 160 | |while i < 9 do | ||
| 161 | print(i) | ||
| 162 | i = i + 1 | ||
| 163 | end | ||
| 164 | |||
| 165 | print(1) | ||
| 166 | =-= | ||
| 167 | local i = 0 | ||
| 168 | while i < 9 do | ||
| 169 | print(i) | ||
| 170 | i = i + 1 | ||
| 171 | end| | ||
| 172 | |||
| 173 | print(1) | ||
| 174 | =-=-= | ||
| 175 | |||
| 176 | Name: forward-sentence moves over repeat statements | ||
| 177 | |||
| 178 | =-= | ||
| 179 | local i = 0 | ||
| 180 | |repeat | ||
| 181 | print(i) | ||
| 182 | i = i + 1 | ||
| 183 | until i > 9 | ||
| 184 | |||
| 185 | print(1) | ||
| 186 | =-= | ||
| 187 | local i = 0 | ||
| 188 | repeat | ||
| 189 | print(i) | ||
| 190 | i = i + 1 | ||
| 191 | until i > 9| | ||
| 192 | |||
| 193 | print(1) | ||
| 194 | =-=-= | ||
| 195 | |||
| 196 | Name: forward-sentence moves over function calls | ||
| 197 | |||
| 198 | =-= | ||
| 199 | |print(1) | ||
| 200 | =-= | ||
| 201 | print(1)| | ||
| 202 | =-=-= | ||
| 203 | |||
| 204 | Name: forward-sentence moves over return statements | ||
| 205 | |||
| 206 | =-= | ||
| 207 | function f() | ||
| 208 | |return math.random() | ||
| 209 | end | ||
| 210 | =-= | ||
| 211 | function f() | ||
| 212 | return math.random() | ||
| 213 | end| | ||
| 214 | =-=-= | ||
| 215 | |||
| 216 | Code: | ||
| 217 | (lambda () | ||
| 218 | (lua-mode) | ||
| 219 | (forward-sentence 1)) | ||
| 220 | |||
| 221 | Name: forward-sentence moves over table fields | ||
| 222 | |||
| 223 | =-= | ||
| 224 | local t = { | ||
| 225 | |a = 1, | ||
| 226 | b = 2, | ||
| 227 | } | ||
| 228 | =-= | ||
| 229 | local t = { | ||
| 230 | a = 1, | ||
| 231 | b = 2, | ||
| 232 | }| | ||
| 233 | =-=-= | ||
| 234 | |||
| 235 | Code: | ||
| 236 | (lambda () | ||
| 237 | (lua-mode) | ||
| 238 | (backward-sentence 1)) | ||
| 239 | |||
| 240 | Point-Char: | | ||
| 241 | |||
| 242 | Name: backward-sentence moves over if statements | ||
| 243 | |||
| 244 | =-= | ||
| 245 | function f() | ||
| 246 | if true then | ||
| 247 | print(1) | ||
| 248 | elseif false then | ||
| 249 | print(0) | ||
| 250 | else | ||
| 251 | print(2) | ||
| 252 | end| | ||
| 253 | end | ||
| 254 | =-= | ||
| 255 | |function f() | ||
| 256 | if true then | ||
| 257 | print(1) | ||
| 258 | elseif false then | ||
| 259 | print(0) | ||
| 260 | else | ||
| 261 | print(2) | ||
| 262 | end | ||
| 263 | end | ||
| 264 | =-=-= | ||
| 265 | |||
| 266 | Name: backward-sentence moves over variable declaration | ||
| 267 | |||
| 268 | =-= | ||
| 269 | local n = 1| | ||
| 270 | |||
| 271 | print(n) | ||
| 272 | =-= | ||
| 273 | |local n = 1 | ||
| 274 | |||
| 275 | print(n) | ||
| 276 | =-=-= | ||
| 277 | |||
| 278 | Name: backward-sentence moves over for statements | ||
| 279 | |||
| 280 | =-= | ||
| 281 | for k, v in pairs({}) do | ||
| 282 | print(k, v) | ||
| 283 | end| | ||
| 284 | |||
| 285 | print(1) | ||
| 286 | =-= | ||
| 287 | |for k, v in pairs({}) do | ||
| 288 | print(k, v) | ||
| 289 | end | ||
| 290 | |||
| 291 | print(1) | ||
| 292 | =-=-= | ||
| 293 | |||
| 294 | Name: backward-sentence moves over do statements | ||
| 295 | |||
| 296 | =-= | ||
| 297 | do | ||
| 298 | local x = 1 | ||
| 299 | local y = 2 | ||
| 300 | |||
| 301 | print(x, y) | ||
| 302 | end| | ||
| 303 | |||
| 304 | print(1) | ||
| 305 | =-= | ||
| 306 | do | ||
| 307 | local x = 1 | ||
| 308 | local y = 2 | ||
| 309 | |||
| 310 | |print(x, y) | ||
| 311 | end | ||
| 312 | |||
| 313 | print(1) | ||
| 314 | =-=-= | ||
| 315 | |||
| 316 | Name: backward-sentence moves over while statements | ||
| 317 | |||
| 318 | =-= | ||
| 319 | local i = 0 | ||
| 320 | while i < 9 do | ||
| 321 | print(i) | ||
| 322 | i = i + 1 | ||
| 323 | end| | ||
| 324 | |||
| 325 | print(1) | ||
| 326 | =-= | ||
| 327 | |local i = 0 | ||
| 328 | while i < 9 do | ||
| 329 | print(i) | ||
| 330 | i = i + 1 | ||
| 331 | end | ||
| 332 | |||
| 333 | print(1) | ||
| 334 | =-=-= | ||
| 335 | |||
| 336 | Name: backward-sentence moves over repeat statements | ||
| 337 | |||
| 338 | =-= | ||
| 339 | local i = 0 | ||
| 340 | repeat | ||
| 341 | print(i) | ||
| 342 | i = i + 1 | ||
| 343 | until i > 9| | ||
| 344 | |||
| 345 | print(1) | ||
| 346 | =-= | ||
| 347 | |local i = 0 | ||
| 348 | repeat | ||
| 349 | print(i) | ||
| 350 | i = i + 1 | ||
| 351 | until i > 9 | ||
| 352 | |||
| 353 | print(1) | ||
| 354 | =-=-= | ||
| 355 | |||
| 356 | Name: backward-sentence moves over function calls | ||
| 357 | |||
| 358 | =-= | ||
| 359 | print(1)| | ||
| 360 | =-= | ||
| 361 | |print(1) | ||
| 362 | =-=-= | ||
| 363 | |||
| 364 | Name: backward-sentence moves over return statements | ||
| 365 | |||
| 366 | =-= | ||
| 367 | function f() | ||
| 368 | return math.random()| | ||
| 369 | end | ||
| 370 | =-= | ||
| 371 | |function f() | ||
| 372 | return math.random() | ||
| 373 | end | ||
| 374 | =-=-= | ||
| 375 | |||
| 376 | Code: | ||
| 377 | (lambda () | ||
| 378 | (lua-mode) | ||
| 379 | (backward-sentence 2)) | ||
| 380 | |||
| 381 | Point-Char: | | ||
| 382 | |||
| 383 | Name: backward-sentence moves over table fields | ||
| 384 | |||
| 385 | =-= | ||
| 386 | local t = { | ||
| 387 | a = 1, | ||
| 388 | b = 2|, | ||
| 389 | } | ||
| 390 | =-= | ||
| 391 | |local t = { | ||
| 392 | a = 1, | ||
| 393 | b = 2, | ||
| 394 | } | ||
| 395 | =-=-= | ||
| 396 | |||
| 397 | Code: | ||
| 398 | (lambda () | ||
| 399 | (lua-mode) | ||
| 400 | (forward-sexp 1)) | ||
| 401 | |||
| 402 | Point-Char: | | ||
| 403 | |||
| 404 | Name: forward-sexp moves over arguments | ||
| 405 | |||
| 406 | =-= | ||
| 407 | print|(1, 2, 3) | ||
| 408 | =-= | ||
| 409 | print(1, 2, 3)| | ||
| 410 | =-=-= | ||
| 411 | |||
| 412 | Name: forward-sexp moves over parameters | ||
| 413 | |||
| 414 | =-= | ||
| 415 | function f|(a, b) end | ||
| 416 | =-= | ||
| 417 | function f(a, b)| end | ||
| 418 | =-=-= | ||
| 419 | |||
| 420 | Name: forward-sexp moves over strings | ||
| 421 | |||
| 422 | =-= | ||
| 423 | print(|"1, 2, 3") | ||
| 424 | =-= | ||
| 425 | print("1, 2, 3"|) | ||
| 426 | =-=-= | ||
| 427 | |||
| 428 | Name: forward-sexp moves over tables | ||
| 429 | |||
| 430 | =-= | ||
| 431 | local t = |{ 1, | ||
| 432 | 2, | ||
| 433 | 3 } | ||
| 434 | =-= | ||
| 435 | local t = { 1, | ||
| 436 | 2, | ||
| 437 | 3 }| | ||
| 438 | =-=-= | ||
| 439 | |||
| 440 | Name: forward-sexp moves over parenthesized expressions | ||
| 441 | |||
| 442 | =-= | ||
| 443 | |(function (x) return x + 1 end)(41) | ||
| 444 | =-= | ||
| 445 | (function (x) return x + 1 end)|(41) | ||
| 446 | =-=-= | ||
| 447 | |||
| 448 | Name: forward-sexp moves over function declarations | ||
| 449 | |||
| 450 | =-= | ||
| 451 | |function foo (x) | ||
| 452 | if false then | ||
| 453 | print "foo" | ||
| 454 | elseif true then | ||
| 455 | print "bar" | ||
| 456 | end | ||
| 457 | end | ||
| 458 | =-= | ||
| 459 | function| foo (x) | ||
| 460 | if false then | ||
| 461 | print "foo" | ||
| 462 | elseif true then | ||
| 463 | print "bar" | ||
| 464 | end | ||
| 465 | end | ||
| 466 | =-=-= | ||
| 467 | |||
| 468 | Name: forward-sexp moves over do statements | ||
| 469 | |||
| 470 | =-= | ||
| 471 | |do | ||
| 472 | print(a + 1) | ||
| 473 | end | ||
| 474 | =-= | ||
| 475 | do| | ||
| 476 | print(a + 1) | ||
| 477 | end | ||
| 478 | =-=-= | ||
| 479 | |||
| 480 | Name: forward-sexp moves over for statements | ||
| 481 | |||
| 482 | =-= | ||
| 483 | |for k,v in pairs({}) do | ||
| 484 | print(k, v) | ||
| 485 | end | ||
| 486 | =-= | ||
| 487 | for| k,v in pairs({}) do | ||
| 488 | print(k, v) | ||
| 489 | end | ||
| 490 | =-=-= | ||
| 491 | |||
| 492 | Name: forward-sexp moves over repeat statements | ||
| 493 | |||
| 494 | =-= | ||
| 495 | |repeat | ||
| 496 | n = n + 1 | ||
| 497 | until n > 10 | ||
| 498 | =-= | ||
| 499 | repeat| | ||
| 500 | n = n + 1 | ||
| 501 | until n > 10 | ||
| 502 | =-=-= | ||
| 503 | |||
| 504 | Name: forward-sexp moves over while statements | ||
| 505 | |||
| 506 | =-= | ||
| 507 | |while n < 99 | ||
| 508 | do | ||
| 509 | n = n+1 | ||
| 510 | end | ||
| 511 | =-= | ||
| 512 | while| n < 99 | ||
| 513 | do | ||
| 514 | n = n+1 | ||
| 515 | end | ||
| 516 | =-=-= | ||
| 517 | |||
| 518 | Code: | ||
| 519 | (lambda () | ||
| 520 | (lua-mode) | ||
| 521 | (backward-sexp 1)) | ||
| 522 | |||
| 523 | Point-Char: | | ||
| 524 | |||
| 525 | Name: backward-sexp moves over arguments | ||
| 526 | |||
| 527 | =-= | ||
| 528 | print(1, 2, 3)| | ||
| 529 | =-= | ||
| 530 | print|(1, 2, 3) | ||
| 531 | =-=-= | ||
| 532 | |||
| 533 | Name: backward-sexp moves over parameters | ||
| 534 | |||
| 535 | =-= | ||
| 536 | function f(a, b)| end | ||
| 537 | =-= | ||
| 538 | function f|(a, b) end | ||
| 539 | =-=-= | ||
| 540 | |||
| 541 | Name: backward-sexp moves over strings | ||
| 542 | |||
| 543 | =-= | ||
| 544 | print("1, 2, 3"|) | ||
| 545 | =-= | ||
| 546 | print(|"1, 2, 3") | ||
| 547 | =-=-= | ||
| 548 | |||
| 549 | Name: backward-sexp moves over tables | ||
| 550 | |||
| 551 | =-= | ||
| 552 | local t = { 1, | ||
| 553 | 2, | ||
| 554 | 3 }| | ||
| 555 | =-= | ||
| 556 | local t = |{ 1, | ||
| 557 | 2, | ||
| 558 | 3 } | ||
| 559 | =-=-= | ||
| 560 | |||
| 561 | Name: backward-sexp moves over parenthesized expressions | ||
| 562 | |||
| 563 | =-= | ||
| 564 | (function (x) return x + 1 end)|(41) | ||
| 565 | =-= | ||
| 566 | |(function (x) return x + 1 end)(41) | ||
| 567 | =-=-= | ||
| 568 | |||
| 569 | Name: backward-sexp moves over function declarations | ||
| 570 | |||
| 571 | =-= | ||
| 572 | function foo (x) | ||
| 573 | if false then | ||
| 574 | print "foo" | ||
| 575 | elseif true then | ||
| 576 | print "bar" | ||
| 577 | end | ||
| 578 | end| | ||
| 579 | =-= | ||
| 580 | function foo (x) | ||
| 581 | if false then | ||
| 582 | print "foo" | ||
| 583 | elseif true then | ||
| 584 | print "bar" | ||
| 585 | end | ||
| 586 | |end | ||
| 587 | =-=-= | ||
| 588 | |||
| 589 | Name: backward-sexp moves over do statements | ||
| 590 | |||
| 591 | =-= | ||
| 592 | do | ||
| 593 | print(a + 1) | ||
| 594 | end| | ||
| 595 | =-= | ||
| 596 | do | ||
| 597 | print(a + 1) | ||
| 598 | |end | ||
| 599 | =-=-= | ||
| 600 | |||
| 601 | Name: backward-sexp moves over for statements | ||
| 602 | |||
| 603 | =-= | ||
| 604 | for k,v in pairs({}) do | ||
| 605 | print(k, v) | ||
| 606 | end| | ||
| 607 | =-= | ||
| 608 | for k,v in pairs({}) do | ||
| 609 | print(k, v) | ||
| 610 | |end | ||
| 611 | =-=-= | ||
| 612 | |||
| 613 | Name: backward-sexp moves over repeat statements | ||
| 614 | |||
| 615 | =-= | ||
| 616 | repeat | ||
| 617 | n = n + 1 | ||
| 618 | until n > 10| | ||
| 619 | =-= | ||
| 620 | repeat | ||
| 621 | n = n + 1 | ||
| 622 | until n > |10 | ||
| 623 | =-=-= | ||
| 624 | |||
| 625 | Name: backward-sexp moves over while statements | ||
| 626 | |||
| 627 | =-= | ||
| 628 | while n < 99 | ||
| 629 | do | ||
| 630 | n = n+1 | ||
| 631 | end| | ||
| 632 | =-= | ||
| 633 | while n < 99 | ||
| 634 | do | ||
| 635 | n = n+1 | ||
| 636 | |end | ||
| 637 | =-=-= | ||
diff --git a/test/lisp/progmodes/lua-mode-resources/which-function.lua b/test/lisp/progmodes/lua-mode-resources/which-function.lua new file mode 100644 index 00000000000..621d818461c --- /dev/null +++ b/test/lisp/progmodes/lua-mode-resources/which-function.lua | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | local function f(x) | ||
| 2 | print(x) | ||
| 3 | end | ||
diff --git a/test/lisp/progmodes/lua-mode-tests.el b/test/lisp/progmodes/lua-mode-tests.el new file mode 100644 index 00000000000..aee3a5f47cb --- /dev/null +++ b/test/lisp/progmodes/lua-mode-tests.el | |||
| @@ -0,0 +1,60 @@ | |||
| 1 | ;;; lua-mode-tests.el --- Tests for lua-mode -*- lexical-binding: t; -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2023-2025 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | ;; GNU Emacs 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 | ;; GNU Emacs 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 GNU Emacs. If not, see <https://www.gnu.org/licenses/>. | ||
| 19 | |||
| 20 | ;;; Code: | ||
| 21 | |||
| 22 | (require 'ert) | ||
| 23 | (require 'ert-font-lock) | ||
| 24 | (require 'ert-x) | ||
| 25 | (require 'hideshow) | ||
| 26 | (require 'which-func) | ||
| 27 | |||
| 28 | (ert-deftest lua-test-indentation () | ||
| 29 | (ert-test-erts-file (ert-resource-file "indent.erts"))) | ||
| 30 | |||
| 31 | (ert-deftest lua-test-movement () | ||
| 32 | (ert-test-erts-file (ert-resource-file "movement.erts"))) | ||
| 33 | |||
| 34 | (ert-deftest lua-test-font-lock () | ||
| 35 | (let ((font-lock-maximum-decoration t)) | ||
| 36 | (ert-font-lock-test-file (ert-resource-file "font-lock.lua") 'lua-mode))) | ||
| 37 | |||
| 38 | (ert-deftest lua-test-which-function () | ||
| 39 | (with-temp-buffer | ||
| 40 | (insert-file-contents (ert-resource-file "which-function.lua")) | ||
| 41 | (lua-mode) | ||
| 42 | (which-function-mode) | ||
| 43 | (goto-char (point-min)) | ||
| 44 | (should (equal "f" (which-function))) | ||
| 45 | (which-function-mode -1))) | ||
| 46 | |||
| 47 | (ert-deftest lua-test-hideshow () | ||
| 48 | (with-temp-buffer | ||
| 49 | (insert-file-contents (ert-resource-file "hide-show.lua")) | ||
| 50 | (lua-mode) | ||
| 51 | (hs-minor-mode) | ||
| 52 | (hs-hide-all) | ||
| 53 | (should (= 9 (length (overlays-in (point-min) (point-max))))) | ||
| 54 | (hs-show-all) | ||
| 55 | (should (= 0 (length (overlays-in (point-min) (point-max))))) | ||
| 56 | (hs-minor-mode -1))) | ||
| 57 | |||
| 58 | (provide 'lua-mode-tests) | ||
| 59 | |||
| 60 | ;;; lua-mode-tests.el ends here | ||