branch: externals/matlab-mode
commit 7a39c1b5ab11ecb6e6c03384e244e3104eb2c3b9
Author: John Ciolfi <[email protected]>
Commit: John Ciolfi <[email protected]>
matlab-ts-mode: enable test for matlab tree-sitter issue 117
---
...ndent_line_cont_unary_in_cell_or_mat_issue117.m | 24 +++---
...ine_cont_unary_in_cell_or_mat_issue117.skip.txt | 1 -
...e_cont_unary_in_cell_or_mat_issue117_expected.m | 21 +++++
...t_unary_in_cell_or_mat_issue117_expected_msgs.m | 21 +++++
...ndent_line_cont_unary_in_cell_or_mat_issue117.m | 21 +++++
...ine_cont_unary_in_cell_or_mat_issue117.skip.txt | 1 -
...cont_unary_in_cell_or_mat_issue117_expected.txt | 68 ++++++++++++++++
tests/test-matlab-ts-mode-parser.el | 92 +++++++++++-----------
8 files changed, 191 insertions(+), 58 deletions(-)
diff --git
a/tests/test-matlab-ts-mode-indent-files/indent_line_cont_unary_in_cell_or_mat_issue117.m
b/tests/test-matlab-ts-mode-indent-files/indent_line_cont_unary_in_cell_or_mat_issue117.m
index 07e3b9480d..667aa84b5e 100644
---
a/tests/test-matlab-ts-mode-indent-files/indent_line_cont_unary_in_cell_or_mat_issue117.m
+++
b/tests/test-matlab-ts-mode-indent-files/indent_line_cont_unary_in_cell_or_mat_issue117.m
@@ -2,20 +2,20 @@
% See https://github.com/acristoffers/tree-sitter-matlab/issues/117
-m1 = [-100 -200...
- -300];
+m1 = [-100.0 -200.0...
+ -300.0];
-c1 = {-100 -200...
- -300};
+c1 = {-100.0 -200.0...
+ -300.0};
-m1 = [-100 -200 ...
- -300];
+m1 = [-100.0 -200.0 ...
+ -300.0];
-c1 = {-100 -200 ...
- -300};
+c1 = {-100.0 -200.0 ...
+ -300.0};
-m1 = [-100 -200,...
- -300];
+m1 = [-100.0 -200.0,...
+ -300.0];
-c1 = {-100 -200,...
- -300};
+c1 = {-100.0 -200.0,...
+ -300.0};
diff --git
a/tests/test-matlab-ts-mode-indent-files/indent_line_cont_unary_in_cell_or_mat_issue117.skip.txt
b/tests/test-matlab-ts-mode-indent-files/indent_line_cont_unary_in_cell_or_mat_issue117.skip.txt
deleted file mode 100644
index 9f0d023f04..0000000000
---
a/tests/test-matlab-ts-mode-indent-files/indent_line_cont_unary_in_cell_or_mat_issue117.skip.txt
+++ /dev/null
@@ -1 +0,0 @@
-See https://github.com/acristoffers/tree-sitter-matlab/issues/117
diff --git
a/tests/test-matlab-ts-mode-indent-files/indent_line_cont_unary_in_cell_or_mat_issue117_expected.m
b/tests/test-matlab-ts-mode-indent-files/indent_line_cont_unary_in_cell_or_mat_issue117_expected.m
new file mode 100644
index 0000000000..578a26c990
--- /dev/null
+++
b/tests/test-matlab-ts-mode-indent-files/indent_line_cont_unary_in_cell_or_mat_issue117_expected.m
@@ -0,0 +1,21 @@
+% -*- matlab-ts -*-
+
+% See https://github.com/acristoffers/tree-sitter-matlab/issues/117
+
+m1 = [-100.0 -200.0...
+ -300.0];
+
+c1 = {-100.0 -200.0...
+ -300.0};
+
+m1 = [-100.0 -200.0 ...
+ -300.0];
+
+c1 = {-100.0 -200.0 ...
+ -300.0};
+
+m1 = [-100.0 -200.0,...
+ -300.0];
+
+c1 = {-100.0 -200.0,...
+ -300.0};
diff --git
a/tests/test-matlab-ts-mode-indent-files/indent_line_cont_unary_in_cell_or_mat_issue117_expected_msgs.m
b/tests/test-matlab-ts-mode-indent-files/indent_line_cont_unary_in_cell_or_mat_issue117_expected_msgs.m
new file mode 100644
index 0000000000..952310b731
--- /dev/null
+++
b/tests/test-matlab-ts-mode-indent-files/indent_line_cont_unary_in_cell_or_mat_issue117_expected_msgs.m
@@ -0,0 +1,21 @@
+% -*- matlab-ts -*- % <{Matched rule: ((lambda (node parent _bol &rest _)
(and node (not (string= (treesit-node-type node) "line_continuation")) (equal
(treesit-node-type parent) "source_file"))) (lambda (_node _parent bol &rest _)
(save-excursion (goto-char bol) (line-beginning-position))) 0)}>
+
+% See https://github.com/acristoffers/tree-sitter-matlab/issues/117 %
<{Matched rule: ((lambda (node parent _bol &rest _) (and node (not (string=
(treesit-node-type node) "line_continuation")) (equal (treesit-node-type
parent) "source_file"))) (lambda (_node _parent bol &rest _) (save-excursion
(goto-char bol) (line-beginning-position))) 0)}>
+
+m1 = [-100.0 -200.0... % <{Matched rule: ((lambda (node parent _bol &rest _)
(and node (not (string= (treesit-node-type node) "line_continuation")) (equal
(treesit-node-type parent) "source_file"))) (lambda (_node _parent bol &rest _)
(save-excursion (goto-char bol) (line-beginning-position))) 0)}>
+ -300.0]; % <{Matched rule: ((parent-is
"\\`\\(?:function_output\\|row\\)\\'") parent 0)}>
+
+c1 = {-100.0 -200.0... % <{Matched rule: ((lambda (node parent _bol &rest _)
(and node (not (string= (treesit-node-type node) "line_continuation")) (equal
(treesit-node-type parent) "source_file"))) (lambda (_node _parent bol &rest _)
(save-excursion (goto-char bol) (line-beginning-position))) 0)}>
+ -300.0}; % <{Matched rule: ((parent-is
"\\`\\(?:function_output\\|row\\)\\'") parent 0)}>
+
+m1 = [-100.0 -200.0 ... % <{Matched rule: ((lambda (node parent _bol &rest _)
(and node (not (string= (treesit-node-type node) "line_continuation")) (equal
(treesit-node-type parent) "source_file"))) (lambda (_node _parent bol &rest _)
(save-excursion (goto-char bol) (line-beginning-position))) 0)}>
+ -300.0]; % <{Matched rule: ((parent-is
"\\`\\(?:function_output\\|row\\)\\'") parent 0)}>
+
+c1 = {-100.0 -200.0 ... % <{Matched rule: ((lambda (node parent _bol &rest _)
(and node (not (string= (treesit-node-type node) "line_continuation")) (equal
(treesit-node-type parent) "source_file"))) (lambda (_node _parent bol &rest _)
(save-excursion (goto-char bol) (line-beginning-position))) 0)}>
+ -300.0}; % <{Matched rule: ((parent-is
"\\`\\(?:function_output\\|row\\)\\'") parent 0)}>
+
+m1 = [-100.0 -200.0,... % <{Matched rule: ((lambda (node parent _bol &rest _)
(and node (not (string= (treesit-node-type node) "line_continuation")) (equal
(treesit-node-type parent) "source_file"))) (lambda (_node _parent bol &rest _)
(save-excursion (goto-char bol) (line-beginning-position))) 0)}>
+ -300.0]; % <{Matched rule: ((parent-is
"\\`\\(?:function_output\\|row\\)\\'") parent 0)}>
+
+c1 = {-100.0 -200.0,... % <{Matched rule: ((lambda (node parent _bol &rest _)
(and node (not (string= (treesit-node-type node) "line_continuation")) (equal
(treesit-node-type parent) "source_file"))) (lambda (_node _parent bol &rest _)
(save-excursion (goto-char bol) (line-beginning-position))) 0)}>
+ -300.0}; % <{Matched rule: ((parent-is
"\\`\\(?:function_output\\|row\\)\\'") parent 0)}>
diff --git
a/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-indent-files/indent_line_cont_unary_in_cell_or_mat_issue117.m
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-indent-files/indent_line_cont_unary_in_cell_or_mat_issue117.m
new file mode 100644
index 0000000000..667aa84b5e
--- /dev/null
+++
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-indent-files/indent_line_cont_unary_in_cell_or_mat_issue117.m
@@ -0,0 +1,21 @@
+% -*- matlab-ts -*-
+
+% See https://github.com/acristoffers/tree-sitter-matlab/issues/117
+
+m1 = [-100.0 -200.0...
+ -300.0];
+
+c1 = {-100.0 -200.0...
+ -300.0};
+
+m1 = [-100.0 -200.0 ...
+ -300.0];
+
+c1 = {-100.0 -200.0 ...
+ -300.0};
+
+m1 = [-100.0 -200.0,...
+ -300.0];
+
+c1 = {-100.0 -200.0,...
+ -300.0};
diff --git
a/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-indent-files/indent_line_cont_unary_in_cell_or_mat_issue117.skip.txt
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-indent-files/indent_line_cont_unary_in_cell_or_mat_issue117.skip.txt
deleted file mode 100644
index 9f0d023f04..0000000000
---
a/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-indent-files/indent_line_cont_unary_in_cell_or_mat_issue117.skip.txt
+++ /dev/null
@@ -1 +0,0 @@
-See https://github.com/acristoffers/tree-sitter-matlab/issues/117
diff --git
a/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-indent-files/indent_line_cont_unary_in_cell_or_mat_issue117_expected.txt
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-indent-files/indent_line_cont_unary_in_cell_or_mat_issue117_expected.txt
new file mode 100644
index 0000000000..2192839a00
--- /dev/null
+++
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-indent-files/indent_line_cont_unary_in_cell_or_mat_issue117_expected.txt
@@ -0,0 +1,68 @@
+# -*- t-utils-ts-parse-tree -*-
+(source_file (comment[1,20]@{% -*- matlab-ts -*-}@) (comment[22,89]@{% See
https://github.com/acristoffers/tree-sitter-...}@)
+ (assignment left: (identifier[91,93]@{m1}@) =[94,95]
+ right:
+ (matrix [[96,97]
+ (row
+ (unary_operator -[97,98] operand: (number[98,103]@{100.0}@))
+ ,[104,104]
+ (unary_operator -[104,105] operand: (number[105,110]@{200.0}@))
+ (line_continuation[110,125]@{...\n }@) ,[125,125]
+ (unary_operator -[125,126] operand: (number[126,131]@{300.0}@)))
+ ][131,132]))
+ ;[132,133]
+ (assignment left: (identifier[135,137]@{c1}@) =[138,139]
+ right:
+ (cell {[140,141]
+ (row
+ (unary_operator -[141,142] operand: (number[142,147]@{100.0}@))
+ ,[148,148]
+ (unary_operator -[148,149] operand: (number[149,154]@{200.0}@))
+ (line_continuation[154,169]@{...\n }@) ,[169,169]
+ (unary_operator -[169,170] operand: (number[170,175]@{300.0}@)))
+ }[175,176]))
+ ;[176,177]
+ (assignment left: (identifier[179,181]@{m1}@) =[182,183]
+ right:
+ (matrix [[184,185]
+ (row
+ (unary_operator -[185,186] operand: (number[186,191]@{100.0}@))
+ ,[192,192]
+ (unary_operator -[192,193] operand: (number[193,198]@{200.0}@))
+ (line_continuation[199,214]@{...\n }@) ,[214,214]
+ (unary_operator -[214,215] operand: (number[215,220]@{300.0}@)))
+ ][220,221]))
+ ;[221,222]
+ (assignment left: (identifier[224,226]@{c1}@) =[227,228]
+ right:
+ (cell {[229,230]
+ (row
+ (unary_operator -[230,231] operand: (number[231,236]@{100.0}@))
+ ,[237,237]
+ (unary_operator -[237,238] operand: (number[238,243]@{200.0}@))
+ (line_continuation[244,259]@{...\n }@) ,[259,259]
+ (unary_operator -[259,260] operand: (number[260,265]@{300.0}@)))
+ }[265,266]))
+ ;[266,267]
+ (assignment left: (identifier[269,271]@{m1}@) =[272,273]
+ right:
+ (matrix [[274,275]
+ (row
+ (unary_operator -[275,276] operand: (number[276,281]@{100.0}@))
+ ,[282,282]
+ (unary_operator -[282,283] operand: (number[283,288]@{200.0}@))
+ ,[288,289] (line_continuation[289,293]@{...\n}@)
+ (unary_operator -[304,305] operand: (number[305,310]@{300.0}@)))
+ ][310,311]))
+ ;[311,312]
+ (assignment left: (identifier[314,316]@{c1}@) =[317,318]
+ right:
+ (cell {[319,320]
+ (row
+ (unary_operator -[320,321] operand: (number[321,326]@{100.0}@))
+ ,[327,327]
+ (unary_operator -[327,328] operand: (number[328,333]@{200.0}@))
+ ,[333,334] (line_continuation[334,338]@{...\n}@)
+ (unary_operator -[349,350] operand: (number[350,355]@{300.0}@)))
+ }[355,356]))
+ ;[356,357] \n[357,358])
diff --git a/tests/test-matlab-ts-mode-parser.el
b/tests/test-matlab-ts-mode-parser.el
index 86d3791d25..09b6d614c8 100644
--- a/tests/test-matlab-ts-mode-parser.el
+++ b/tests/test-matlab-ts-mode-parser.el
@@ -129,52 +129,56 @@ If UPDATE-IF-NEEDED is t, update the file by copying it,
else return a
string which is empty if no-updates needed, otherwise the string tells
you that updates are needed."
- (setq test-matlab-ts-mode-parser--file-ht (make-hash-table :test #'equal))
-
- (let* ((all-m-files (cl-delete-if (lambda (m-file)
- (let ((use
(test-matlab-ts-mode-parser--use-file m-file)))
- (not use)))
- (directory-files-recursively "." (rx ".m"
eos))))
- (copy-of-m-files (cl-delete-if (lambda (m-file)
- (not (string-match-p
-
"^./test-matlab-ts-mode-parser-files/copy-of-"
- m-file)))
- (directory-files-recursively
- "./test-matlab-ts-mode-parser-files"
(rx ".m" eos))))
- (updates (mapcar #'test-matlab-ts-mode-parser--update-file
all-m-files))
- (n-updates 0))
-
- (dolist (tuple updates)
- (let ((update (nth 0 tuple))
- (m-file (nth 1 tuple))
- (test-m-file (nth 2 tuple)))
- (when update
+ (let* ((me (symbol-file 'test-matlab-ts-mode-parser--all-files))
+ (my-dir (file-name-directory me))
+ (default-directory my-dir))
+
+ (setq test-matlab-ts-mode-parser--file-ht (make-hash-table :test #'equal))
+
+ (let* ((all-m-files (cl-delete-if (lambda (m-file)
+ (let ((use
(test-matlab-ts-mode-parser--use-file m-file)))
+ (not use)))
+ (directory-files-recursively "." (rx
".m" eos))))
+ (copy-of-m-files (cl-delete-if (lambda (m-file)
+ (not (string-match-p
+
"^./test-matlab-ts-mode-parser-files/copy-of-"
+ m-file)))
+ (directory-files-recursively
+
"./test-matlab-ts-mode-parser-files" (rx ".m" eos))))
+ (updates (mapcar #'test-matlab-ts-mode-parser--update-file
all-m-files))
+ (n-updates 0))
+
+ (dolist (tuple updates)
+ (let ((update (nth 0 tuple))
+ (m-file (nth 1 tuple))
+ (test-m-file (nth 2 tuple)))
+ (when update
+ (setq n-updates (1+ n-updates))
+ (when update-if-needed
+ (let ((dir (file-name-directory test-m-file)))
+ (when (not (file-directory-p dir))
+ (make-directory dir t)))
+ (copy-file m-file test-m-file t)))))
+
+ (dolist (copy-of-m-file copy-of-m-files)
+ (when (not (gethash copy-of-m-file
test-matlab-ts-mode-parser--file-ht))
(setq n-updates (1+ n-updates))
(when update-if-needed
- (let ((dir (file-name-directory test-m-file)))
- (when (not (file-directory-p dir))
- (make-directory dir t)))
- (copy-file m-file test-m-file t)))))
-
- (dolist (copy-of-m-file copy-of-m-files)
- (when (not (gethash copy-of-m-file test-matlab-ts-mode-parser--file-ht))
- (setq n-updates (1+ n-updates))
- (when update-if-needed
- (delete-file copy-of-m-file))
- (let ((expected (replace-regexp-in-string "\\.m$" "_expected.txt"
copy-of-m-file)))
- (when (file-exists-p expected)
- (delete-file expected)
- (when update-if-needed
- expected)))))
-
- (if update-if-needed
- (format "%d file(s) updated" n-updates)
- (if (= n-updates 0)
- ""
- (format (concat "%d ./test-matlab-ts-mode-parser-files/*.m require
updating, run "
- "M-: (test-matlab-ts-mode-parser--all-files t) "
- "to update them")
- n-updates)))))
+ (delete-file copy-of-m-file))
+ (let ((expected (replace-regexp-in-string "\\.m$" "_expected.txt"
copy-of-m-file)))
+ (when (file-exists-p expected)
+ (delete-file expected)
+ (when update-if-needed
+ expected)))))
+
+ (if update-if-needed
+ (format "%d file(s) updated" n-updates)
+ (if (= n-updates 0)
+ ""
+ (format (concat "%d ./test-matlab-ts-mode-parser-files/*.m require
updating, run "
+ "M-: (test-matlab-ts-mode-parser--all-files t) "
+ "to update them")
+ n-updates))))))
(provide 'test-matlab-ts-mode-parser)
;;; test-matlab-ts-mode-parser.el ends here