Reorganize tests into a real spec suite

This commit is contained in:
2024-08-04 19:18:43 -03:00
parent 57c160173c
commit e7c2053222
693 changed files with 136 additions and 116 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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