summaryrefslogtreecommitdiffstats
path: root/tests/snippets/matlab
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 11:33:32 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 11:33:32 +0000
commit1f403ad2197fc7442409f434ee574f3e6b46fb73 (patch)
tree0299c6dd11d5edfa918a29b6456bc1875f1d288c /tests/snippets/matlab
parentInitial commit. (diff)
downloadpygments-upstream.tar.xz
pygments-upstream.zip
Adding upstream version 2.14.0+dfsg.upstream/2.14.0+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/snippets/matlab')
-rw-r--r--tests/snippets/matlab/test_classes_with_properties.txt105
-rw-r--r--tests/snippets/matlab/test_command_mode.txt12
-rw-r--r--tests/snippets/matlab/test_comment_after_continuation.txt25
-rw-r--r--tests/snippets/matlab/test_dot_operator.txt10
-rw-r--r--tests/snippets/matlab/test_keywords_ended_by_newline.txt36
-rw-r--r--tests/snippets/matlab/test_line_continuation.txt25
-rw-r--r--tests/snippets/matlab/test_multiple_spaces_variable_assignment.txt13
-rw-r--r--tests/snippets/matlab/test_one_space_assignment.txt13
-rw-r--r--tests/snippets/matlab/test_operator_multiple_space.txt13
-rw-r--r--tests/snippets/matlab/test_single_line.txt18
10 files changed, 270 insertions, 0 deletions
diff --git a/tests/snippets/matlab/test_classes_with_properties.txt b/tests/snippets/matlab/test_classes_with_properties.txt
new file mode 100644
index 0000000..7de838eb
--- /dev/null
+++ b/tests/snippets/matlab/test_classes_with_properties.txt
@@ -0,0 +1,105 @@
+---input---
+classdef Name < dynamicprops
+ properties
+ % i am a comment
+ name1
+ name2
+ end
+ properties (Constant = true, SetAccess = protected)
+ % i too am a comment
+ matrix = [0, 1, 2];
+ string = 'i am a string'
+ end
+ methods
+ % i am also a comment
+ function self = Name()
+ % i am a comment inside a constructor
+ end
+ end
+end
+
+---tokens---
+'classdef' Keyword
+' ' Text.Whitespace
+'Name' Name
+' ' Text.Whitespace
+'<' Operator
+' ' Text.Whitespace
+'dynamicprops' Keyword
+'\n ' Text.Whitespace
+'properties' Keyword
+'\n ' Text.Whitespace
+'% i am a comment' Comment
+'\n ' Text.Whitespace
+'name1' Name
+'\n ' Text.Whitespace
+'name2' Name
+'\n ' Text.Whitespace
+'end' Keyword
+'\n ' Text.Whitespace
+'properties' Keyword
+' ' Text.Whitespace
+'(' Punctuation
+'Constant' Name.Builtin
+' ' Text.Whitespace
+'=' Punctuation
+' ' Text.Whitespace
+'true' Keyword
+',' Punctuation
+' ' Text.Whitespace
+'SetAccess' Name.Builtin
+' ' Text.Whitespace
+'=' Punctuation
+' ' Text.Whitespace
+'protected' Keyword
+')' Punctuation
+'\n ' Text.Whitespace
+'% i too am a comment' Comment
+'\n ' Text.Whitespace
+'matrix' Name
+' ' Text.Whitespace
+'=' Punctuation
+' ' Text.Whitespace
+'[' Punctuation
+'0' Literal.Number.Integer
+',' Punctuation
+' ' Text.Whitespace
+'1' Literal.Number.Integer
+',' Punctuation
+' ' Text.Whitespace
+'2' Literal.Number.Integer
+']' Punctuation
+';' Punctuation
+'\n ' Text.Whitespace
+'string' Name
+' ' Text.Whitespace
+'=' Punctuation
+' ' Text.Whitespace
+"'" Literal.String
+"i am a string'" Literal.String
+'\n ' Text.Whitespace
+'end' Keyword
+'\n ' Text.Whitespace
+'methods' Keyword
+'\n ' Text.Whitespace
+'% i am also a comment' Comment
+'\n ' Text.Whitespace
+'function' Keyword
+' ' Text.Whitespace
+'self' Text
+' ' Text.Whitespace
+'=' Punctuation
+' ' Text.Whitespace
+'Name' Name.Function
+'(' Punctuation
+')' Punctuation
+'\n ' Text.Whitespace
+'% i am a comment inside a constructor' Comment
+'\n ' Text.Whitespace
+'end' Keyword
+'\n ' Text.Whitespace
+'end' Keyword
+'\n' Text.Whitespace
+
+'end' Keyword
+'\n' Text.Whitespace
diff --git a/tests/snippets/matlab/test_command_mode.txt b/tests/snippets/matlab/test_command_mode.txt
new file mode 100644
index 0000000..e9a8c11
--- /dev/null
+++ b/tests/snippets/matlab/test_command_mode.txt
@@ -0,0 +1,12 @@
+# MATLAB allows char function arguments to not be enclosed by parentheses
+# or contain quote characters, as long as they are space separated. Test
+# that one common such function is formatted appropriately.
+
+---input---
+help sin
+
+---tokens---
+'help' Name.Builtin
+' ' Text.Whitespace
+'sin' Name.Builtin
+'\n' Text.Whitespace
diff --git a/tests/snippets/matlab/test_comment_after_continuation.txt b/tests/snippets/matlab/test_comment_after_continuation.txt
new file mode 100644
index 0000000..baf88e3
--- /dev/null
+++ b/tests/snippets/matlab/test_comment_after_continuation.txt
@@ -0,0 +1,25 @@
+# Test that text after the line continuation ellipses is marked as a comment.
+
+---input---
+set('T',300,... a comment
+'P',101325);
+
+---tokens---
+'set' Name.Builtin
+'(' Punctuation
+"'" Literal.String
+"T'" Literal.String
+',' Punctuation
+'300' Literal.Number.Integer
+',' Punctuation
+'...' Keyword
+' a comment' Comment
+'\n' Text.Whitespace
+
+"'" Literal.String
+"P'" Literal.String
+',' Punctuation
+'101325' Literal.Number.Integer
+')' Punctuation
+';' Punctuation
+'\n' Text.Whitespace
diff --git a/tests/snippets/matlab/test_dot_operator.txt b/tests/snippets/matlab/test_dot_operator.txt
new file mode 100644
index 0000000..b858cd3
--- /dev/null
+++ b/tests/snippets/matlab/test_dot_operator.txt
@@ -0,0 +1,10 @@
+# 1./x is (1)(./)(x), not (1.)(/)(x)
+
+---input---
+1./x
+
+---tokens---
+'1' Literal.Number.Integer
+'./' Operator
+'x' Name
+'\n' Text.Whitespace
diff --git a/tests/snippets/matlab/test_keywords_ended_by_newline.txt b/tests/snippets/matlab/test_keywords_ended_by_newline.txt
new file mode 100644
index 0000000..59dca03
--- /dev/null
+++ b/tests/snippets/matlab/test_keywords_ended_by_newline.txt
@@ -0,0 +1,36 @@
+# Test that keywords on their own line are marked as keywords.
+
+---input---
+if x > 100
+ disp('x > 100')
+else
+ disp('x < 100')
+end
+
+---tokens---
+'if' Keyword
+' ' Text.Whitespace
+'x' Name
+' ' Text.Whitespace
+'>' Operator
+' ' Text.Whitespace
+'100' Literal.Number.Integer
+'\n ' Text.Whitespace
+'disp' Name.Builtin
+'(' Punctuation
+"'" Literal.String
+"x > 100'" Literal.String
+')' Punctuation
+'\n' Text.Whitespace
+
+'else' Keyword
+'\n ' Text.Whitespace
+'disp' Name.Builtin
+'(' Punctuation
+"'" Literal.String
+"x < 100'" Literal.String
+')' Punctuation
+'\n' Text.Whitespace
+
+'end' Keyword
+'\n' Text.Whitespace
diff --git a/tests/snippets/matlab/test_line_continuation.txt b/tests/snippets/matlab/test_line_continuation.txt
new file mode 100644
index 0000000..1e47368
--- /dev/null
+++ b/tests/snippets/matlab/test_line_continuation.txt
@@ -0,0 +1,25 @@
+# Test that line continuation by ellipses does not produce generic
+# output on the second line.
+
+---input---
+set('T',300,...
+'P',101325);
+
+---tokens---
+'set' Name.Builtin
+'(' Punctuation
+"'" Literal.String
+"T'" Literal.String
+',' Punctuation
+'300' Literal.Number.Integer
+',' Punctuation
+'...' Keyword
+'\n' Text.Whitespace
+
+"'" Literal.String
+"P'" Literal.String
+',' Punctuation
+'101325' Literal.Number.Integer
+')' Punctuation
+';' Punctuation
+'\n' Text.Whitespace
diff --git a/tests/snippets/matlab/test_multiple_spaces_variable_assignment.txt b/tests/snippets/matlab/test_multiple_spaces_variable_assignment.txt
new file mode 100644
index 0000000..ec5ac24
--- /dev/null
+++ b/tests/snippets/matlab/test_multiple_spaces_variable_assignment.txt
@@ -0,0 +1,13 @@
+# Test that multiple spaces with an equal sign doesn't get formatted to a string.
+
+---input---
+x = 100;
+
+---tokens---
+'x' Name
+' ' Text.Whitespace
+'=' Punctuation
+' ' Text.Whitespace
+'100' Literal.Number.Integer
+';' Punctuation
+'\n' Text.Whitespace
diff --git a/tests/snippets/matlab/test_one_space_assignment.txt b/tests/snippets/matlab/test_one_space_assignment.txt
new file mode 100644
index 0000000..ceafb6e
--- /dev/null
+++ b/tests/snippets/matlab/test_one_space_assignment.txt
@@ -0,0 +1,13 @@
+# Test that one space before an equal sign is formatted correctly.
+
+---input---
+x = 100;
+
+---tokens---
+'x' Name
+' ' Text.Whitespace
+'=' Punctuation
+' ' Text.Whitespace
+'100' Literal.Number.Integer
+';' Punctuation
+'\n' Text.Whitespace
diff --git a/tests/snippets/matlab/test_operator_multiple_space.txt b/tests/snippets/matlab/test_operator_multiple_space.txt
new file mode 100644
index 0000000..e13d3a3
--- /dev/null
+++ b/tests/snippets/matlab/test_operator_multiple_space.txt
@@ -0,0 +1,13 @@
+# Test that multiple spaces with an operator doesn't get formatted to a string.
+
+---input---
+x > 100;
+
+---tokens---
+'x' Name
+' ' Text.Whitespace
+'>' Operator
+' ' Text.Whitespace
+'100' Literal.Number.Integer
+';' Punctuation
+'\n' Text.Whitespace
diff --git a/tests/snippets/matlab/test_single_line.txt b/tests/snippets/matlab/test_single_line.txt
new file mode 100644
index 0000000..72a48f8
--- /dev/null
+++ b/tests/snippets/matlab/test_single_line.txt
@@ -0,0 +1,18 @@
+---input---
+set('T',300,'P',101325);
+
+---tokens---
+'set' Name.Builtin
+'(' Punctuation
+"'" Literal.String
+"T'" Literal.String
+',' Punctuation
+'300' Literal.Number.Integer
+',' Punctuation
+"'" Literal.String
+"P'" Literal.String
+',' Punctuation
+'101325' Literal.Number.Integer
+')' Punctuation
+';' Punctuation
+'\n' Text.Whitespace