mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
JSSpecCompiler: Add our first test :^)
This commit is contained in:
parent
107a3b44fa
commit
00928764e9
Notes:
sideshowbarker
2024-07-16 21:51:02 +09:00
Author: https://github.com/DanShaders Commit: https://github.com/SerenityOS/serenity/commit/00928764e9 Pull-request: https://github.com/SerenityOS/serenity/pull/21612 Reviewed-by: https://github.com/ADKaster
4 changed files with 138 additions and 1 deletions
|
@ -0,0 +1,18 @@
|
|||
auto f(auto cond1, auto cond2)
|
||||
{
|
||||
int a;
|
||||
int b;
|
||||
|
||||
if (cond1) {
|
||||
a = 1;
|
||||
if (cond2) {
|
||||
b = a;
|
||||
} else {
|
||||
b = 3;
|
||||
}
|
||||
} else {
|
||||
b = 4;
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
===== AST after parser =====
|
||||
f():
|
||||
TreeList
|
||||
IfBranch
|
||||
UnresolvedReference cond1
|
||||
TreeList
|
||||
BinaryOperation Declaration
|
||||
UnresolvedReference a
|
||||
MathematicalConstant 1
|
||||
IfBranch
|
||||
UnresolvedReference cond2
|
||||
TreeList
|
||||
BinaryOperation Declaration
|
||||
UnresolvedReference b
|
||||
UnresolvedReference a
|
||||
ElseIfBranch Else
|
||||
TreeList
|
||||
BinaryOperation Declaration
|
||||
UnresolvedReference b
|
||||
MathematicalConstant 3
|
||||
ElseIfBranch Else
|
||||
TreeList
|
||||
BinaryOperation Declaration
|
||||
UnresolvedReference b
|
||||
MathematicalConstant 4
|
||||
ReturnNode
|
||||
UnresolvedReference b
|
||||
|
||||
===== AST after function-call-canonicalization =====
|
||||
f():
|
||||
TreeList
|
||||
IfBranch
|
||||
UnresolvedReference cond1
|
||||
TreeList
|
||||
BinaryOperation Declaration
|
||||
UnresolvedReference a
|
||||
MathematicalConstant 1
|
||||
IfBranch
|
||||
UnresolvedReference cond2
|
||||
TreeList
|
||||
BinaryOperation Declaration
|
||||
UnresolvedReference b
|
||||
UnresolvedReference a
|
||||
ElseIfBranch Else
|
||||
TreeList
|
||||
BinaryOperation Declaration
|
||||
UnresolvedReference b
|
||||
MathematicalConstant 3
|
||||
ElseIfBranch Else
|
||||
TreeList
|
||||
BinaryOperation Declaration
|
||||
UnresolvedReference b
|
||||
MathematicalConstant 4
|
||||
ReturnNode
|
||||
UnresolvedReference b
|
||||
|
||||
===== AST after if-branch-merging =====
|
||||
f():
|
||||
TreeList
|
||||
IfElseIfChain
|
||||
UnresolvedReference cond1
|
||||
TreeList
|
||||
BinaryOperation Declaration
|
||||
UnresolvedReference a
|
||||
MathematicalConstant 1
|
||||
IfElseIfChain
|
||||
UnresolvedReference cond2
|
||||
TreeList
|
||||
BinaryOperation Declaration
|
||||
UnresolvedReference b
|
||||
UnresolvedReference a
|
||||
TreeList
|
||||
BinaryOperation Declaration
|
||||
UnresolvedReference b
|
||||
MathematicalConstant 3
|
||||
TreeList
|
||||
BinaryOperation Declaration
|
||||
UnresolvedReference b
|
||||
MathematicalConstant 4
|
||||
ReturnNode
|
||||
UnresolvedReference b
|
||||
|
||||
===== AST after reference-resolving =====
|
||||
f():
|
||||
TreeList
|
||||
IfElseIfChain
|
||||
UnresolvedReference cond1
|
||||
TreeList
|
||||
BinaryOperation Declaration
|
||||
Var a
|
||||
MathematicalConstant 1
|
||||
IfElseIfChain
|
||||
UnresolvedReference cond2
|
||||
TreeList
|
||||
BinaryOperation Declaration
|
||||
Var b
|
||||
Var a
|
||||
TreeList
|
||||
BinaryOperation Declaration
|
||||
Var b
|
||||
MathematicalConstant 3
|
||||
TreeList
|
||||
BinaryOperation Declaration
|
||||
Var b
|
||||
MathematicalConstant 4
|
||||
ReturnNode
|
||||
Var b
|
||||
|
|
@ -23,6 +23,7 @@ GOOD_LICENSE_HEADER_PATTERN = re.compile(
|
|||
LICENSE_HEADER_CHECK_EXCLUDES = {
|
||||
'AK/Checked.h',
|
||||
'AK/Function.h',
|
||||
'Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Tests/',
|
||||
'Userland/Libraries/LibJS/SafeFunction.h',
|
||||
'Userland/Libraries/LibELF/ELFABI.h',
|
||||
'Userland/Libraries/LibCodeComprehension/Cpp/Tests/',
|
||||
|
|
|
@ -29,7 +29,17 @@ constexpr StringView stderr_capture_filename = "stderr"sv;
|
|||
constexpr StringView compiler_binary_name = "JSSpecCompiler"sv;
|
||||
constexpr StringView relative_path_to_test = "Tests"sv;
|
||||
|
||||
Array<TestDescription, 0> const regression_tests = {};
|
||||
constexpr TestDescription::Flag always_dump_ast = {
|
||||
.name = "all"sv,
|
||||
.dump_ast = true,
|
||||
};
|
||||
|
||||
const Array regression_tests = {
|
||||
TestDescription {
|
||||
.sources = { "simple.cpp"sv },
|
||||
.flags = { always_dump_ast },
|
||||
},
|
||||
};
|
||||
|
||||
static const LexicalPath path_to_compiler_binary = [] {
|
||||
auto path_to_self = LexicalPath(MUST(Core::System::current_executable_path())).parent();
|
||||
|
|
Loading…
Reference in a new issue