diff options
author | Georg Brandl <georg@python.org> | 2021-01-20 10:57:30 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2021-01-20 10:57:30 +0100 |
commit | b40b0cca067c2e9c2f69c91abbd27e79ad243b42 (patch) | |
tree | 6f81b370c551ea06e89ff8333b5939df5625e757 /tests/snippets/matlab | |
parent | dc9bf0c256dbd88c72349822d59b25f9d8225dc6 (diff) | |
download | pygments-git-b40b0cca067c2e9c2f69c91abbd27e79ad243b42.tar.gz |
Rename "tests/lexers" to "tests/snippets" and update the contribution
docs to point to both snippets and examplefiles.
Diffstat (limited to 'tests/snippets/matlab')
9 files changed, 260 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 00000000..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 00000000..554b4084 --- /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 +' ' Text.Whitespace +'sin' Literal.String +'\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 00000000..501407c9 --- /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 +'(' 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_keywords_ended_by_newline.txt b/tests/snippets/matlab/test_keywords_ended_by_newline.txt new file mode 100644 index 00000000..59dca038 --- /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 00000000..bf46f897 --- /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 +'(' 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 00000000..ec5ac24c --- /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 00000000..ceafb6e5 --- /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 00000000..e13d3a37 --- /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 00000000..90b2520a --- /dev/null +++ b/tests/snippets/matlab/test_single_line.txt @@ -0,0 +1,18 @@ +---input--- +set('T',300,'P',101325); + +---tokens--- +'set' Name +'(' 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 |