1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 20:17:44 +00:00

LibGLSL: Add tests for GLSL parser

This commit is contained in:
Poseydon42 2023-07-23 23:10:25 +01:00 committed by Jelle Raaijmakers
parent 29972876e4
commit d160ff2f8d
24 changed files with 368 additions and 0 deletions

View file

@ -0,0 +1,11 @@
TranslationUnit[0:0->3:0]
FunctionDeclaration[0:0->3:0]
Type[0:0->0:3]
void
foo
(
)
FunctionDefinition[1:0->3:0]
{
DiscardStatement[2:4->2:11]
}

View file

@ -0,0 +1,5 @@
void foo()
{
discard;
}

View file

@ -0,0 +1,63 @@
TranslationUnit[0:0->3:0]
FunctionDeclaration[0:0->3:0]
Type[0:0->0:3]
void
foo
(
)
FunctionDefinition[1:0->3:0]
{
VariableDeclaration[2:4->2:66]
Type[2:4->2:6]
int
a
BinaryExpression[2:12->2:66]
BinaryExpression[2:12->2:57]
BinaryExpression[2:12->2:48]
BinaryExpression[2:12->2:36]
BinaryExpression[2:12->2:22]
NumericLiteral[2:12->2:12]
1
+
BinaryExpression[2:16->2:22]
NumericLiteral[2:16->2:16]
2
*
NumericLiteral[2:20->2:20]
3
+
BinaryExpression[2:24->2:36]
BinaryExpression[2:25->2:30]
NumericLiteral[2:25->2:25]
4
-
NumericLiteral[2:29->2:29]
2
/
NumericLiteral[2:34->2:34]
2
+
FunctionCall[2:38->2:48]
Name[2:38->2:40]
max
(
NumericLiteral[2:42->2:42]
7
NumericLiteral[2:45->2:45]
8
)
-
MemberExpression[2:50->2:57]
Name[2:50->2:52]
bar
Name[2:54->2:55]
xy
+
ArrayElementExpression[2:59->2:66]
Name[2:59->2:61]
abc
[
NumericLiteral[2:63->2:64]
13
]
}

View file

@ -0,0 +1,5 @@
void foo()
{
int a = 1 + 2 * 3 + (4 - 2) / 2 + max(7, 8) - bar.xy + abc[13];
}

View file

@ -0,0 +1,37 @@
TranslationUnit[0:0->5:0]
FunctionDeclaration[0:0->5:0]
Type[0:0->0:3]
void
main
(
)
FunctionDefinition[1:0->5:0]
{
VariableDeclaration[2:4->2:13]
Type[2:4->2:6]
int
b
NumericLiteral[2:12->2:12]
0
ForStatement[3:4->4:11]
Initializer:
VariableDeclaration[3:9->3:18]
Type[3:9->3:11]
int
a
NumericLiteral[3:17->3:17]
0
Test expression:
BooleanLiteral[3:20->3:23]
true
Update expression:
UnaryExpression[3:26->3:29]
postfix ++
Name[3:26->3:26]
a
Body:
UnaryExpression[4:8->4:11]
postfix ++
Name[4:8->4:8]
b
}

View file

@ -0,0 +1,7 @@
void main()
{
int b = 0;
for (int a = 0; true; a++)
b++;
}

View file

@ -0,0 +1,15 @@
TranslationUnit[0:0->0:24]
FunctionDeclaration[0:0->0:24]
Type[0:0->0:2]
int
main
(
Parameter[0:9->0:13]
a
Type[0:9->0:11]
int
Parameter[0:16->0:22]
b
Type[0:16->0:20]
float
)

View file

@ -0,0 +1,2 @@
int main(int a, float b);

View file

@ -0,0 +1,13 @@
TranslationUnit[0:0->3:0]
FunctionDeclaration[0:0->3:0]
Type[0:0->0:2]
int
main
(
)
FunctionDefinition[1:0->3:0]
{
ReturnStatement[2:1->2:9]
NumericLiteral[2:8->2:8]
1
}

View file

@ -0,0 +1,5 @@
int main()
{
return 1;
}

View file

@ -0,0 +1,26 @@
TranslationUnit[0:0->6:0]
FunctionDeclaration[0:0->6:0]
Type[0:0->0:3]
bool
foo
(
)
FunctionDefinition[1:0->6:0]
{
IfStatement[2:4->5:20]
Predicate:
BinaryExpression[2:8->2:14]
NumericLiteral[2:8->2:8]
1
==
NumericLiteral[2:13->2:13]
2
Then:
ReturnStatement[3:8->3:19]
BooleanLiteral[3:15->3:18]
true
Else:
ReturnStatement[5:8->5:20]
BooleanLiteral[5:15->5:19]
false
}

View file

@ -0,0 +1,8 @@
bool foo()
{
if (1 == 2)
return true;
else
return false;
}

View file

@ -0,0 +1,23 @@
TranslationUnit[0:0->8:0]
FunctionDeclaration[0:0->3:0]
Type[0:0->0:3]
void
foo
(
)
FunctionDefinition[1:0->3:0]
{
ReturnStatement[2:4->2:10]
}
FunctionDeclaration[5:0->8:0]
Type[5:0->5:2]
int
bar
(
)
FunctionDefinition[6:0->8:0]
{
ReturnStatement[7:4->7:12]
NumericLiteral[7:11->7:11]
3
}

View file

@ -0,0 +1,10 @@
void foo()
{
return;
}
int bar()
{
return 3;
}

View file

@ -0,0 +1,7 @@
TranslationUnit[0:0->3:1]
StructDeclaration[0:7->3:1]
foo
VariableDeclaration[2:4->3:0]
Type[2:4->2:6]
int
bar

View file

@ -0,0 +1,5 @@
struct foo
{
int bar;
};

View file

@ -0,0 +1,32 @@
TranslationUnit[0:0->4:0]
FunctionDeclaration[0:0->4:0]
Type[0:0->0:3]
void
foo
(
)
FunctionDefinition[1:0->4:0]
{
VariableDeclaration[2:4->2:13]
Type[2:4->2:6]
int
a
NumericLiteral[2:12->2:12]
7
VariableDeclaration[3:4->3:22]
Type[3:4->3:6]
int
b
UnaryExpression[3:12->3:22]
prefix ~
UnaryExpression[3:14->3:21]
prefix !
UnaryExpression[3:15->3:21]
prefix ~
UnaryExpression[3:16->3:21]
prefix ++
UnaryExpression[3:18->3:21]
postfix ++
Name[3:18->3:18]
a
}

View file

@ -0,0 +1,6 @@
void foo()
{
int a = 7;
int b = ~(!~++a++);
}

View file

@ -0,0 +1,13 @@
TranslationUnit[0:0->2:16]
VariableDeclaration[0:0->1:0]
Type[0:0->0:11]
uniform vec3
u_Color
VariableDeclaration[1:0->2:0]
Type[1:0->1:6]
in vec3
i_VertexColor
VariableDeclaration[2:0->2:16]
Type[2:0->2:7]
out vec4
o_Color

View file

@ -0,0 +1,4 @@
uniform vec3 u_Color;
in vec3 i_VertexColor;
out vec4 o_Color;