branch: externals/matlab-mode
commit 3498ef710d2f46e830ad41e7c32c51c7d237bc8d
Author: John Ciolfi <john.ciolfi...@gmail.com>
Commit: John Ciolfi <john.ciolfi...@gmail.com>

    matlab-ts-mode: add keywords tests, fix handling of spmd keyword
---
 matlab-ts-mode.el                                  |  5 +-
 .../test-matlab-ts-mode-font-lock-files/keywords.m | 63 ++++++++++++++++++++++
 .../keywords_expected.txt                          | 63 ++++++++++++++++++++++
 .../test_spmd.m                                    |  6 +++
 .../test_spmd_expected.txt                         |  6 +++
 5 files changed, 140 insertions(+), 3 deletions(-)

diff --git a/matlab-ts-mode.el b/matlab-ts-mode.el
index 798a9d2a6a..98f8ab7494 100644
--- a/matlab-ts-mode.el
+++ b/matlab-ts-mode.el
@@ -93,6 +93,7 @@
       "persistent"
       "properties"
       (return_statement)
+      "spmd"
       "switch"
       "try"
       "while")
@@ -176,9 +177,7 @@ START and END specify the region to be fontified."
    ;; Keywords: if, else, etc.
    :language 'matlab
    :feature 'keyword
-   `(([,@matlab-ts-mode--keywords] @font-lock-keyword-face)
-     ;; spmd is "incorrectly" identified as an identifier, hence special case 
that
-     (((identifier) @font-lock-keyword-face (:equal "spmd" 
@font-lock-keyword-face))))
+   `(([,@matlab-ts-mode--keywords] @font-lock-keyword-face))
 
    ;; function/classdef
    :language 'matlab
diff --git a/tests/test-matlab-ts-mode-font-lock-files/keywords.m 
b/tests/test-matlab-ts-mode-font-lock-files/keywords.m
new file mode 100644
index 0000000000..42281184e5
--- /dev/null
+++ b/tests/test-matlab-ts-mode-font-lock-files/keywords.m
@@ -0,0 +1,63 @@
+% -*- matlab-ts -*-
+classdef keywords
+    properties
+        p1 = 0
+    end
+    methods
+        function method1(in)
+           arguments
+               in (1,1) double
+           end  
+
+           global gVar1 gVar2
+           global pVar1 pVar2
+
+           try
+                switch in
+                  case 10
+                    disp('10')
+                 otherwise
+                   disp('~10')
+                end
+            catch me
+               rethrow(me)
+           end
+
+           j = 0;
+           for n = 1:in
+               if mod(n, 5)
+                   continue
+                elseif mod(n, 7)
+                   continue
+               else
+                   j = j + 1;
+                end
+                disp(['Divisible by 5 or 7 : ' num2str(n)])
+            end
+
+            x = 0
+           while x < 10
+               x = x + 1;
+            end
+        end
+
+        function method2()
+            n = 200;
+            A = 500;
+            a = zeros(1,n);
+            parfor i = 1:n
+                a(i) = max(abs(eig(rand(A))));
+            end
+
+           return
+       end
+    end
+
+    events
+    end
+
+    enumeration
+       one
+       two
+    end        
+end
diff --git a/tests/test-matlab-ts-mode-font-lock-files/keywords_expected.txt 
b/tests/test-matlab-ts-mode-font-lock-files/keywords_expected.txt
new file mode 100644
index 0000000000..051b3261a5
--- /dev/null
+++ b/tests/test-matlab-ts-mode-font-lock-files/keywords_expected.txt
@@ -0,0 +1,63 @@
+c ccc ccccccccc ccc
+kkkkkkkk ffffffff
+    kkkkkkkkkk
+        PP d n
+    kkk
+    kkkkkkk
+        kkkkkkkk fffffffbvvb
+           kkkkkkkkk
+               PP bnDnb tttttt
+           kkk  
+
+           kkkkkk ddddd ddddd
+           kkkkkk ddddd ddddd
+
+           kkk
+                kkkkkk dd
+                  kkkk nn
+                    ddddbSssSb
+                 kkkkkkkkk
+                   ddddbSsssSb
+                kkk
+            kkkkk dd
+               dddddddbddb
+           kkk
+
+           d d nD
+           kkk d d nDdd
+               kk dddbdD nb
+                   kkkkkkkk
+                kkkkkk dddbdD nb
+                   kkkkkkkk
+               kkkk
+                   d d d d nD
+                kkk
+                ddddbbSsssssssss ss s ss s s S dddddddbdbbb
+            kkk
+
+            d d n
+           kkkkk d d nn
+               d d d d nD
+            kkk
+        kkk
+
+        kkkkkkkk fffffffbb
+            d d nnnD
+            d d nnnD
+            d d dddddbnDdbD
+            kkkkkk d d nDd
+                dbdb d dddbdddbdddbddddbdbbbbD
+            kkk
+
+           kkkkkk
+       kkk
+    kkk
+
+    kkkkkk
+    kkk
+
+    kkkkkkkkkkk
+       PPP
+       PPP
+    kkk        
+kkk
diff --git a/tests/test-matlab-ts-mode-font-lock-files/test_spmd.m 
b/tests/test-matlab-ts-mode-font-lock-files/test_spmd.m
new file mode 100644
index 0000000000..daeabad02d
--- /dev/null
+++ b/tests/test-matlab-ts-mode-font-lock-files/test_spmd.m
@@ -0,0 +1,6 @@
+% -*- matlab-ts -*-
+% https://github.com/acristoffers/tree-sitter-matlab/issues/25
+parpool(3)
+spmd
+    q = magic(spmdIndex + 2);
+end
diff --git a/tests/test-matlab-ts-mode-font-lock-files/test_spmd_expected.txt 
b/tests/test-matlab-ts-mode-font-lock-files/test_spmd_expected.txt
new file mode 100644
index 0000000000..fcb029a173
--- /dev/null
+++ b/tests/test-matlab-ts-mode-font-lock-files/test_spmd_expected.txt
@@ -0,0 +1,6 @@
+c ccc ccccccccc ccc
+c cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+dddddddbnb
+kkkk
+    d d dddddbddddddddd d nbD
+ddd

Reply via email to