diff options
Diffstat (limited to 'llm-tools-hl-test.el')
| -rw-r--r-- | llm-tools-hl-test.el | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/llm-tools-hl-test.el b/llm-tools-hl-test.el index 5b50f14..b849c14 100644 --- a/llm-tools-hl-test.el +++ b/llm-tools-hl-test.el | |||
| @@ -4,20 +4,20 @@ | |||
| 4 | (ert-deftest llm-tools--hl-file-read-test () | 4 | (ert-deftest llm-tools--hl-file-read-test () |
| 5 | "Test that 'llm-tools--hl-file-read' produces correct hashline format." | 5 | "Test that 'llm-tools--hl-file-read' produces correct hashline format." |
| 6 | (let* ((content "\ | 6 | (let* ((content "\ |
| 7 | const TITLE = \"Mr\"; | 7 | ;; greeting.el |
| 8 | export function greet(name) { | 8 | (defconst greeting-title \"Mr\") |
| 9 | \treturn [ | 9 | (defun greet (name) |
| 10 | \t TITLE, | 10 | (concat |
| 11 | \t name?.trim() || \"guest\", | 11 | greeting-title |
| 12 | \t].join(\" \"); | 12 | (or (string-trim name) \"guest\")) |
| 13 | }") | 13 | )") |
| 14 | (file (make-temp-file nil nil nil content)) | 14 | (file (make-temp-file nil nil nil content)) |
| 15 | (actual (llm-tools--hl-file-read file))) | 15 | (actual (llm-tools--hl-file-read file))) |
| 16 | (unwind-protect | 16 | (unwind-protect |
| 17 | (progn | 17 | (progn |
| 18 | (should (= (length (string-lines actual)) 7)) | 18 | (should (= (length (string-lines actual)) 7)) |
| 19 | (should (string-match-p "\\`1vx|const TITLE" actual)) | 19 | (should (string-match-p "\\`1gi|;; greeting" actual)) |
| 20 | (should (string-match-p "7gv|}\\'" actual))) | 20 | (should (string-match-p "7ce|)\\'" actual))) |
| 21 | (delete-file file)))) | 21 | (delete-file file)))) |
| 22 | 22 | ||
| 23 | (ert-deftest llm-tools--hl-anchor-to-line-num-test () | 23 | (ert-deftest llm-tools--hl-anchor-to-line-num-test () |
| @@ -26,15 +26,15 @@ export function greet(name) { | |||
| 26 | (should (= (llm-tools--hl-anchor-to-line-num "1vx") 1))) | 26 | (should (= (llm-tools--hl-anchor-to-line-num "1vx") 1))) |
| 27 | 27 | ||
| 28 | (ert-deftest llm-tools--hl-parse-section-single-replace () | 28 | (ert-deftest llm-tools--hl-parse-section-single-replace () |
| 29 | (let ((section "= 1vx..1vx\n~const TITLE = \"Mrs\";")) | 29 | (let ((section "= 1vx..1vx\n~(defconst greeting-title \"Mrs\")")) |
| 30 | (should (= (length (llm-tools--hl-parse-section section)) 1)) | 30 | (should (= (length (llm-tools--hl-parse-section section)) 1)) |
| 31 | (let ((op (car (llm-tools--hl-parse-section section)))) | 31 | (let ((op (car (llm-tools--hl-parse-section section)))) |
| 32 | (should (eq (hl-op-type op) 'replace)) | 32 | (should (eq (hl-op-type op) 'replace)) |
| 33 | (should (equal (hl-op-range op) '("1vx" "1vx"))) | 33 | (should (equal (hl-op-range op) '("1vx" "1vx"))) |
| 34 | (should (equal (hl-op-payload op) '("const TITLE = \"Mrs\";")))))) | 34 | (should (equal (hl-op-payload op) '("(defconst greeting-title \"Mrs\")")))))) |
| 35 | 35 | ||
| 36 | (ert-deftest llm-tools--hl-parse-section-multi-line-payload () | 36 | (ert-deftest llm-tools--hl-parse-section-multi-line-payload () |
| 37 | (let ((section "= 3gv..6be\n~\treturn [\n~\t\t\"Mrs\",\n~\t\tname?.trim() || \"guest\",\n~\t].join(\" \");")) | 37 | (let ((section "= 3gv..6be\n~ (concat\n~ greeting-title\n~ (or (string-trim name) \"guest\"))\n~ )")) |
| 38 | (let ((op (car (llm-tools--hl-parse-section section)))) | 38 | (let ((op (car (llm-tools--hl-parse-section section)))) |
| 39 | (should (= (length (hl-op-payload op)) 4))))) | 39 | (should (= (length (hl-op-payload op)) 4))))) |
| 40 | 40 | ||
| @@ -46,14 +46,14 @@ export function greet(name) { | |||
| 46 | (should (null (hl-op-payload op)))))) | 46 | (should (null (hl-op-payload op)))))) |
| 47 | 47 | ||
| 48 | (ert-deftest llm-tools--hl-parse-section-insert-after () | 48 | (ert-deftest llm-tools--hl-parse-section-insert-after () |
| 49 | (let ((section "+ 4ei\n~\t\t\"Dr\",")) | 49 | (let ((section "+ 4ei\n~ greeting-title")) |
| 50 | (let ((op (car (llm-tools--hl-parse-section section)))) | 50 | (let ((op (car (llm-tools--hl-parse-section section)))) |
| 51 | (should (eq (hl-op-type op) 'insert-after)) | 51 | (should (eq (hl-op-type op) 'insert-after)) |
| 52 | (should (string= (hl-op-anchor op) "4ei")) | 52 | (should (string= (hl-op-anchor op) "4ei")) |
| 53 | (should (equal (hl-op-payload op) '("\t\t\"Dr\",")))))) | 53 | (should (equal (hl-op-payload op) '(" greeting-title")))))) |
| 54 | 54 | ||
| 55 | (ert-deftest llm-tools--hl-parse-section-insert-before () | 55 | (ert-deftest llm-tools--hl-parse-section-insert-before () |
| 56 | (let ((section "< 5ff\n~\t\t\"Dr\",")) | 56 | (let ((section "< 5ff\n~ greeting-title")) |
| 57 | (let ((op (car (llm-tools--hl-parse-section section)))) | 57 | (let ((op (car (llm-tools--hl-parse-section section)))) |
| 58 | (should (eq (hl-op-type op) 'insert-before)) | 58 | (should (eq (hl-op-type op) 'insert-before)) |
| 59 | (should (string= (hl-op-anchor op) "5ff"))))) | 59 | (should (string= (hl-op-anchor op) "5ff"))))) |
