branch: elpa/lua-mode
commit 3a0fb4bfe83f6702eba9f84991c7eb3b3b3fc5f7
Author: Nikita Bloshchanevich <[email protected]>
Commit: Nikita Bloshchanevich <[email protected]>
`lua-funcname-at-point': add tests
---
test/test-funcname-at-point.el | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/test/test-funcname-at-point.el b/test/test-funcname-at-point.el
new file mode 100644
index 0000000..a73b368
--- /dev/null
+++ b/test/test-funcname-at-point.el
@@ -0,0 +1,31 @@
+;;; test-funcname-at-point.el --- Test `lua-funcname-at-point'
+
+;;; Commentary:
+
+;; Ensure that `lua-funcname-at-point' works correctly in all intended
+;; circumstances.
+
+;;; Code:
+
+(describe "Test `lua-funcname-at-point'."
+ (it "handles trailing periods"
+ (with-temp-buffer
+ (insert "table.insert.")
+ (backward-char)
+ (expect (lua-funcname-at-point) :to-equal "table.insert")))
+ (it "handles point being in the middle"
+ (with-temp-buffer
+ (insert "table.")
+ (save-excursion
+ (insert "insert."))
+ (expect (lua-funcname-at-point) :to-equal "table.insert")))
+ (it "handles point being at the start of the buffer"
+ (with-temp-buffer
+ (save-excursion (insert "table.insert."))
+ (expect (lua-funcname-at-point) :to-equal "table.insert")))
+ (it "ignores identifiers before point"
+ (with-temp-buffer
+ (insert "table.insert.")
+ (expect (lua-funcname-at-point) :to-be nil))))
+
+;;; test-funcname-at-point.el ends here