* bug#67605: [PATCH] Add font-lock tests for lua-ts-mode
@ 2023-12-03 17:06 john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
[not found] ` <handler.67605.B.170162347725836.ack@debbugs.gnu.org>
0 siblings, 1 reply; 3+ messages in thread
From: john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-12-03 17:06 UTC (permalink / raw)
To: 67605
Tags: patch
Adds font-lock tests to the repo now that ert-font-lock is
included.
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#67605: Acknowledgement ([PATCH] Add font-lock tests for lua-ts-mode)
[not found] ` <handler.67605.B.170162347725836.ack@debbugs.gnu.org>
@ 2023-12-03 17:18 ` john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-09 8:58 ` Eli Zaretskii
0 siblings, 1 reply; 3+ messages in thread
From: john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-12-03 17:18 UTC (permalink / raw)
To: 67605
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0001-Add-font-lock-tests-for-lua-ts-mode-bug-67605.patch --]
[-- Type: text/x-patch, Size: 10095 bytes --]
From 249430935fb3cb0ee0e6b808922bef84a66b9cb7 Mon Sep 17 00:00:00 2001
From: john muhl <jm@pub.pink>
Date: Sun, 3 Dec 2023 10:56:04 -0600
Subject: [PATCH] Add font-lock tests for lua-ts-mode (bug#67605)
* test/lisp/progmodes/lua-ts-mode-tests.el (lua-ts-test-font-lock):
Add ert-font-lock tests.
(lua-ts-mode-test-indentation):
(lua-ts-test-indentation):
(lua-ts-mode-test-movement):
(lua-ts-test-movement): Rename for consistency.
* test/lisp/progmodes/lua-ts-mode-resources/font-lock.lua: New
file.
---
.../lua-ts-mode-resources/font-lock.lua | 339 ++++++++++++++++++
test/lisp/progmodes/lua-ts-mode-tests.el | 10 +-
2 files changed, 347 insertions(+), 2 deletions(-)
create mode 100644 test/lisp/progmodes/lua-ts-mode-resources/font-lock.lua
diff --git a/test/lisp/progmodes/lua-ts-mode-resources/font-lock.lua b/test/lisp/progmodes/lua-ts-mode-resources/font-lock.lua
new file mode 100644
index 00000000000..93d589e3825
--- /dev/null
+++ b/test/lisp/progmodes/lua-ts-mode-resources/font-lock.lua
@@ -0,0 +1,339 @@
+#!/usr/bin/env lua
+-- ^ font-lock-comment-face
+-- Comment
+-- <- font-lock-comment-delimiter-face
+-- ^ font-lock-comment-face
+--[[
+-- ^ font-lock-comment-face
+Multi-line comment
+-- ^ font-lock-comment-face
+]]
+-- <- font-lock-comment-face
+local line_comment = "comment" -- comment
+-- ^ font-lock-comment-face
+
+-- Definition
+local function f1() end
+-- ^ font-lock-function-name-face
+local f2 = function() end
+-- ^ font-lock-function-name-face
+local tb = { f1 = function() end }
+-- ^ font-lock-function-name-face
+function tb.f2() end
+-- ^ font-lock-function-name-face
+function tb:f3() end
+-- ^ font-lock-function-name-face
+tbl.f4 = function() end
+-- ^ font-lock-function-name-face
+function x.y:z() end
+-- ^ font-lock-function-name-face
+
+-- Keyword
+if true then
+-- <- font-lock-keyword-face
+-- ^ font-lock-keyword-face
+elseif true then
+-- <- font-lock-keyword-face
+else end
+-- <- font-lock-keyword-face
+-- ^ font-lock-keyword-face
+local p = {}
+-- ^ font-lock-keyword-face
+for k,v in pairs({}) do end
+-- <- font-lock-keyword-face
+-- ^ font-lock-keyword-face
+repeat if true then break end until false
+-- <- font-lock-keyword-face
+-- ^ font-lock-keyword-face
+-- ^ font-lock-keyword-face
+while true do end
+-- <- font-lock-keyword-face
+-- ^ font-lock-keyword-face
+function fn() return true end
+-- <- font-lock-keyword-face
+-- ^ font-lock-keyword-face
+goto label1
+-- ^ font-lock-keyword-face
+::label1::
+if true and not false or nil then
+-- ^ font-lock-keyword-face
+-- ^ font-lock-keyword-face
+-- ^ font-lock-keyword-face
+end
+
+-- String
+local _
+_ = "x"
+-- ^ font-lock-string-face
+_ = 'x'
+-- ^ font-lock-string-face
+_ = "x\ty"
+-- ^ font-lock-string-face
+-- ^ font-lock-string-face
+_ = "x\"y"
+-- ^ font-lock-string-face
+-- ^ font-lock-string-face
+_ = 'x\'y'
+-- ^ font-lock-string-face
+-- ^ font-lock-string-face
+_ = "x\z
+ y"
+-- ^ font-lock-string-face
+_ = "x\0900y"
+-- ^ font-lock-string-face
+_ = "x\09y"
+-- ^ font-lock-string-face
+_ = "x\0y"
+-- ^ font-lock-string-face
+_ = "x\u{1f602}y"
+-- ^ font-lock-string-face
+_ = [[x]]
+-- ^ font-lock-string-face
+_ = [=[x]=]
+-- ^ font-lock-string-face
+
+-- Assignment
+local n = 0
+-- ^ font-lock-variable-name-face
+o, p, q = 1, 2, 3
+-- <- font-lock-variable-name-face
+-- ^ font-lock-variable-name-face
+-- ^ font-lock-variable-name-face
+tbl[k] = "A"
+-- ^ font-lock-variable-name-face
+tbl.x = 1
+-- ^ font-lock-variable-name-face
+for i=0,9 do end
+-- ^ font-lock-variable-name-face
+
+-- Constant
+local x <const> = 1
+-- ^ font-lock-constant-face
+local f <close> = io.open('/file')
+-- ^ font-lock-constant-face
+local a, b, c = true, false, nil
+-- ^ font-lock-constant-face
+-- ^ font-lock-constant-face
+-- ^ font-lock-constant-face
+::label2::
+-- ^ font-lock-constant-face
+goto label2
+-- ^ font-lock-constant-face
+
+-- Number
+n = 123
+-- ^ font-lock-number-face
+print(99)
+-- ^ font-lock-number-face
+print(tbl[1])
+-- ^ font-lock-number-face
+
+-- Bracket
+local t = {}
+-- ^ font-lock-bracket-face
+-- ^ font-lock-bracket-face
+print(t[1])
+-- ^ font-lock-bracket-face
+-- ^ font-lock-bracket-face
+-- ^ font-lock-bracket-face
+-- ^ font-lock-bracket-face
+
+-- Builtin
+assert()
+-- <- font-lock-builtin-face
+bit32()
+-- <- font-lock-builtin-face
+collectgarbage()
+-- <- font-lock-builtin-face
+coroutine()
+-- <- font-lock-builtin-face
+debug()
+-- <- font-lock-builtin-face
+dofile()
+-- <- font-lock-builtin-face
+error()
+-- <- font-lock-builtin-face
+getmetatable()
+-- <- font-lock-builtin-face
+io()
+-- <- font-lock-builtin-face
+ipairs()
+-- <- font-lock-builtin-face
+load()
+-- <- font-lock-builtin-face
+loadfile()
+-- <- font-lock-builtin-face
+math()
+-- <- font-lock-builtin-face
+next()
+-- <- font-lock-builtin-face
+os()
+-- <- font-lock-builtin-face
+package()
+-- <- font-lock-builtin-face
+pairs()
+-- <- font-lock-builtin-face
+pcall()
+-- <- font-lock-builtin-face
+print()
+-- <- font-lock-builtin-face
+rawequal()
+-- <- font-lock-builtin-face
+rawget()
+-- <- font-lock-builtin-face
+rawlen()
+-- <- font-lock-builtin-face
+rawset()
+-- <- font-lock-builtin-face
+require()
+-- <- font-lock-builtin-face
+select()
+-- <- font-lock-builtin-face
+setmetatable()
+-- <- font-lock-builtin-face
+string()
+-- <- font-lock-builtin-face
+table()
+-- <- font-lock-builtin-face
+tonumber()
+-- <- font-lock-builtin-face
+tostring()
+-- <- font-lock-builtin-face
+type()
+-- <- font-lock-builtin-face
+utf8()
+-- <- font-lock-builtin-face
+warn()
+-- <- font-lock-builtin-face
+xpcall()
+-- <- font-lock-builtin-face
+print(_G)
+-- ^ font-lock-builtin-face
+print(_VERSION)
+-- ^ font-lock-builtin-face
+f.close()
+-- ^ font-lock-builtin-face
+f.flush()
+-- ^ font-lock-builtin-face
+f.lines()
+-- ^ font-lock-builtin-face
+f.read()
+-- ^ font-lock-builtin-face
+f.seek()
+-- ^ font-lock-builtin-face
+f.setvbuf()
+-- ^ font-lock-builtin-face
+f.write()
+-- ^ font-lock-builtin-face
+
+-- Delimiter
+t = { 1, 2 };
+-- ^ font-lock-delimiter-face
+-- ^ font-lock-delimiter-face
+
+-- Escape
+_ = "x\ty"
+-- ^ font-lock-escape-face
+-- ^ font-lock-escape-face
+_ = "x\"y"
+-- ^ font-lock-escape-face
+-- ^ font-lock-escape-face
+_ = 'x\'y'
+-- ^ font-lock-escape-face
+-- ^ font-lock-escape-face
+_ = "x\z
+ y"
+-- <- font-lock-escape-face
+_ = "x\x5Ay"
+-- ^ font-lock-escape-face
+-- ^ font-lock-escape-face
+_ = "x\0900y"
+-- ^ font-lock-escape-face
+_ = "x\09y"
+-- ^ font-lock-escape-face
+_ = "x\0y"
+-- ^ font-lock-escape-face
+_ = "x\u{1f602}y"
+-- ^ font-lock-escape-face
+-- ^ font-lock-escape-face
+
+-- Function
+func_one()
+-- ^ font-lock-function-call-face
+tbl.func_two()
+-- ^ font-lock-function-call-face
+tbl:func_three()
+-- ^ font-lock-function-call-face
+tbl.f = f4()
+-- ^ font-lock-function-call-face
+
+-- Operator
+local a, b = 1, 2
+-- ^ font-lock-operator-face
+print(a & b)
+-- ^ font-lock-operator-face
+print(a | b)
+-- ^ font-lock-operator-face
+print(a ~ b)
+-- ^ font-lock-operator-face
+print(a << 1)
+-- ^ font-lock-operator-face
+-- ^ font-lock-operator-face
+print(a >> 1)
+-- ^ font-lock-operator-face
+-- ^ font-lock-operator-face
+print(a+b-a*b/a%b^a//b)
+-- ^ font-lock-operator-face
+-- ^ font-lock-operator-face
+-- ^ font-lock-operator-face
+-- ^ font-lock-operator-face
+-- ^ font-lock-operator-face
+-- ^ font-lock-operator-face
+-- ^ font-lock-operator-face
+print(#t)
+-- ^ font-lock-operator-face
+print("h".."at")
+-- ^ font-lock-operator-face
+print(a==b)
+-- ^ font-lock-operator-face
+print(a~=b)
+-- ^ font-lock-operator-face
+print(a<=b)
+-- ^ font-lock-operator-face
+print(a>=b)
+-- ^ font-lock-operator-face
+print(a<b)
+-- ^ font-lock-operator-face
+print(a>b)
+-- ^ font-lock-operator-face
+function ff(...) end
+-- ^ font-lock-operator-face
+
+-- Property
+t = { a=1 }
+-- ^ font-lock-property-name-face
+print(t.a)
+-- ^ font-lock-property-use-face
+
+-- Punctuation
+tbl.f2()
+-- ^ font-lock-punctuation-face
+tbl:f3()
+-- ^ font-lock-punctuation-face
+
+-- Variable
+function fn(x, y) end
+-- ^ font-lock-variable-name-face
+-- ^ font-lock-variable-name-face
+fn(a, b)
+-- ^ font-lock-variable-use-face
+-- ^ font-lock-variable-use-face
+print(a + b)
+-- ^ font-lock-variable-use-face
+-- ^ font-lock-variable-use-face
+print(t[a])
+-- ^ font-lock-variable-use-face
+tbl.f1(p)
+-- ^ font-lock-variable-use-face
+tbl:f2(q)
+-- ^ font-lock-variable-use-face
diff --git a/test/lisp/progmodes/lua-ts-mode-tests.el b/test/lisp/progmodes/lua-ts-mode-tests.el
index d2105b66f6d..8a566d777e3 100644
--- a/test/lisp/progmodes/lua-ts-mode-tests.el
+++ b/test/lisp/progmodes/lua-ts-mode-tests.el
@@ -20,17 +20,23 @@
;;; Code:
(require 'ert)
+(require 'ert-font-lock)
(require 'ert-x)
(require 'treesit)
-(ert-deftest lua-ts-mode-test-indentation ()
+(ert-deftest lua-ts-test-indentation ()
(skip-unless (treesit-ready-p 'lua))
(ert-test-erts-file (ert-resource-file "indent.erts")))
-(ert-deftest lua-ts-mode-test-movement ()
+(ert-deftest lua-ts-test-movement ()
(skip-unless (treesit-ready-p 'lua))
(ert-test-erts-file (ert-resource-file "movement.erts")))
+(ert-deftest lua-ts-test-font-lock ()
+ (skip-unless (treesit-ready-p 'lua))
+ (let ((treesit-font-lock-level 4))
+ (ert-font-lock-test-file (ert-resource-file "font-lock.lua") 'lua-ts-mode)))
+
(provide 'lua-ts-mode-tests)
;;; lua-ts-mode-tests.el ends here
--
2.41.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#67605: Acknowledgement ([PATCH] Add font-lock tests for lua-ts-mode)
2023-12-03 17:18 ` bug#67605: Acknowledgement ([PATCH] Add font-lock tests for lua-ts-mode) john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-12-09 8:58 ` Eli Zaretskii
0 siblings, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2023-12-09 8:58 UTC (permalink / raw)
To: john muhl; +Cc: 67605-done
> Date: Sun, 03 Dec 2023 11:18:13 -0600
> From: john muhl via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>
>
> >From 249430935fb3cb0ee0e6b808922bef84a66b9cb7 Mon Sep 17 00:00:00 2001
> From: john muhl <jm@pub.pink>
> Date: Sun, 3 Dec 2023 10:56:04 -0600
> Subject: [PATCH] Add font-lock tests for lua-ts-mode (bug#67605)
>
> * test/lisp/progmodes/lua-ts-mode-tests.el (lua-ts-test-font-lock):
> Add ert-font-lock tests.
> (lua-ts-mode-test-indentation):
> (lua-ts-test-indentation):
> (lua-ts-mode-test-movement):
> (lua-ts-test-movement): Rename for consistency.
> * test/lisp/progmodes/lua-ts-mode-resources/font-lock.lua: New
> file.
Thanks, installed on the master branch, and closing the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-12-09 8:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-03 17:06 bug#67605: [PATCH] Add font-lock tests for lua-ts-mode john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
[not found] ` <handler.67605.B.170162347725836.ack@debbugs.gnu.org>
2023-12-03 17:18 ` bug#67605: Acknowledgement ([PATCH] Add font-lock tests for lua-ts-mode) john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-12-09 8:58 ` Eli Zaretskii
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).