mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:27:35 +00:00
Tests: Add regression tests for the LibCpp preprocessor
Similarly to the LibCpp parser regression tests, these tests run the preprocessor on the .cpp test files under Userland/LibCpp/Tests/preprocessor, and compare the output with existing .txt ground truth files.
This commit is contained in:
parent
a38c330c68
commit
e57fdb63f8
13 changed files with 101 additions and 3 deletions
2
Userland/Libraries/LibCpp/Tests/preprocessor/macro1.cpp
Normal file
2
Userland/Libraries/LibCpp/Tests/preprocessor/macro1.cpp
Normal file
|
@ -0,0 +1,2 @@
|
|||
#define ADD(x,y) x+y
|
||||
ADD(2,5);
|
4
Userland/Libraries/LibCpp/Tests/preprocessor/macro1.txt
Normal file
4
Userland/Libraries/LibCpp/Tests/preprocessor/macro1.txt
Normal file
|
@ -0,0 +1,4 @@
|
|||
Integer 1:0-1:2 (2)
|
||||
Plus 1:0-1:2 (+)
|
||||
Integer 1:0-1:2 (5)
|
||||
Semicolon 1:8-1:8 (;)
|
3
Userland/Libraries/LibCpp/Tests/preprocessor/macro2.cpp
Normal file
3
Userland/Libraries/LibCpp/Tests/preprocessor/macro2.cpp
Normal file
|
@ -0,0 +1,3 @@
|
|||
#define M(x) String {x + "lo"}
|
||||
|
||||
M("he" + "l")
|
8
Userland/Libraries/LibCpp/Tests/preprocessor/macro2.txt
Normal file
8
Userland/Libraries/LibCpp/Tests/preprocessor/macro2.txt
Normal file
|
@ -0,0 +1,8 @@
|
|||
KnownType 2:0-2:0 (String)
|
||||
LeftCurly 2:0-2:0 ({)
|
||||
DoubleQuotedString 2:0-2:0 ("he")
|
||||
Plus 2:0-2:0 (+)
|
||||
DoubleQuotedString 2:0-2:0 ("l")
|
||||
Plus 2:0-2:0 (+)
|
||||
DoubleQuotedString 2:0-2:0 ("lo")
|
||||
RightCurly 2:0-2:0 (})
|
4
Userland/Libraries/LibCpp/Tests/preprocessor/macro3.cpp
Normal file
4
Userland/Libraries/LibCpp/Tests/preprocessor/macro3.cpp
Normal file
|
@ -0,0 +1,4 @@
|
|||
#define M(x, y, z) x y = z;
|
||||
|
||||
M(Vector, vec, ({1,2}))
|
||||
|
11
Userland/Libraries/LibCpp/Tests/preprocessor/macro3.txt
Normal file
11
Userland/Libraries/LibCpp/Tests/preprocessor/macro3.txt
Normal file
|
@ -0,0 +1,11 @@
|
|||
KnownType 2:0-2:0 (Vector)
|
||||
Identifier 2:0-2:0 (vec)
|
||||
Equals 2:0-2:0 (=)
|
||||
LeftParen 2:0-2:0 (()
|
||||
LeftCurly 2:0-2:0 ({)
|
||||
Integer 2:0-2:0 (1)
|
||||
Comma 2:0-2:0 (,)
|
||||
Integer 2:0-2:0 (2)
|
||||
RightCurly 2:0-2:0 (})
|
||||
RightParen 2:0-2:0 ())
|
||||
Semicolon 2:0-2:0 (;)
|
|
@ -0,0 +1,2 @@
|
|||
#define NUMBER 1337
|
||||
int x = NUMBER;
|
|
@ -0,0 +1,5 @@
|
|||
KnownType 1:0-1:2 (int)
|
||||
Identifier 1:4-1:4 (x)
|
||||
Equals 1:6-1:6 (=)
|
||||
Integer 1:8-1:13 (1337)
|
||||
Semicolon 1:14-1:14 (;)
|
Loading…
Add table
Add a link
Reference in a new issue